Skip to content

Commit

Permalink
Allow disabling Info diagnostics globally
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kzu committed Jul 24, 2024
1 parent 058dbbc commit d7090c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions samples/dotnet/SponsorLink/SponsorLinkAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public override void Initialize(AnalysisContext context)
// multiple diagnostics for each project in a solution that uses the same product.
ctx.RegisterCompilationEndAction(ctx =>
{
// We'd never report Info/hero link if users opted out of it.
if (status == SponsorStatus.Sponsor &&
ctx.Options.AnalyzerConfigOptionsProvider.GlobalOptions.TryGetValue("build_property.SponsorLinkHero", out var slHero) &&
bool.TryParse(slHero, out var isHero) && isHero)
return;

// Only report if the package is directly referenced in the project for
// any of the funding packages we monitor (i.e. we could have one or more
// metapackages we also consider "direct references).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

<!-- To quickly exit if true -->
<CompilerVisibleProperty Include="DesignTimeBuild" />

<!-- If the user declares himself already as a hero, we don't need to remind him via Info diagnostics -->
<CompilerVisibleProperty Include="SponsorLinkHero" />
</ItemGroup>

<PropertyGroup>
Expand Down

0 comments on commit d7090c1

Please sign in to comment.