Closed PremekTill closed 2 weeks ago
There will be a release in the next couple of days that will resolve this, V2.0.x
Unfortunately, this particular issue got worse with 2.0.9. The original conflict is gone, but now I get a CS0122 "\<AttributeName> is inaccessible due to its protection level" error instead and cannot compile at all. It seems that the generator tries to pull in the attribute generated in ProjectA from ProjectB, instead of generating one reference for each project separately, thus breaking the internal modifier. Cleaning, rebuilding and manually deleting bin
and obj
folders didn't help.
I tried different settings for PrivateAssets and IncludeAssets in both csproj
files, but to no avail. Just for reference, these are my default settings:
<PackageReference Include="ReactiveUI.SourceGenerators" Version="2.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Thank you for your feedback, I am looking further into this and will come up with a resolve as soon as possible.
@PremekTill Could you try <PackageReference Include="ReactiveUI.SourceGenerators" Version="2.0.9" PrivateAssets="all" />
Unfortunately, it does not have any effect. Additionally, as I was changing the versions and parameters back and forth, the generator was getting more and more broken (at times refusing to generate anything at all without throwing any errors, even after dotnet clean and restore/rebuild).
However, switching over to Visual Studio and compiling the projects once with v2.0.9 seems to have fixed the issue completely – even going back to Rider, I can now switch between v1.1.31 and v2.0.9 freely.
I'm not sure what the root cause of the issue was, but it might have been an issue Rider-side, maybe having to do with some internal cache? I will try pulling the project on a clean machine and checking if it works there without the VS compilation – if it doesn't resurface, I think this issue can be closed for now, though I'd maybe leave it open for a couple of days while I try to repro in case someone else runs into it when upgrading from 1.1.31.
Sounds like maybe old nuget package cache.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Describe the bug 🐞
When creating two projects where Project B depends on Project A and both use ReactiveUI.SourceGenerators, when a class in Project B uses one of the source gen attributes (ReactiveAttribute, ReactiveCommandAttribute, ObservableAsPropertyAttribute et cetera) and at the same time references a class from Project A which uses the attribute as well, a build warning is generated.
The warning is CS0436, for example:
The type ReactiveAttribute in <PathProjectB>\obj\Debug\ReactiveUI.SourceGenerators\ReactiveUI.SourceGenerators.ReactiveGenerator\ReactiveUI.SourceGenerators.ReactiveAttribute.g.cs conflicts with the imported type ReactiveAttribute in <AssemblyProjectA>. Using the type defined in <PathProjectB>\<...ReactiveAttribute.g.cs>.
The compiled project runs as expected, however, the superfluous warnings clutter the Build output and cause problems in CI/CD pipelines.
Step to reproduce
Reproduction repository
No response
Expected behavior
There should be no warnings in the Build output.
Screenshots 🖼️
No response
IDE
Rider Windows
Operating system
Windows 10
Version
ReactiveUI.SourceGenerators 1.1.31
Device
No response
ReactiveUI Version
20.1.63
Additional information ℹ️
No response