Skip to content

Confusing AOT IL3035 error regarding Enums during Source Generation #112562

Answered by MichalStrehovsky
thomhurst asked this question in Q&A
Discussion options

You must be logged in to vote

Looks like some of the properties on SourceGeneratedMethodInformation are marked as [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]. My guess is that one of the types assigned to this property (on the line numbers reported by the analysis) are either enums, or have nested types that are enums (.All includes nested types).

This assignment then means that all methods on System.Enum should be considered targets of reflection (because .All also means all methods, including inherited). But that includes Enum.GetValues(Type) and this method is not safe to call in an AOT compiled app (it's marked as RequiredDynamicCode).

It's possible the app doesn't end up reflecting on that me…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MichalStrehovsky
Comment options

Answer selected by MichalStrehovsky
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
2 participants