Skip to content

Commit 94dcc8b

Browse files
devlooped-botkzu
authored andcommitted
⬆️ Bump files with dotnet-file sync
# devlooped/oss - Remove shared community files from ignores devlooped/oss@65f89e0 - Don't attempt to push to nuget.org without a key devlooped/oss@d11c4dc - Push also to sleet if configured devlooped/oss@40ee833 # clarius/pages - Bump github-pages to fix build error clarius/pages@90fa16e # devlooped/SponsorLink - Don't attempt to sign ILRepack when SignAssembly=false devlooped/SponsorLink@330f826 - Rename analyzer targets to make scenario more explicit devlooped/SponsorLink@7407f5b - Use a stronger session ID for editors than the process ID devlooped/SponsorLink@dbf1cb0 - Ensure only direct dependencies are exposed as analyzer props devlooped/SponsorLink@5038d77 - Remove all cross-process deduping and simplify devlooped/SponsorLink@fb3353a
1 parent f849213 commit 94dcc8b

12 files changed

+106
-111
lines changed

.github/workflows/build.yml

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ on:
1515
branches: [ main, dev, 'dev/*', 'feature/*', 'rel/*' ]
1616
paths-ignore:
1717
- changelog.md
18-
- code-of-conduct.md
19-
- security.md
20-
- support.md
2118
- readme.md
2219
pull_request:
2320
types: [opened, synchronize, reopened]

.github/workflows/publish.yml

+11
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,15 @@ jobs:
4040
path: '*.binlog'
4141

4242
- name: 🚀 nuget
43+
env:
44+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
45+
if: env.NUGET_API_KEY != ''
4346
run: dotnet nuget push ./bin/**/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate
47+
48+
- name: 🚀 sleet
49+
env:
50+
SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }}
51+
if: env.SLEET_CONNECTION != ''
52+
run: |
53+
dotnet tool install -g --version 4.0.18 sleet
54+
sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found"

.netconfig

+25-25
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
sha = 49661dbf0720cde93eb5569be7523b5912351560
3131
[file ".github/workflows/build.yml"]
3232
url = https://github.com/devlooped/oss/blob/main/.github/workflows/build.yml
33-
etag = 7ab5fbbf1235cdb0c2216ef236c25f8c5ce0f28d372109817f1ae62cacc62ec1
33+
etag = 20ef46203325f5b3d06a991f8b38c24bcea49fd74d39062a62003448e2dd8b0a
3434
weak
35-
sha = fef463525739d0fb514dfb9e2bcbc2b1e5f81e38
35+
sha = 65f89e06ed7b2ac33ed3b729adc865b7076840d8
3636
[file ".gitignore"]
3737
url = https://github.com/devlooped/oss/blob/main/.gitignore
3838
etag = a9c37ae312afac14b78436a7d018af4483d88736b5f780576f2c5a0b3f14998c
@@ -86,9 +86,9 @@
8686
sha = 5fb172362c767bef7c36478f1a6bdc264723f8f9
8787
[file ".github/workflows/publish.yml"]
8888
url = https://github.com/devlooped/oss/blob/main/.github/workflows/publish.yml
89-
etag = 2bc45eaf0bb289ced535c2720975c573ff70841edf1181885e64614e2cafb89f
89+
etag = 105db682c332b2bb0873e60a7d2da45b00fe7d83da0f0e7dbf9a84bc5be77c25
9090
weak
91-
sha = 27a5c9a5f58f901056d4b048a79ba5843c6f6789
91+
sha = 40ee833a83d843c242914599e2635ca9a05aa837
9292
[file ".github/workflows/dotnet-file.yml"]
9393
url = https://github.com/devlooped/oss/blob/main/.github/workflows/dotnet-file.yml
9494
sha = 7afe350f7e80a230e922db026d4e1198ba15cae1
@@ -109,8 +109,8 @@
109109
weak
110110
[file "Gemfile"]
111111
url = https://github.com/clarius/pages/blob/main/Gemfile
112-
sha = 565a77f40db0863cb47ceb36f88790259a697c91
113-
etag = 24e482e91192e292b633e3c17c4f095286ffb5a041d299d761b2e6ef99ee7669
112+
sha = 90fa16ed0e7300a78a38ee1d23c34a7e875aab27
113+
etag = 3dd7febc8ae6760f19abfe787711f469c288cd803a6f1c545edec34264d48e71
114114
weak
115115
[file ".github/workflows/includes.yml"]
116116
url = https://github.com/devlooped/oss/blob/main/.github/workflows/includes.yml
@@ -136,8 +136,8 @@
136136
url = https://github.com/devlooped/SponsorLink/tree/main/samples/dotnet/
137137
[file "src/SponsorLink/Analyzer/Analyzer.csproj"]
138138
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/Analyzer/Analyzer.csproj
139-
sha = 200107908a6aafac1957ac905f47d144b5bf8939
140-
etag = c4832b00fdb1a6111d686c95badebb01ab5eb24ffb9ecbe45325c82f704ccf54
139+
sha = 7407f5b3461213ae764f53ee93651a34487e458c
140+
etag = 2842ea95c956faa47e997a7d20c39df2efc5b9c4f37fe1c2eeea297ee4ba9889
141141
weak
142142
[file "src/SponsorLink/Analyzer/Properties/launchSettings.json"]
143143
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/Analyzer/Properties/launchSettings.json
@@ -194,20 +194,15 @@
194194
sha = f47528874a6d9192b5546f84b455f5ccc474a707
195195
etag = 5be3b99c0049cbe98c305f5af2fd482a3a995960c3a1fc6dd2bffcbf3b7e4d52
196196
weak
197-
[file "src/SponsorLink/SponsorLink.targets"]
198-
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink.targets
199-
sha = 92f466a4cebb59798276a498321e941d98bf5066
200-
etag = ec09a25e0d1d8d5a0f74a80bd5fcb9a7ad61c0d6b52073f16f80f36ba44f472f
201-
weak
202197
[file "src/SponsorLink/SponsorLink/AppDomainDictionary.cs"]
203198
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/AppDomainDictionary.cs
204199
sha = f47528874a6d9192b5546f84b455f5ccc474a707
205200
etag = 4a70f86e73f951bca95618c221d821e38a31ef9092af4ac61447eab845671a28
206201
weak
207202
[file "src/SponsorLink/SponsorLink/DiagnosticsManager.cs"]
208203
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/DiagnosticsManager.cs
209-
sha = f47528874a6d9192b5546f84b455f5ccc474a707
210-
etag = 0f2bb6afa53513c0837dc7621fdf86f66cbd8b5eaa1978047dc50b96e3a87c99
204+
sha = fb3353af9d7085d73804d0f484507dc76f5b2608
205+
etag = 06a241de827a7e9fb78eb21ad68c26f307d3f916f7cbf98176b6dae053d976f6
211206
weak
212207
[file "src/SponsorLink/SponsorLink/ManifestStatus.cs"]
213208
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/ManifestStatus.cs
@@ -226,18 +221,18 @@
226221
weak
227222
[file "src/SponsorLink/SponsorLink/SponsorLink.cs"]
228223
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorLink.cs
229-
sha = f47528874a6d9192b5546f84b455f5ccc474a707
230-
etag = a5b16dc3c8022add752db5c3b0055fbfd7df9b14dad2ff1a6360a6ecafda1ce1
224+
sha = dbf1cb075923d964e797d047a793ca2152f9d040
225+
etag = 6a6b4579c0802f43f965e0f1f8661e0c5063a0170eaa7376dc57149f9251f8a4
231226
weak
232227
[file "src/SponsorLink/SponsorLink/SponsorLink.csproj"]
233228
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorLink.csproj
234-
sha = f47528874a6d9192b5546f84b455f5ccc474a707
235-
etag = dee8fab315723f4d82c5b0106f3f15ecc4d663fbba68e324289bdaada50c14e5
229+
sha = 7407f5b3461213ae764f53ee93651a34487e458c
230+
etag = 87d82d13a30e52098f032ede5108cc89c6873f12c6d748839b3b6c047b0b2fa4
236231
weak
237232
[file "src/SponsorLink/SponsorLink/SponsorLinkAnalyzer.cs"]
238233
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorLinkAnalyzer.cs
239-
sha = f47528874a6d9192b5546f84b455f5ccc474a707
240-
etag = 9c4604895aafcbc6bfe859f1b9fb0313a94e315b336556b0b78ea553d4eac1e1
234+
sha = fb3353af9d7085d73804d0f484507dc76f5b2608
235+
etag = 76f5ea97fa141c39fe681a526e6d72c8816605882ab9f23d524c7fbe2ae78c06
241236
weak
242237
[file "src/SponsorLink/SponsorLink/SponsorStatus.cs"]
243238
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorStatus.cs
@@ -256,8 +251,8 @@
256251
weak
257252
[file "src/SponsorLink/SponsorLink/buildTransitive/Devlooped.Sponsors.targets"]
258253
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/buildTransitive/Devlooped.Sponsors.targets
259-
sha = f47528874a6d9192b5546f84b455f5ccc474a707
260-
etag = 2d1bdeba897ce160ebb2988e75bf89ca9034699b736b1e24ed621a5e8d47e2d7
254+
sha = 5038d77597e956881dbb6e1d3f050f2c8dc21b4d
255+
etag = f4e566aa471141e5064276f8e3668466e8bf907c4db2fbc533bcef90744c8c46
261256
weak
262257
[file "src/SponsorLink/SponsorLink/sponsorable.md"]
263258
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/sponsorable.md
@@ -361,6 +356,11 @@
361356
weak
362357
[file "src/SponsorLink/readme.md"]
363358
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/readme.md
364-
sha = f47528874a6d9192b5546f84b455f5ccc474a707
365-
etag = 89f9984ca933c7647eff583e36374ba1c21c94342649d07cd369ef0ea4f056b9
359+
sha = 7407f5b3461213ae764f53ee93651a34487e458c
360+
etag = 50937c64732bb2b97ddc67cc7b7b2d091c51390c9f5f2b5fdcfe9f1becb5d838
361+
weak
362+
[file "src/SponsorLink/SponsorLink.Analyzer.targets"]
363+
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink.Analyzer.targets
364+
sha = 330f826844a5a8be0b1ed6d670e3de2804b595ae
365+
etag = 8fde8a0cd161428bec1aec37a592447fdc769ea6892cf75208ebfd847c3219d4
366366
weak

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
source 'https://rubygems.org'
22

3-
gem 'github-pages', '~> 209', group: :jekyll_plugins
3+
gem 'github-pages', '~> 231', group: :jekyll_plugins

src/SponsorLink/Analyzer/Analyzer.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PublishRepositoryUrl>true</PublishRepositoryUrl>
99
<MergeAnalyzerAssemblies>false</MergeAnalyzerAssemblies>
1010
<MergeAnalyzerAssemblies Condition="'$(CI)' == 'true'">true</MergeAnalyzerAssemblies>
11-
<CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink.targets</CustomAfterMicrosoftCSharpTargets>
11+
<CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink.Analyzer.targets</CustomAfterMicrosoftCSharpTargets>
1212
<ImplicitUsings>disable</ImplicitUsings>
1313
<FundingPackageId>SponsorableLib</FundingPackageId>
1414
</PropertyGroup>

src/SponsorLink/SponsorLink.targets src/SponsorLink/SponsorLink.Analyzer.targets

+10-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
<FundingPrefix Condition="'$(FundingPrefix)' == ''">$([System.Text.RegularExpressions.Regex]::Replace("$(FundingProduct)", "[^A-Z]", ""))</FundingPrefix>
2121
<!-- Default grace days for an expired sponsor manifest or unknown status -->
2222
<FundingGrace Condition="'$(FundingGrace)' == ''">15</FundingGrace>
23-
</PropertyGroup>
23+
24+
<!-- Strong-naming analyzers is both unnecessary and additionally unsupported by ILRepack when run as a dotnet tool -->
25+
<SignAssembly Condition="'$(MergeAnalyzerAssemblies)' == 'true'">false</SignAssembly>
26+
</PropertyGroup>
2427

2528
<ItemGroup>
2629
<Compile Include="$(MSBuildThisFileDirectory)SponsorLink/*.cs"
@@ -155,7 +158,7 @@ partial class SponsorLink
155158
<LibDir Include="@(ReferenceCopyLocalDirs -&gt; Distinct())" />
156159
</ItemGroup>
157160
<PropertyGroup>
158-
<AbsoluteAssemblyOriginatorKeyFile Condition="'$(AssemblyOriginatorKeyFile)' != ''">$([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine('$(MSBuildProjectDirectory)','$(AssemblyOriginatorKeyFile)'))))</AbsoluteAssemblyOriginatorKeyFile>
161+
<AbsoluteAssemblyOriginatorKeyFile Condition="'$(SignAssembly)' == 'true' and '$(AssemblyOriginatorKeyFile)' != ''">$([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine('$(MSBuildProjectDirectory)','$(AssemblyOriginatorKeyFile)'))))</AbsoluteAssemblyOriginatorKeyFile>
159162
<ILRepackArgs Condition="'$(AbsoluteAssemblyOriginatorKeyFile)' != ''">/keyfile:"$(AbsoluteAssemblyOriginatorKeyFile)" /delaysign</ILRepackArgs>
160163
<ILRepackArgs>$(ILRepackArgs) /internalize</ILRepackArgs>
161164
<ILRepackArgs>$(ILRepackArgs) /union</ILRepackArgs>
@@ -205,7 +208,10 @@ partial class SponsorLink
205208
<Target Name="PackCopyLocalLockFileAssemblies" Condition="'$(MergeAnalyzerAssemblies)' != 'true'"
206209
BeforeTargets="GetPackageContents" DependsOnTargets="ReferenceCopyLocalPathsOutputGroup">
207210
<ItemGroup>
208-
<PackageFile Include="@(ReferenceCopyLocalPathsOutputGroupOutput)" PackFolder="$(PackFolder)" />
211+
<PackageFile Include="@(ReferenceCopyLocalPathsOutputGroupOutput)" Condition="
212+
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CodeAnalysis', StringComparison.OrdinalIgnoreCase)) And
213+
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CSharp', StringComparison.OrdinalIgnoreCase))"
214+
PackFolder="$(PackFolder)" />
209215
</ItemGroup>
210216
</Target>
211217

@@ -214,4 +220,4 @@ partial class SponsorLink
214220
<SponsorLinkImported>true</SponsorLinkImported>
215221
</PropertyGroup>
216222

217-
</Project>
223+
</Project>

src/SponsorLink/SponsorLink/DiagnosticsManager.cs

+28-70
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
using System.Collections.Concurrent;
55
using System.Collections.Generic;
66
using System.Collections.Immutable;
7-
using System.Diagnostics;
87
using System.Globalization;
98
using System.IO;
10-
using System.IO.MemoryMappedFiles;
119
using System.Linq;
12-
using System.Runtime.InteropServices;
13-
using System.Threading;
1410
using Humanizer;
1511
using Humanizer.Localisation;
1612
using Microsoft.CodeAnalysis;
@@ -44,32 +40,6 @@ class DiagnosticsManager
4440
ConcurrentDictionary<string, Diagnostic> Diagnostics
4541
=> AppDomainDictionary.Get<ConcurrentDictionary<string, Diagnostic>>(appDomainDiagnosticsKey.ToString());
4642

47-
/// <summary>
48-
/// Attemps to remove a diagnostic for the given product.
49-
/// </summary>
50-
/// <param name="product">The product diagnostic that might have been pushed previously.</param>
51-
/// <returns>The removed diagnostic, or <see langword="null" /> if none was previously pushed.</returns>
52-
public void ReportOnce(Action<Diagnostic> report, string product = Funding.Product)
53-
{
54-
if (Diagnostics.TryRemove(product, out var diagnostic) &&
55-
GetStatus(diagnostic) != SponsorStatus.Grace)
56-
{
57-
// Ensure only one such diagnostic is reported per product for the entire process,
58-
// so that we can avoid polluting the error list with duplicates across multiple projects.
59-
var id = string.Concat(Process.GetCurrentProcess().Id, product, diagnostic.Id);
60-
using var mutex = new Mutex(false, "mutex" + id);
61-
mutex.WaitOne();
62-
using var mmf = CreateOrOpenMemoryMappedFile(id, 1);
63-
using var accessor = mmf.CreateViewAccessor();
64-
if (accessor.ReadByte(0) == 0)
65-
{
66-
accessor.Write(0, (byte)1);
67-
report(diagnostic);
68-
Tracing.Trace($"👈{diagnostic.Severity.ToString().ToLowerInvariant()}:{Process.GetCurrentProcess().Id}:{Process.GetCurrentProcess().ProcessName}:{product}:{diagnostic.Id}");
69-
}
70-
}
71-
}
72-
7343
/// <summary>
7444
/// Gets the status of the given product based on a previously stored diagnostic.
7545
/// To ensure the value is always set before returning, use <see cref="GetOrSetStatus"/>.
@@ -100,6 +70,34 @@ public SponsorStatus GetOrSetStatus(ImmutableArray<AdditionalText> manifests, An
10070
public SponsorStatus GetOrSetStatus(Func<AnalyzerOptions?> options)
10171
=> GetOrSetStatus(() => options().GetSponsorAdditionalFiles(), () => options()?.AnalyzerConfigOptionsProvider.GlobalOptions);
10272

73+
/// <summary>
74+
/// Attemps to remove a diagnostic for the given product.
75+
/// </summary>
76+
/// <param name="product">The product diagnostic that might have been pushed previously.</param>
77+
/// <returns>The removed diagnostic, or <see langword="null" /> if none was previously pushed.</returns>
78+
public Diagnostic? Pop(string product = Funding.Product)
79+
{
80+
if (Diagnostics.TryRemove(product, out var diagnostic) &&
81+
GetStatus(diagnostic) != SponsorStatus.Grace)
82+
{
83+
return diagnostic;
84+
}
85+
86+
return null;
87+
}
88+
89+
/// <summary>
90+
/// Pushes a diagnostic for the given product.
91+
/// </summary>
92+
/// <returns>The same diagnostic that was pushed, for chained invocations.</returns>
93+
Diagnostic Push(Diagnostic diagnostic, string product = Funding.Product)
94+
{
95+
// We only expect to get one warning per sponsorable+product
96+
// combination, and first one to set wins.
97+
Diagnostics.TryAdd(product, diagnostic);
98+
return diagnostic;
99+
}
100+
103101
SponsorStatus GetOrSetStatus(Func<ImmutableArray<AdditionalText>> getAdditionalFiles, Func<AnalyzerConfigOptions?> getGlobalOptions)
104102
{
105103
if (GetStatus() is { } status)
@@ -166,29 +164,6 @@ SponsorStatus GetOrSetStatus(Func<ImmutableArray<AdditionalText>> getAdditionalF
166164
}
167165
}
168166

169-
/// <summary>
170-
/// Pushes a diagnostic for the given product.
171-
/// </summary>
172-
/// <returns>The same diagnostic that was pushed, for chained invocations.</returns>
173-
Diagnostic Push(Diagnostic diagnostic, string product = Funding.Product)
174-
{
175-
// We only expect to get one warning per sponsorable+product
176-
// combination, and first one to set wins.
177-
if (Diagnostics.TryAdd(product, diagnostic))
178-
{
179-
// Reset the process-wide flag for this diagnostic.
180-
var id = string.Concat(Process.GetCurrentProcess().Id, product, diagnostic.Id);
181-
using var mutex = new Mutex(false, "mutex" + id);
182-
mutex.WaitOne();
183-
using var mmf = CreateOrOpenMemoryMappedFile(id, 1);
184-
using var accessor = mmf.CreateViewAccessor();
185-
accessor.Write(0, (byte)0);
186-
Tracing.Trace($"👉{diagnostic.Severity.ToString().ToLowerInvariant()}:{Process.GetCurrentProcess().Id}:{Process.GetCurrentProcess().ProcessName}:{product}:{diagnostic.Id}");
187-
}
188-
189-
return diagnostic;
190-
}
191-
192167
SponsorStatus? GetStatus(Diagnostic? diagnostic) => diagnostic?.Properties.TryGetValue(nameof(SponsorStatus), out var value) == true
193168
? value switch
194169
{
@@ -201,23 +176,6 @@ Diagnostic Push(Diagnostic diagnostic, string product = Funding.Product)
201176
}
202177
: null;
203178

204-
static MemoryMappedFile CreateOrOpenMemoryMappedFile(string mapName, int capacity)
205-
{
206-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
207-
{
208-
return MemoryMappedFile.CreateOrOpen(mapName, capacity);
209-
}
210-
else
211-
{
212-
// On Linux, use a file-based memory-mapped file
213-
string filePath = $"/tmp/{mapName}";
214-
using (var fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
215-
fs.Write(new byte[capacity], 0, capacity);
216-
217-
return MemoryMappedFile.CreateFromFile(filePath, FileMode.OpenOrCreate);
218-
}
219-
}
220-
221179
internal static DiagnosticDescriptor CreateSponsor(string[] sponsorable, string prefix) => new(
222180
$"{prefix}100",
223181
Resources.Sponsor_Title,

src/SponsorLink/SponsorLink/SponsorLink.cs

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Collections.Immutable;
6+
using System.Diagnostics;
67
using System.Diagnostics.CodeAnalysis;
78
using System.IO;
89
using System.Linq;
@@ -43,6 +44,14 @@ static partial class SponsorLink
4344
Environment.GetEnvironmentVariable("RESHARPER_FUS_SESSION") != null ||
4445
Environment.GetEnvironmentVariable("IDEA_INITIAL_DIRECTORY") != null;
4546

47+
/// <summary>
48+
/// A unique session ID associated with the current IDE or process running the analyzer.
49+
/// </summary>
50+
public static string SessionId =>
51+
IsVisualStudio ? Environment.GetEnvironmentVariable("ServiceHubLogSessionKey") :
52+
IsRider ? Environment.GetEnvironmentVariable("RESHARPER_FUS_SESSION") :
53+
Process.GetCurrentProcess().Id.ToString();
54+
4655
/// <summary>
4756
/// Manages the sharing and reporting of diagnostics across the source generator
4857
/// and the diagnostic analyzer, to avoid doing the online check more than once.

src/SponsorLink/SponsorLink/SponsorLink.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</ItemGroup>
3636

3737
<ItemGroup>
38-
<None Include="..\SponsorLink.targets" Link="SponsorLink.targets" />
38+
<None Include="..\SponsorLink.Analyzer.targets" Link="SponsorLink.Analyzer.targets" />
3939
</ItemGroup>
4040

4141
<Target Name="EmitFunding" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun" Inputs="$(MSBuildAllProjects)" Outputs="$(IntermediateOutputPath)SponsorLink.g.cs">

src/SponsorLink/SponsorLink/SponsorLinkAnalyzer.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ public override void Initialize(AnalysisContext context)
4141
// so it's expected to NOT get a diagnostic back. Also, we don't want to report
4242
// multiple diagnostics for each project in a solution that uses the same product.
4343
ctx.RegisterCompilationEndAction(ctx =>
44-
Diagnostics.ReportOnce(diagnostic => ctx.ReportDiagnostic(diagnostic)));
44+
{
45+
var prop = Funding.PackageId.Replace('.', '_');
46+
// Only report if the package is directly referenced in the project. See SL_CollectDependencies in buildTransitive\Devlooped.Sponsors.targets
47+
if (ctx.Options.AnalyzerConfigOptionsProvider.GlobalOptions.TryGetValue("build_property." + prop, out var package) &&
48+
package?.Length > 0 &&
49+
Diagnostics.Pop() is { } diagnostic)
50+
{
51+
ctx.ReportDiagnostic(diagnostic);
52+
}
53+
});
4554
}
4655
});
4756
#pragma warning restore RS1013 // Start action has no registered non-end actions

0 commit comments

Comments
 (0)