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

Add RSxxxx diagnostic for compilation end diagnostic descriptors without CompilationEnd custom tag #6397

Merged
merged 1 commit into from
Jan 4, 2023

Conversation

mavasani
Copy link
Contributor

@mavasani mavasani commented Jan 3, 2023

Closes #6282

@mavasani mavasani requested a review from a team as a code owner January 3, 2023 08:19
@mavasani
Copy link
Contributor Author

mavasani commented Jan 3, 2023

@Youssef1313 @Evangelink for review. Thanks!

@mavasani mavasani removed the Community label Jan 3, 2023
@codecov
Copy link

codecov bot commented Jan 3, 2023

Codecov Report

Merging #6397 (2a19c5b) into main (b7bb138) will increase coverage by 0.00%.
The diff coverage is 99.05%.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6397    +/-   ##
========================================
  Coverage   96.11%   96.11%            
========================================
  Files        1361     1361            
  Lines      316031   316545   +514     
  Branches    10195    10214    +19     
========================================
+ Hits       303738   304244   +506     
- Misses       9861     9863     +2     
- Partials     2432     2438     +6     

Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

Does this work for DiagnosticDescriptorHelper.Create we have in this repo?

Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

LGTM (given a quick look)

@mavasani
Copy link
Contributor Author

mavasani commented Jan 3, 2023

Does this work for DiagnosticDescriptorHelper.Create we have in this repo?

I think it should. Analyzing CustomTags argument is done by existing code in the analyzer. Even otherwise, I think we primarily care about analyzers outside this repo to benefit from this new warning.

Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

It looks like there is a violation in this repo?

context.RegisterCompilationEndAction(context => AnalyzeSymbol(context.ReportDiagnostic, context.Compilation.Assembly,
supportedAttriubte, unsupportedAttribute, knownPlatforms, context.CancellationToken));

internal static readonly DiagnosticDescriptor UnknownPlatform = DiagnosticDescriptorHelper.Create(RuleId,
s_localizableTitle,
CreateLocalizableResourceString(nameof(UseValidPlatformStringUnknownPlatform)),
DiagnosticCategory.Interoperability,
RuleLevel.BuildWarning,
description: s_localizableDescription,
isPortedFxCopRule: false,
isDataflowRule: false);
internal static readonly DiagnosticDescriptor InvalidVersion = DiagnosticDescriptorHelper.Create(RuleId,
s_localizableTitle,
CreateLocalizableResourceString(nameof(UseValidPlatformStringInvalidVersion)),
DiagnosticCategory.Interoperability,
RuleLevel.BuildWarning,
description: s_localizableDescription,
isPortedFxCopRule: false,
isDataflowRule: false);
internal static readonly DiagnosticDescriptor NoVersion = DiagnosticDescriptorHelper.Create(RuleId,
s_localizableTitle,
CreateLocalizableResourceString(nameof(UseValidPlatformStringNoVersion)),
DiagnosticCategory.Interoperability,
RuleLevel.BuildWarning,
description: s_localizableDescription,
isPortedFxCopRule: false,
isDataflowRule: false);

Though this one can't easily be caught as context.ReportDiagnostic isn't invoked, but rather captured as a method group and passed down few calls to report a diagnostic.

@mavasani
Copy link
Contributor Author

mavasani commented Jan 4, 2023

It looks like there is a violation in this repo?

context.RegisterCompilationEndAction(context => AnalyzeSymbol(context.ReportDiagnostic, context.Compilation.Assembly,
supportedAttriubte, unsupportedAttribute, knownPlatforms, context.CancellationToken));

internal static readonly DiagnosticDescriptor UnknownPlatform = DiagnosticDescriptorHelper.Create(RuleId,
s_localizableTitle,
CreateLocalizableResourceString(nameof(UseValidPlatformStringUnknownPlatform)),
DiagnosticCategory.Interoperability,
RuleLevel.BuildWarning,
description: s_localizableDescription,
isPortedFxCopRule: false,
isDataflowRule: false);
internal static readonly DiagnosticDescriptor InvalidVersion = DiagnosticDescriptorHelper.Create(RuleId,
s_localizableTitle,
CreateLocalizableResourceString(nameof(UseValidPlatformStringInvalidVersion)),
DiagnosticCategory.Interoperability,
RuleLevel.BuildWarning,
description: s_localizableDescription,
isPortedFxCopRule: false,
isDataflowRule: false);
internal static readonly DiagnosticDescriptor NoVersion = DiagnosticDescriptorHelper.Create(RuleId,
s_localizableTitle,
CreateLocalizableResourceString(nameof(UseValidPlatformStringNoVersion)),
DiagnosticCategory.Interoperability,
RuleLevel.BuildWarning,
description: s_localizableDescription,
isPortedFxCopRule: false,
isDataflowRule: false);

Though this one can't easily be caught as context.ReportDiagnostic isn't invoked, but rather captured as a method group and passed down few calls to report a diagnostic.

Thanks, I'll create a separate PR to fix this issue.

@mavasani mavasani merged commit 60f592c into dotnet:main Jan 4, 2023
@mavasani mavasani deleted the CompilationEndTagDiagnostic branch January 4, 2023 03:33
@github-actions github-actions bot added this to the vNext milestone Jan 4, 2023
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.

Add RSxxxx diagnostic for compilation end diagnostic descriptors without CompilationEnd custom tag
2 participants