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

Getting Enum fields/attributes in trimmed and AOT'd applications #105506

Closed
eerhardt opened this issue Jul 25, 2024 · 4 comments · Fixed by #105524
Closed

Getting Enum fields/attributes in trimmed and AOT'd applications #105506

eerhardt opened this issue Jul 25, 2024 · 4 comments · Fixed by #105524
Assignees
Labels
area-NativeAOT-coreclr area-Tools-ILLink .NET linker development as well as trimming analyzers
Milestone

Comments

@eerhardt
Copy link
Member

Similar to #97737, we should support more scenarios where we know a Type is an Enum type without emitting warnings.

The example scenario comes from https://github.com/microsoft/OpenAPI.NET/pull/1717/files#diff-c59c9153ccf5e00142826d1c5e4d3d92470aac0bc740a302a23557432141277c

        public static T GetAttributeOfType<T>(this Enum enumValue) where T : Attribute
        {
            var type = enumValue.GetType();
            var memInfo = type.GetField(enumValue.ToString(), BindingFlags.Public | BindingFlags.Static);

This code shouldn't warn because type is guaranteed to be an Enum type.

This scenario was explicitly not supported in #105351. We should support it.

cc @sbomer @MichalStrehovsky

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jul 25, 2024
@sbomer sbomer added this to the 9.0.0 milestone Jul 25, 2024
@sbomer sbomer added area-Tools-ILLink .NET linker development as well as trimming analyzers and removed untriaged New issue has not been triaged by the area owner labels Jul 25, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

@sbomer sbomer self-assigned this Jul 25, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@sbomer sbomer closed this as completed in 7102706 Jul 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-NativeAOT-coreclr area-Tools-ILLink .NET linker development as well as trimming analyzers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants