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 @@ + + +