Feeding source generated enum into json source generator #115299
Unanswered
JenyaRostov
asked this question in
Q&A
Replies: 1 comment 5 replies
-
Note that this is not related to the runtime nor the BCL, and strictly speaking also not directly related to the C# language itself. This issue is related to the build pipeline (roslyn), and there is already (still) an open issue tracking this limitation: dotnet/roslyn#57239 |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, i have a source generator that generates enums based on classes i have in my project
In total i have 3 enums generated, one of which represents type of network request (one enum value per request class)
That enum is used in RequestMessage class, as a property
I get that class typeinfo by doing this:
JsonContext.Default.GetTypeInfo(typeof(TRequest))
And this is the error i get:
System.NotSupportedException: JsonTypeInfo metadata for type 'Proto.RequestType' was not provided by TypeInfoResolver of type 'Proto.JsonContext'
The main point of all of that is that i want to use that class(and generated enum) in a NativeAOT scenario, and for that i use json source generator. But you can't feed output of one SG to another, which leads to the question
How do i use that generated enum with json in NativeAOT? I tried custom converters (as suggested in discord), but that didn't work
The only solution i can think of is enabling reflection, but i don't know how to enable it
Beta Was this translation helpful? Give feedback.
All reactions