Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThisAssemblyNamespace is ignored when updating from 2.3.0 to 3.0.4 #258

Closed
codingdave opened this issue Feb 28, 2023 · 3 comments · Fixed by #266
Closed

ThisAssemblyNamespace is ignored when updating from 2.3.0 to 3.0.4 #258

codingdave opened this issue Feb 28, 2023 · 3 comments · Fixed by #266
Labels

Comments

@codingdave
Copy link
Contributor

codingdave commented Feb 28, 2023

Describe the Bug

error CS0436: The type 'ThisAssembly' in 'GitInfo.CodeAnalysis\GitInfoGenerator\ThisAssembly.Git.IsDirty.g.cs' conflicts with the imported type 'ThisAssembly' in 'myassembly, Culture=neutral, PublicKeyToken=...'. Using the type defined in 'GitInfo.CodeAnalysis\GitInfoGenerator\ThisAssembly.Git.IsDirty.g.cs'.

Steps to Reproduce

I updated my project from 2.3.0 to 3.0.4 and run into this issue. Using 3.0.0. results in

C:\Program Files\dotnet\sdk\7.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.GenerateAssemblyInfo.targets(209,5): error NETSDK1018: Invalid NuGet version string: '123.45.678+<$branchname>.<$commitid>'. 

Note: Branchname contains ´/´, and gitversion shows v123.45-678-g<$commitid> instead of 123.45.678.

Expected Behavior

Updating to 3.0.4 should not break a project that was working with 2.3.0.

Version Info

working version: 2.3.0
breaking versions: 3.0.4 (and 3.0.0)

Additional Info

I tried to create a minimal sample but wasnt able to reproduce the issue over there, though I tried to create the same setup is to my failing project.

So I hope you can give me some hints how to continue.

@codingdave codingdave added the bug label Feb 28, 2023
@rwg0
Copy link

rwg0 commented Mar 5, 2023

I think that 3.0.x is ignoring the ThisAssemblyNamespace property, which allowed you to set a distinct namespace for each project in previous versions. For instance a common solution was adding

<ThisAssemblyNamespace>$(RootNamespace)</ThisAssemblyNamespace>

to Directory.Build.targets.

Without that property, all ThisAssembly classes go into the global namespace. If you are also using the InternalsVisibleTo attribute, then you get collisions that break the build as you are seeing.

Until it is fixed, you will need to either remove the [InternalsVisibleTo] attribute, which will probably break stuff, since it will be there for a reason, or stick with 2.3.0

@codingdave
Copy link
Contributor Author

Good idea @rwg0

By adding [InternalsVisibleToAttribute] I still wasnt able to produce the error in my minimal sample but when I removed the attribute from my real project It successfully compiles with 3.0.4 as well.

@kzu
Copy link
Member

kzu commented Mar 7, 2023

Yes, this is a missing feature in 3.x. Pending implementation on ThisAssembly at devlooped/ThisAssembly#211

@kzu kzu changed the title Regression when updating from 2.3.0 to 3.0.4 ThisAssemblyNamespace is ignored when updating from 2.3.0 to 3.0.4 Mar 7, 2023
kzu added a commit that referenced this issue Mar 22, 2023
We were not properly conditioning the new ThisAssembly-based generation on the usage of a custom ThisAssemblyNamespace, causing P2P scenarios to fail since we were simultaneously generating in the custom namespace *and* the global one.

Fixes #258
@kzu kzu closed this as completed in #266 Mar 22, 2023
kzu added a commit that referenced this issue Mar 22, 2023
We were not properly conditioning the new ThisAssembly-based generation on the usage of a custom ThisAssemblyNamespace, causing P2P scenarios to fail since we were simultaneously generating in the custom namespace *and* the global one.

Fixes #258
@devlooped devlooped locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants