Skip to content

Commit

Permalink
Fix scenario where multiple packages share product name
Browse files Browse the repository at this point in the history
i.e. ThisAssembly. We want to report only once for all the packages, so it's expected to not find
  • Loading branch information
kzu committed Jun 18, 2024
1 parent 93df7c7 commit 23f83bd
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/SponsorLink/SponsorLink/SponsorLinkAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,13 @@ public override void Initialize(AnalysisContext context)
// NOTE: even if we don't report the diagnostic, we still set the status so other analyzers can use it.
ctx.RegisterCompilationEndAction(ctx =>
{
// NOTE: for multiple projects with the same product name, we only report one diagnostic,
// so it's expected to NOT get a diagnostic back. Also, we don't want to report
// multiple diagnostics for each project in a solution that uses the same product.
if (Diagnostics.Pop(Funding.Product) is Diagnostic diagnostic)
{
ctx.ReportDiagnostic(diagnostic);
}
else
{
// This should never happen and would be a bug.
Debug.Assert(true, "We should have provided a diagnostic of some kind for " + Funding.Product);
// We'll report it as unknown as a fallback for now.
ctx.ReportDiagnostic(Diagnostic.Create(descriptors[SponsorStatus.Unknown], null,
properties: ImmutableDictionary.Create<string, string?>().Add(nameof(SponsorStatus), nameof(SponsorStatus.Unknown)),
Funding.Product, Sponsorables.Keys.Humanize(Resources.Or)));
}
});
}
});
Expand Down

0 comments on commit 23f83bd

Please sign in to comment.