Closed zitmen closed 2 years ago
Hi @beakona, thanks for accepting the PR. When can I look forward to a new nuget? :)
Hi @zitmen, I've made v1.0.21-preview yesterday.
Here is sequence of events that led me to preview
and not actual release, for now.
I have:
Then I tried to use new source generator in real project and got error that compiler sees *Attributes twice:
I decided to make preview
in order not to break existing projects 'without developer doing nothing'. This kind of reasoning may be incorrect??
Also, there is breaking change. Now you can't use reflection to find which members are autogenerated because *Attributes are erased (because of conditional
)
Then I tried to use new source generator in real project and got error that compiler sees *Attributes twice
This happened to me too, but it is a Visual Studio problem. When you close the VS and then start it again, it works fine. There is no issue because the autogenerated attribute is no longer there unless you are referencing 2 versions of the nuget, which you should not do anyway.
I am ok with preview, I just need to reference something :)
Also, there is breaking change. Now you can't use reflection ...
Interesting, I would not think of such use case. Not sure what it is good for..? But if someone relies on that, then how about introducing a conditional compilation so I can opt in into the attribute removal? Because I am excluding the dlls from runtime as there is no need for it and neither for the attribute (at least in all my use cases). Alternatively there could be a different attribute, but that's probably confusing.
Thanks, Martin
Hi, it is a nice project you have here. I would like to use it but there are some issues when referenced in a bigger project.
1) The output binaries contain the attribute despite the fact this is a Roslyn component 2) When the nuget is referenced from multiple projects, I get
CS0436
: Type conflicts with the imported typeThis PR fixed both issues.
The first one simply by using
System.Diagnostics.ConditionalAttribute
The second by extracting the attribute to a separate dll, which is automagically referenced by the projects as an extra dependency and thus it is not needed to generate the attributes by the generator. Here is some reference for this problem and solution: https://andrewlock.net/creating-a-source-generator-part-7-solving-the-source-generator-marker-attribute-problem-part1/ There is potentially also this package:
Code.Generation.Roslyn.Attributes
, which is neat, but I assumed you don't want to introduce another dependency, especially when it has a different license.