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
I have an incremental source generator that is designed to operate on types annotated with a specific attribute, and is supposed to pull metadata out of a binary file packed as an embedded resource in order to generate code according to said metadata. The metadata itself actually comes from another project and will probably be pulled before build by a CI script.
A workaround would be to embed these files in a dll that is passed as MetadataReference (with no APIs) to the compiler. Since there is nothing the code can use from this reference the compiler won’t emit any AssemblyRefs. But the analyzer can find it in the compilation and extract the resources.
However my understanding of this solution is that the metadata reference would be attached to the source generator itself, which is not ideal in my use case. Trying to use MetadataReferencesProvider has not yielded significant results for me as I've been stuck trying to retrieve the actual binary data so that it can be parsed during build. My current (incomplete solution) goes as follow:
What am I missing? Do I have to walk through the Implementation handles until I get to a blob and can call GetBlobReader ?
Additional files do not have this problem because they expose the file contents as strings, however this data is very not-utf8 (or any encoding, for that matter) friendly (on top of being possibly quite large)
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have an incremental source generator that is designed to operate on types annotated with a specific attribute, and is supposed to pull metadata out of a binary file packed as an embedded resource in order to generate code according to said metadata. The metadata itself actually comes from another project and will probably be pulled before build by a CI script.
I'm aware of #49855 where it was hinted that
However my understanding of this solution is that the metadata reference would be attached to the source generator itself, which is not ideal in my use case. Trying to use
MetadataReferencesProviderhas not yielded significant results for me as I've been stuck trying to retrieve the actual binary data so that it can be parsed during build. My current (incomplete solution) goes as follow:What am I missing? Do I have to walk through the
Implementationhandles until I get to a blob and can callGetBlobReader?Additional files do not have this problem because they expose the file contents as strings, however this data is very not-utf8 (or any encoding, for that matter) friendly (on top of being possibly quite large)
Beta Was this translation helpful? Give feedback.
All reactions