Replies: 3 comments 5 replies
-
|
Source generators can't trigger other source generators is a problem. Eg if you put the attributes of the system text json generator in our generator it won't cause it to generate in the same assembly If you do your json generation in a separate project it can work That's my concern anyway |
Beta Was this translation helpful? Give feedback.
-
|
dotnet/roslyn#57912 Thanks! To clarify the constraint: Roslyn source generators don’t have a defined run order and each generator sees the same initial compilation. Code/attributes that one generator emits aren’t visible to other generators in the same compilation round, so adding JsonPropertyName/JsonInclude from ReactiveUI.SourceGenerators won’t cause the System.Text.Json source generator to pick them up in that project. That’s by design of the generator pipeline (no inter-generator dependencies / ordering). |
Beta Was this translation helpful? Give feedback.
-
|
The work around:
So my point is likely we'd be potentially adding to our support workload where people aren't understanding the output from our ReactiveUI source generator isn't having the desired output on the STJ output. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Just started migrating to ReactiveUI.SourceGenerators from ReactiveUI.Fody. While Fody was very elegant, I do support the move towards source generators for a variety of reasons, although it's still a bit awkward and working with the source is not quite so convenient.
I can live with it all, but I would like to suggest support for attaching System.Text.Json attributes to the generated property.
If you're using the System.Text.Json source generator, which is reasonable given that this is about ReactiveUI.SourceGenerators, it can't serialize private fields. So the explicitly declared private field for example
_myProperty, annoted with ReactiveUI.SourceGenerators[Reactive]attribute generates a public propertyMyProperty.The problem is that you can't tell the source generator to add a System.Text.Json
JsonPropertyNameor any other such attributes. It would be really nice if it could support at leastJsonPropertyName,JsonIncludeandJsonIgnore.I'm not sure if I like the idea of having
ReactiveUI.SourceGenerators.JsonPropertyNameAttributeetc. as the risk for mistakes is too large, I think. Or maybe not, it would look nice... The alternative would perhaps be arguments to the attribute, i.e. something like:[Reactive(JsonInclude = true, JsonPropertyName = "my_property")]Or am I completely missing something? Is System.Text.Json supported somehow, and I'm just not reading the documentation properly?
Comments, suggestions, thoughts appreciated.
Never did any work with source generators, but it can't be that hard... If I get some kind of provisional go ahead from the maintainers I could give it a go try to make a pull request.
Beta Was this translation helpful? Give feedback.
All reactions