Skip to content

Conversation

@kzu
Copy link
Member

@kzu kzu commented Mar 20, 2023

Since analyzers are transitive by default (unless PrivateAssets=all in the PackageReference), we could have been inadvertently generating ThisAssembly classes via project-to-project (P2P) references and causing potential type name conflicts (if InternalsVisibleTo is also in use).

This can happen if you add a package reference manually and forget to set PrivateAssets=all. But ThisAssembly is always intended to be private assets.

After some testing, it turns out that even if we set the PrivateAssets=all via targets provided by the package itself, we can prevent this abnormal (but perhaps easy to encounter?) situation from happening at all.

This is particularly necessary with the introduction of the SponsorLink checks, since those are analyzers too, and require compiler-visible properties to be surfaced.

By forcing PrivateAssets, we make sure SponsorLink analyzer never runs on P2P projects and only on the directly referencing one.

@kzu kzu added the enhancement New feature or request label Mar 20, 2023
Since analyzers are transitive by default (unless PrivateAssets=all in the PackageReference), we could have been inadvertently generating ThisAssembly classes via project-to-project (P2P) references and causing potential type name conflicts (if InternalsVisibleTo is also in use).

This can happen if you add a package reference manually and forget to set PrivateAssets=all. But ThisAssembly is *always* intended to be private assets.

After some testing, it turns out that even if we set the PrivateAssets=all via targets provided by the package itself, we can prevent this abnormal (but perhaps easy to encounter?) situation from happening at all.

This is particularly necessary with the introduction of the SponsorLink checks, since those are analyzers too, and require compiler-visible properties to be surfaced.

By forcing PrivateAssets, we make sure SponsorLink analyzer never runs on P2P projects and only on the directly referencing one.
@kzu kzu force-pushed the dev/AlwaysPrivate branch from 00b4102 to 876c485 Compare March 20, 2023 20:45
@kzu kzu enabled auto-merge (rebase) March 20, 2023 20:49
@kzu kzu merged commit d139b44 into main Mar 20, 2023
@kzu kzu deleted the dev/AlwaysPrivate branch March 20, 2023 20:51
@devlooped devlooped locked and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants