You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In today's C#, metaprogramming using Source Generators is widely utilized.
There are various use cases for Source Generators, including those intended for broad use as a library by end users, as well as those meant to be used solely within specific projects.
Currently, even for the latter use case, Roslyn requires the creation of a dedicated project for the generator and appropriate configuration on the project side utilizing it.
To alleviate this complexity, could we not allow for the unified management of generator source code within a single project?
Differentiate between build asset source code (.cs) and generator source code (e.g. .csgen) using file extensions.
Apply different target frameworks to build assets and generators.
Generators created from *.csgen are only effective within the same project's *.cs or files specified as AdditionalFiles.
Generator binaries are updated after the build. They remain effective in *.cs files until the next rebuild of *.csgen.
It might be more convenient if nameof expressions in *.csgen could reference namespaces, types, and members defined in *.cs.
(I think these would be achieved by simply embedding them as string constants; it is probably not able to enable typeof.)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In today's C#, metaprogramming using Source Generators is widely utilized.
There are various use cases for Source Generators, including those intended for broad use as a library by end users, as well as those meant to be used solely within specific projects.
Currently, even for the latter use case, Roslyn requires the creation of a dedicated project for the generator and appropriate configuration on the project side utilizing it.
To alleviate this complexity, could we not allow for the unified management of generator source code within a single project?
Differentiate between build asset source code (
.cs
) and generator source code (e.g..csgen
) using file extensions.Apply different target frameworks to build assets and generators.
Generators created from
*.csgen
are only effective within the same project's*.cs
or files specified asAdditionalFiles
.Generator binaries are updated after the build. They remain effective in
*.cs
files until the next rebuild of*.csgen
.It might be more convenient if
nameof
expressions in*.csgen
could reference namespaces, types, and members defined in*.cs
.(I think these would be achieved by simply embedding them as string constants; it is probably not able to enable
typeof
.)Thank you.
Beta Was this translation helpful? Give feedback.
All reactions