-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source Generators: Allow embedding of files other than source #49935
Comments
Could I ask to add a possibility to include a non-compilable additional files? I need to send some metadata from SG to my VSIX (and update custom codelenses with that metadata), so I need to access that metadata (for example XML file) in |
This would be great. Source generators should be able to add other types of files to the output. One example would be Swagger that could generate the OpenAPI file at compile time and add the resulting .json to the compile output. Unless there is another way that could be done? |
Would be very useful! |
Any updates on this? |
Concrete use-case from my company: |
Our use case: |
I think this is a great idea! Generating C# source code is fantastic, but being able to generate other file types, such as I understand that As well as that, we could perhaps give flags to Personally, if I can use generators to create Thanks, and much respect to the dev team (who I imagine are already considering such ideas)! 😄 P.S. As a fellow developer, I understand that requests and ideas are often far beyond the current concerns and/or reach of development goals. I'm just here as a voice in favour of supporting generating different file types because it's incredibly useful and... it's awesome! |
I'd love to see this available from source generators. Two use cases come to mind:
Both of these are possible through secondary build actions which analyze the produced dll, but source generators are much easier. |
this feature would help me as well. I'm using source generators to generate a virtual lookup table, but I would also love to generate some static resource file about that metadata that downstream consumers could read without having to load up the |
Also chiming in that this would be very useful. My use case: I am using Incremental Source Generators to generate bindings to an embedded Lua scripting engine, and I would also like to be able to generate API documentation files that I can later ingest into Sphinx or similar to generate API docs for my generated bindings. |
As other have pointed out, there is a major use case for generating bindings to non-C# code. After doing all the work to serialize the game objects with a source generator, we realized it would be a huge improvement to use that same code to generate the C++ bindings to the game client. We made this work but it's explicitly not an official use case. It would also be great if this could be triggered as a build step and avoid it constantly running via IntelliSense. |
My use case - I want to rewrite this nuget package. It converts Due to the fast changing nature of multi-targeting builds and Dotnet evolution, keeping this package working cross platform has been a trial. It's also not very VS friendly, as Intellisense doesn't recognize the generated wrapper classes. |
We've seen from several customers the want to embed other files into the output assembly, particularly EmbeddedResources (see #49923)
We should explore an API that allows generators to add 'other' inputs to the compilation other than just source. This could be scoped explicitly to EmbeddedResources, or we might want to allow e.g. AdditionalFiles too.
Expanding it out to more types might have implications for analyzers, as they would be able to see them as well, but given that analyzers today see the generated source this seems desirable (although we might need an API that returns the provenance of the thing, such as Generated or Not).
The text was updated successfully, but these errors were encountered: