source generator
Is it possible to output a .json file from a source generator or does it only work with c# files?
10 Replies
this is what i have currently and it generates a "test.json.cs" file instead
ontop of getting this error
It might be possible to output it as a resource or a const string
Source generators, IIRC, hook directly into the compiler and emit the files there
They don't work like T4 templates
i see.. how would i output as a resource?
Huh, now that I'm looking at it, I'm not sure it's possible after all...
Maybe peeps in #roslyn would know more
Only thing I could find is this GH issue
atm SGs can only produce source
I asked a similar question recently https://discord.com/channels/143867839282020352/598678594750775301/1195136293181591602
jcotton42
random question, what approach would you take to generate something during your build that is an SG isn't appropriate for?
separate console project that you msbuild Exec (how would ensure the project gets built first?)
MSBuild Task? (those looked awkward to have in the same project tho)
Quoted by
<@446416451230760990> from #roslyn (click here)
React with ❌ to remove this embed.
FWIW I generate a manifest of JS files for use with a webworker in one of my projects, and I do it with... just a normal method that uses
Directory
and File
classes to do that lmao
Then I just call await JsManifest.Generate()
on startup and call it a dayIs it possible to output a .json file from a source generator or does it only work with c# files?Only C# files
C# file with a raw string literal json seems like a workaround