From d7090c1dbcb20c68b99486a6dc53d86b8d9b06bb Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Tue, 23 Jul 2024 23:25:06 -0300 Subject: [PATCH] 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 true ``` This will disable the info diagnostics and decrease the noise for sponsors after synchronizing their manifests. --- samples/dotnet/SponsorLink/SponsorLinkAnalyzer.cs | 6 ++++++ .../SponsorLink/buildTransitive/Devlooped.Sponsors.targets | 3 +++ 2 files changed, 9 insertions(+) diff --git a/samples/dotnet/SponsorLink/SponsorLinkAnalyzer.cs b/samples/dotnet/SponsorLink/SponsorLinkAnalyzer.cs index 3a6dd749..3f7decda 100644 --- a/samples/dotnet/SponsorLink/SponsorLinkAnalyzer.cs +++ b/samples/dotnet/SponsorLink/SponsorLinkAnalyzer.cs @@ -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). diff --git a/samples/dotnet/SponsorLink/buildTransitive/Devlooped.Sponsors.targets b/samples/dotnet/SponsorLink/buildTransitive/Devlooped.Sponsors.targets index 4ede04d1..0bc5a45e 100644 --- a/samples/dotnet/SponsorLink/buildTransitive/Devlooped.Sponsors.targets +++ b/samples/dotnet/SponsorLink/buildTransitive/Devlooped.Sponsors.targets @@ -26,6 +26,9 @@ + + +