From d139b4480bf36c418506b6995d315c7929ef4674 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Mon, 20 Mar 2023 17:33:21 -0300 Subject: [PATCH] Bump to latest SponsorLink and ensure private assets always 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. --- .../ThisAssembly.AssemblyInfo.csproj | 4 ++-- .../ThisAssembly.AssemblyInfo.targets | 9 +++++++++ src/ThisAssembly.Constants/ThisAssembly.Constants.csproj | 4 ++-- .../ThisAssembly.Constants.targets | 4 ++++ src/ThisAssembly.Git/ThisAssembly.Git.csproj | 4 ++-- src/ThisAssembly.Git/ThisAssembly.Git.targets | 6 ++++++ src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj | 8 ++++++-- src/ThisAssembly.Metadata/ThisAssembly.Metadata.targets | 9 +++++++++ .../ThisAssembly.Prerequisites.csproj | 2 +- src/ThisAssembly.Project/ThisAssembly.Project.csproj | 4 ++-- src/ThisAssembly.Project/ThisAssembly.Project.targets | 8 +++++++- src/ThisAssembly.Resources/ThisAssembly.Resources.csproj | 4 ++-- .../ThisAssembly.Resources.targets | 6 ++++++ src/ThisAssembly.Strings/ThisAssembly.Strings.csproj | 4 ++-- src/ThisAssembly.Strings/ThisAssembly.Strings.targets | 6 ++++++ src/ThisAssembly.Tests/ThisAssembly.Tests.csproj | 3 ++- src/ThisAssembly/ThisAssembly.csproj | 2 +- 17 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.targets create mode 100644 src/ThisAssembly.Metadata/ThisAssembly.Metadata.targets diff --git a/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.csproj b/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.csproj index 3be05d31..018d7cff 100644 --- a/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.csproj +++ b/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.csproj @@ -27,8 +27,8 @@ on the `ThisAssembly.Info` class. - - + + diff --git a/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.targets b/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.targets new file mode 100644 index 00000000..a71f2e72 --- /dev/null +++ b/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.targets @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/src/ThisAssembly.Constants/ThisAssembly.Constants.csproj b/src/ThisAssembly.Constants/ThisAssembly.Constants.csproj index f6093958..e6b371bd 100644 --- a/src/ThisAssembly.Constants/ThisAssembly.Constants.csproj +++ b/src/ThisAssembly.Constants/ThisAssembly.Constants.csproj @@ -47,8 +47,8 @@ C#: - - + + diff --git a/src/ThisAssembly.Constants/ThisAssembly.Constants.targets b/src/ThisAssembly.Constants/ThisAssembly.Constants.targets index 27c295db..955dcbcb 100644 --- a/src/ThisAssembly.Constants/ThisAssembly.Constants.targets +++ b/src/ThisAssembly.Constants/ThisAssembly.Constants.targets @@ -5,6 +5,10 @@ + + + diff --git a/src/ThisAssembly.Git/ThisAssembly.Git.csproj b/src/ThisAssembly.Git/ThisAssembly.Git.csproj index 30f737ba..717f8e67 100644 --- a/src/ThisAssembly.Git/ThisAssembly.Git.csproj +++ b/src/ThisAssembly.Git/ThisAssembly.Git.csproj @@ -29,8 +29,8 @@ - - + + diff --git a/src/ThisAssembly.Git/ThisAssembly.Git.targets b/src/ThisAssembly.Git/ThisAssembly.Git.targets index a3da21bd..677e7a90 100644 --- a/src/ThisAssembly.Git/ThisAssembly.Git.targets +++ b/src/ThisAssembly.Git/ThisAssembly.Git.targets @@ -1,5 +1,11 @@ + + + + + pr$(GITHUB_REF.Replace('refs/pull/', '').Replace('/merge', '')) diff --git a/src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj b/src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj index 62af3bed..bb34bb79 100644 --- a/src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj +++ b/src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj @@ -39,8 +39,12 @@ C#: - - + + + + + + diff --git a/src/ThisAssembly.Metadata/ThisAssembly.Metadata.targets b/src/ThisAssembly.Metadata/ThisAssembly.Metadata.targets new file mode 100644 index 00000000..fcf9fbea --- /dev/null +++ b/src/ThisAssembly.Metadata/ThisAssembly.Metadata.targets @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/src/ThisAssembly.Prerequisites/ThisAssembly.Prerequisites.csproj b/src/ThisAssembly.Prerequisites/ThisAssembly.Prerequisites.csproj index e77ac8f9..1a140140 100644 --- a/src/ThisAssembly.Prerequisites/ThisAssembly.Prerequisites.csproj +++ b/src/ThisAssembly.Prerequisites/ThisAssembly.Prerequisites.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/ThisAssembly.Project/ThisAssembly.Project.csproj b/src/ThisAssembly.Project/ThisAssembly.Project.csproj index 56ad11d1..437619bb 100644 --- a/src/ThisAssembly.Project/ThisAssembly.Project.csproj +++ b/src/ThisAssembly.Project/ThisAssembly.Project.csproj @@ -38,8 +38,8 @@ C#: - - + + diff --git a/src/ThisAssembly.Project/ThisAssembly.Project.targets b/src/ThisAssembly.Project/ThisAssembly.Project.targets index afda26a6..ea707c36 100644 --- a/src/ThisAssembly.Project/ThisAssembly.Project.targets +++ b/src/ThisAssembly.Project/ThisAssembly.Project.targets @@ -1,5 +1,11 @@ + + + + + InitializeSourceControlInformation @@ -15,7 +21,7 @@ @(ProjectPropertyDistinct, '|') - + diff --git a/src/ThisAssembly.Resources/ThisAssembly.Resources.csproj b/src/ThisAssembly.Resources/ThisAssembly.Resources.csproj index 71cbaa79..06472016 100644 --- a/src/ThisAssembly.Resources/ThisAssembly.Resources.csproj +++ b/src/ThisAssembly.Resources/ThisAssembly.Resources.csproj @@ -23,8 +23,8 @@ - - + + diff --git a/src/ThisAssembly.Resources/ThisAssembly.Resources.targets b/src/ThisAssembly.Resources/ThisAssembly.Resources.targets index 5823e988..04951d66 100644 --- a/src/ThisAssembly.Resources/ThisAssembly.Resources.targets +++ b/src/ThisAssembly.Resources/ThisAssembly.Resources.targets @@ -1,5 +1,11 @@ + + + + + diff --git a/src/ThisAssembly.Strings/ThisAssembly.Strings.csproj b/src/ThisAssembly.Strings/ThisAssembly.Strings.csproj index e5b51d47..c7a40b9a 100644 --- a/src/ThisAssembly.Strings/ThisAssembly.Strings.csproj +++ b/src/ThisAssembly.Strings/ThisAssembly.Strings.csproj @@ -24,8 +24,8 @@ such as "Hello {name}". - - + + diff --git a/src/ThisAssembly.Strings/ThisAssembly.Strings.targets b/src/ThisAssembly.Strings/ThisAssembly.Strings.targets index cbbad226..764e8327 100644 --- a/src/ThisAssembly.Strings/ThisAssembly.Strings.targets +++ b/src/ThisAssembly.Strings/ThisAssembly.Strings.targets @@ -1,5 +1,11 @@ + + + + + diff --git a/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj b/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj index 30b41336..53766eb2 100644 --- a/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj +++ b/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj @@ -31,7 +31,8 @@ - + + diff --git a/src/ThisAssembly/ThisAssembly.csproj b/src/ThisAssembly/ThisAssembly.csproj index 76090500..055c1c22 100644 --- a/src/ThisAssembly/ThisAssembly.csproj +++ b/src/ThisAssembly/ThisAssembly.csproj @@ -12,7 +12,7 @@ - +