Skip to content

Commit d7090c1

Browse files
committed
Allow disabling Info diagnostics globally
If you declare via a property you already know you're a SL hero, we have no need to remind you :). ```xml <SponsorLinkHero>true</SponsorLinkHero> ``` This will disable the info diagnostics and decrease the noise for sponsors after synchronizing their manifests.
1 parent 058dbbc commit d7090c1

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

samples/dotnet/SponsorLink/SponsorLinkAnalyzer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public override void Initialize(AnalysisContext context)
4343
// multiple diagnostics for each project in a solution that uses the same product.
4444
ctx.RegisterCompilationEndAction(ctx =>
4545
{
46+
// We'd never report Info/hero link if users opted out of it.
47+
if (status == SponsorStatus.Sponsor &&
48+
ctx.Options.AnalyzerConfigOptionsProvider.GlobalOptions.TryGetValue("build_property.SponsorLinkHero", out var slHero) &&
49+
bool.TryParse(slHero, out var isHero) && isHero)
50+
return;
51+
4652
// Only report if the package is directly referenced in the project for
4753
// any of the funding packages we monitor (i.e. we could have one or more
4854
// metapackages we also consider "direct references).

samples/dotnet/SponsorLink/buildTransitive/Devlooped.Sponsors.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
<!-- To quickly exit if true -->
2828
<CompilerVisibleProperty Include="DesignTimeBuild" />
29+
30+
<!-- If the user declares himself already as a hero, we don't need to remind him via Info diagnostics -->
31+
<CompilerVisibleProperty Include="SponsorLinkHero" />
2932
</ItemGroup>
3033

3134
<PropertyGroup>

0 commit comments

Comments
 (0)