-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Non Semantic Source Generation #54723
Comments
Small thing to consider about naming the enum. Should it be plural (ie, |
How does this interact with diagnostics produced by a source generator? Would the diagnostics only show up at build time, not at design time? Additionally, would this be usable by generators that generate code to provide implementations of partial methods without showing errors for missing partial method implementations, or is it just for cases where the generated code is called through clever implementation tricks like "implicit" default constructors or method overloading? |
I am also particularly curious about this. In my use case scenario (detailed in #51497), I need to generate some methods for an interface that is added to partial user-defined types. I could just generate those methods as empty to make IntelliSense happy when the generator is running in the IDE, and save a ton of work, and then actually populate them properly during the full compile. I'd be interested to know if such a scenario would be supported by this proposed feature as well 😄 |
I'm guessing:
|
Currently this only supports the 'clever tricks' scenario. However the 'ReferenceOnlySource' would allow to do a decl/implementation split. In terms of diagnostics, yes these would only be produced as part of a 'full build', not during typing in the IDE, as presumably you'd need to do the actual generation in order to create the diagnostics. When thats not the case, you can pass the same node to |
NotesNew EnumConsensus was enum as-is is fine. NamingCould we rename somehow? Reference onlyThere is a desire to ship the |
Closed via #54798 |
Background and Motivation
Today source generators can only provide a single type of Source. This is always run in the IDE and compiler. However there are customers (such as the Orleans team) who produce source that is semantically 'invisible'; that is the added code has a runtime effect, but adds no user visible types in completion or intellisense etc.
This means that in IDE scenarios, we are doing a lot of unnecessary work, when the author could inform us to just skip it.
Proposed API
Usage Examples
Alternative Designs
New Enum
The above design re-uses the already existing
IncrementalGeneratorOutputKind
. However, there may be limited value in being able to disable PostInit and regular source. Should we create a new public enum that only lists certain types of ouputs that can be explicitly toggled?Enable instead of Disable
Should we make the output types explicitly opt-in? This would require the host to manually opt-in to new output types as they are added which seems unfortunate.
'Dummy' source or decl only
The above proposal only works when the source is entirely 'invisible'. Do we want to think about a mechanism where the generator can provide a reference source of e.g. just declarations for the IDE, and full source for the compiler? We could probably achieve that by adding another
RegisterReferenceSourceOutput
but it seems orthogonal enough that we could add it later alongside this proposal.Risks
The text was updated successfully, but these errors were encountered: