[release/9.0-staging] Support generic fields in PersistedAssemblyBuilder by github-actions[bot] · Pull Request #110839 · dotnet/runtime

Backport of #110372 to release/9.0-staging

/cc @steveharter

Customer Impact

  • Customer reported
  • Found internally

The new PersistableAssemblyBuilder functionality added in v9 has a bug where generic fields do not generate the proper IL, causing a generic field to be generated as non-generic.

Regression

  • Yes
  • No

This was new functionality added in v9.

Testing

The original author's repro was verified and a test added that inspects the generated field's metadata to make sure the field is generic.

Risk

Low; the fix is fairly straightforward and follows other similar cases where we need to use metadata from open generic types instead of the closed generic type.