admin管理员组文章数量:1124655
I have a source generator which completes an implementation of a library, this means there is a source generator assembly and a library assembly. In order for the source generator to create the correct implementation it needs to know the name of a few types in the library, these just have to be the name (but generic type information would be a bonus).
The problem is the library runtime is 8.0
and the source generator has to be net standard 2.0
which means I can't have a normal dependency to the library from the source generator.
Is there a way to include type details from a non-net standard 2.0
compliant codebase in a source generator?
What I've tried:
- Including loose C# files as needed: Core interfaces make use of non-
standard 2.0
features so don't compile#define NETSTANDARD2_0
to exclude features, while this would work it requires a large amount of defines to block out features and methods. It's possible some of them need to be known about by the source generator
- Shared projects: Don't allow for types that use higher level features like static abstract interface methods, works for simpler libraries
- Reference Assemblies: Don't produce runtime agnostic output assemblies, the library must compile with
standard 2.0
even if only using it usingnameof()
to fill in type names
Current Solution
I have a single file with a lot of const string
instances which have the names of types and namespaces. If the types move or are renamed the source generator either can't find the members to link against or produces invalid code which points at old types (or old type locations)
本文标签: cGet type names for nameof() from another assembly without runtime restrictionsStack Overflow
版权声明:本文标题:c# - Get type names for nameof() from another assembly without runtime restrictions - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736645839a1946099.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论