tunnelvisionlabs / ReferenceAssemblyAnnotator

IL weaver to add nullability annotations to .NET reference assemblies
MIT License
71 stars 8 forks source link

Duplicate definition warnings for nullability attributes #32

Closed jnm2 closed 5 years ago

jnm2 commented 5 years ago

The error list has one warning per usage of one of the nullability attributes in my own code:

CS0436 The type 'AllowNullAttribute' in '.nuget\packages\tunnelvisionlabs.referenceassemblyannotator\1.0.0-alpha.69\build\NullableAttributes.cs' conflicts with the imported type 'AllowNullAttribute' in \. Using the type defined in '.nuget\packages\tunnelvisionlabs.referenceassemblyannotator\1.0.0-alpha.69\build\NullableAttributes.cs'.

This is after git clean -fxd with VS closed and then building the solution once or a few times.

This is an SDK-style project that does not define any attributes except by referencing this package.

sharwell commented 5 years ago

Either you have a reference to a project that provides the attributes, or you define the attributes in source with your project, or one of your projects has InternalsVisibleTo access to another project. You should set GenerateNullableAttributes to false in your project file for all projects that have access to the attributes from another imported project or reference.

jnm2 commented 5 years ago

Aha, InternalsVisibleTo didn't occur to me. That was it, thanks!