Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsValueType not set correctly for custom attribute fields of an enum type #941

Open
Zastai opened this issue May 3, 2024 · 2 comments
Open

Comments

@Zastai
Copy link
Contributor

Zastai commented May 3, 2024

All parts of the TypeReference for such an enum are right, it's just not flagged as a value type. As a result, using that TypeReference elsewhere results in load/resolve-time errors when using the modified assembly.

Looks like the reading for custom attribute fields/properties (AssemblyReader.ReadCustomAttributeFieldOrPropType) sees ElementType.Enum and then bases the TypeReference on the type name it finds.

@Zastai Zastai changed the title IsValueType not set correctly for custom attribute fields of a (non-framework) enum type IsValueType not set correctly for custom attribute fields of an enum type May 3, 2024
@ltrzesniewski
Copy link
Contributor

Hmm, this reminds me of something: https://github.com/ltrzesniewski/InlineIL.Fody/blob/b257467995801ee2f3a4db44aef86acfcceccbc9/src/InlineIL.Fody/Model/TypeRefBuilder.cs#L174-L181

I wrote the following comment:

TypeRefs from different assemblies get imported as MetadataType.Class
since this information is not stored in the assembly metadata.

IIRC this applies to all value types, not only enums, since the TypeRef metadata table does not store this flag.

@Zastai
Copy link
Contributor Author

Zastai commented May 3, 2024

Yes, for the general case where there is just an utf8 type name to be resolved in the typeref table, that's understandable.

But here the ElementType adds that extra bit of information, because (afaik) all enums are value types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants