Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequireNamedArgumentsAnalyzer: add support for exemptions #961

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

omsmith
Copy link
Contributor

@omsmith omsmith commented Aug 10, 2024

ExemptSymbolsBuilder is a helper for building sets of exempt symbols without bespoke logic per-analyzer.

The AdditionalFile format is similar to Roslyn's BannedApiAnalyzer: https://github.com/dotnet/roslyn-analyzers/blob/3211f48253bc18560156d90dc5e710d35f7d03fa/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/BannedApiAnalyzers.Help.md

In this case the optional [;Description Text] is excluded from the format, as exemptions do not lead to user-facing messages.

Comments are supported for developers to leave notes justifying the exemption.

ExemptSymbolsBuilder is a helper for building sets of exempt symbols
without bespoke logic per-analyzer.

The AdditionalFile format is similar to Roslyn's BannedApiAnalyzer:
https://github.com/dotnet/roslyn-analyzers/blob/3211f48253bc18560156d90dc5e710d35f7d03fa/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/BannedApiAnalyzers.Help.md

In this case the optional [;Description Text] is excluded from the
format, as exemptions do not lead to user-facing messages.

Comments are supported for developers to leave notes justifying the exemption.
@omsmith omsmith requested a review from j3parker as a code owner August 10, 2024 17:25
m_cancellationToken = context.CancellationToken;
}

public ImmutableHashSet<ISymbol> Build() => m_exemptions.ToImmutable();
Copy link
Member

@j3parker j3parker Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IReadOnlySet<T>/HashSet<T> has better performance

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ImmutableHashSet<T> uses an implementation that makes functional edits cheaper, at the cost of making lookups slower.)

j3parker
j3parker previously approved these changes Aug 12, 2024
@omsmith omsmith merged commit 385f34a into main Aug 12, 2024
1 check passed
@omsmith omsmith deleted the omsmith/required-args-exempt branch August 12, 2024 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants