RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.4k stars 535 forks source link

Implement Roslyn Source Generator to generate from file in a project #1307

Open xperiandri opened 3 years ago

mio991 commented 3 years ago

I am on this but got stuck with NuGet packaging, if somebody can help me to change the packaging so that the output gets also packaged under analyzers/dotnet/cs I will do the rest (I hope). Also only the netstandard2.0 stuff needs to go there?

I have build one Source Generator already at work.

I begun here: https://github.com/mio991/NJsonSchema/tree/roslyn-integration

mio991 commented 3 years ago

Ok, I tried some more and got something to work.

JamieMagee commented 3 years ago

@mio991 Could you open a PR with your changes?

xperiandri commented 3 years ago

You can also use my results from https://github.com/sdedalus/JsonSchemaToSource if needed

JohnYoungers commented 2 years ago

Did this solution end up making it into the library?

I'm trying to create a program to analyze our applications looking for certain method calls, and reporting on the types that are used within that call: I was hoping to document the types with their json schema but I'm having a hard time finding an existing solution that uses a ITypeSymbol as the source opposed to a System.Type

xperiandri commented 2 years ago

Is it from Source Generators API v2?

JohnYoungers commented 2 years ago

This wouldn't necessarily be for source generation, but I believe it would be dealing with the same roslyn types used in the source generators.

Being able to analyze the semanticmodel opposed to concrete types: https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.csharp.csharpextensions.gettypeinfo?view=roslyn-dotnet-4.2.0