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

Guard the 'CustomSeverityConfigurable' tag with AnalysisLevel 9.0 #72238

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ SyntaxKind.RecordDeclaration or
Descriptor,
name.GetLocation(),
option.Notification,
context.Options,
additionalLocations: additionalLocations,
modifiersAdded ? ModifiersAddedProperties : null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void AnalyzeNode(SyntaxNodeAnalysisContext context)
Descriptor,
firstToken.GetLocation(),
option.Notification,
context.Options,
additionalLocations: null,
properties: null,
SyntaxFacts.GetText(firstToken.Kind())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private void AnalyzeNamespace(SyntaxNodeAnalysisContext context)
this.Descriptor,
diagnosticLocation,
option.Notification,
context.Options,
ImmutableArray.Create(declaration.GetLocation()),
ImmutableDictionary<string, string?>.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private void AnalyzeNamespace(SyntaxNodeAnalysisContext context)
this.Descriptor,
diagnosticLocation,
option.Notification,
context.Options,
ImmutableArray.Create(declaration.GetLocation()),
ImmutableDictionary<string, string?>.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private void ProcessCompilationUnit(SyntaxNodeAnalysisContext context)
GetUseProgramMainDiagnosticLocation(
root, isHidden: severity.WithDefaultSeverity(DiagnosticSeverity.Hidden) == ReportDiagnostic.Hidden),
option.Notification,
context.Options,
[],
ImmutableDictionary<string, string?>.Empty));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private void ProcessCompilationUnit(SyntaxNodeAnalysisContext context)
GetUseTopLevelStatementsDiagnosticLocation(
methodDeclaration, isHidden: option.Notification.Severity.WithDefaultSeverity(DiagnosticSeverity.Hidden) == ReportDiagnostic.Hidden),
option.Notification,
context.Options,
ImmutableArray.Create(methodDeclaration.GetLocation()),
ImmutableDictionary<string, string?>.Empty));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
// Report the diagnostic on the "switch" keyword.
location: switchStatement.GetFirstToken().GetLocation(),
notificationOption: styleOption.Notification,
context.Options,
additionalLocations: additionalLocations.ToArrayAndFree(),
properties: ImmutableDictionary<string, string?>.Empty
.Add(Constants.NodeToGenerateKey, ((int)nodeToGenerate).ToString(CultureInfo.InvariantCulture))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ private void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context, INamedTypeSymb
Descriptor,
reportNode.GetLocation(),
option.Notification,
context.Options,
additionalLocations: allLocations,
properties: null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ private void ReportDiagnostics(
Descriptor,
fadeLocation,
NotificationOption2.ForSeverity(Descriptor.DefaultSeverity),
syntaxContext.Options,
additionalLocations,
additionalUnnecessaryLocations: [fadeLocation],
properties));
Expand All @@ -193,6 +194,7 @@ private void ReportDiagnostics(
Descriptor,
expressionStatement.GetLocation(),
notificationOption,
syntaxContext.Options,
additionalLocations, properties));

// If the if-statement extends past the expression statement, then fade out the rest.
Expand All @@ -203,6 +205,7 @@ private void ReportDiagnostics(
Descriptor,
fadeLocation,
NotificationOption2.ForSeverity(Descriptor.DefaultSeverity),
syntaxContext.Options,
additionalLocations,
additionalUnnecessaryLocations: [fadeLocation],
properties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
Descriptor,
localFunction.Identifier.GetLocation(),
option.Notification,
context.Options,
additionalLocations: ImmutableArray.Create(localFunction.GetLocation()),
properties: null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ private void AnalyzeBlock(
Descriptor,
location,
notificationOption,
context.Options,
additionalLocations: ImmutableArray.Create(additionalLocation),
properties: null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected override void InitializeWorker(AnalysisContext context)
Descriptor,
location,
option.Notification,
context.Options,
additionalLocations: ImmutableArray.Create(additionalLocation),
properties: null));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private static void ReportDiagnostics(
descriptor,
usingDirective.GetLocation(),
option.Notification,
context.Options,
additionalLocations: null,
properties: null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private void ProcessArrowExpressionClause(
this.Descriptor,
arrowExpressionClause.ArrowToken.GetLocation(),
notificationOption,
context.Options,
additionalLocations: null,
properties: null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private void ProcessConditionalExpression(SyntaxNodeAnalysisContext context)
this.Descriptor,
conditionalExpression.QuestionToken.GetLocation(),
option.Notification,
context.Options,
additionalLocations: null,
properties: null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private void ProcessToken(SyntaxTreeAnalysisContext context, NotificationOption2
this.Descriptor,
secondBrace.GetLocation(),
notificationOption,
context.Options,
additionalLocations: null,
properties: null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ private void ProcessConstructorInitializer(
this.Descriptor,
colonToken.GetLocation(),
notificationOption,
context.Options,
additionalLocations: ImmutableArray.Create(initializer.GetLocation()),
properties: null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private bool CheckStatementSyntax(SyntaxTreeAnalysisContext context, Notificatio
this.Descriptor,
statement.GetFirstToken().GetLocation(),
notificationOption,
context.Options,
additionalLocations,
properties: null));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
Descriptor,
((PostfixUnaryExpressionSyntax)left).OperatorToken.GetLocation(),
NotificationOption2.Warning,
context.Options,
ImmutableArray.Create(node.GetLocation()),
properties: null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context, INamedTypeSymbol?
Descriptor,
syntaxTree.GetLocation(startReportSpan),
preference.Notification,
context.Options,
additionalLocations: [anonymousFunction.GetLocation()],
additionalUnnecessaryLocations: [syntaxTree.GetLocation(startReportSpan), syntaxTree.GetLocation(endReportSpan)]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ private void ProcessUnreachableDiagnostic(
Descriptor,
firstStatementLocation,
NotificationOption2.ForSeverity(Descriptor.DefaultSeverity),
context.Options,
additionalLocations: [],
additionalUnnecessaryLocations: additionalLocations));

Expand All @@ -142,6 +143,7 @@ private void ProcessUnreachableDiagnostic(
Descriptor,
location,
NotificationOption2.ForSeverity(Descriptor.DefaultSeverity),
context.Options,
additionalLocations,
additionalUnnecessaryLocations,
s_subsequentSectionProperties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private void AnalyzeSubpattern(SyntaxNodeAnalysisContext syntaxContext)
Descriptor,
expressionColon.GetLocation(),
styleOption.Notification,
syntaxContext.Options,
ImmutableArray.Create(subpattern.GetLocation()),
properties: null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private void AnalyzeArrayInitializerExpression(SyntaxNodeAnalysisContext context
Descriptor,
initializer.OpenBraceToken.GetLocation(),
option.Notification,
context.Options,
additionalLocations: ImmutableArray.Create(initializer.GetLocation()),
properties: changesSemantics ? ChangesSemantics : null));
}
Expand All @@ -205,6 +206,7 @@ private void ReportArrayCreationDiagnostics(
Descriptor,
expression.GetFirstToken().GetLocation(),
notification,
context.Options,
additionalLocations: locations,
properties: properties));

Expand All @@ -219,6 +221,7 @@ expression is ArrayCreationExpressionSyntax arrayCreationExpression
UnnecessaryCodeDescriptor,
additionalUnnecessaryLocations[0],
NotificationOption2.ForSeverity(UnnecessaryCodeDescriptor.DefaultSeverity),
context.Options,
additionalLocations: locations,
additionalUnnecessaryLocations: additionalUnnecessaryLocations,
properties: properties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private void AnalyzeInvocationExpression(
Descriptor,
analysisResult.DiagnosticLocation,
option.Notification,
context.Options,
additionalLocations: locations,
properties: properties));

Expand All @@ -70,6 +71,7 @@ void FadeOutCode(SyntaxNodeAnalysisContext context, AnalysisResult analysisResul
UnnecessaryCodeDescriptor,
additionalUnnecessaryLocations[0],
NotificationOption2.ForSeverity(UnnecessaryCodeDescriptor.DefaultSeverity),
context.Options,
additionalLocations: locations,
additionalUnnecessaryLocations: additionalUnnecessaryLocations,
properties: properties));
Expand All @@ -87,6 +89,7 @@ void FadeOutCode(SyntaxNodeAnalysisContext context, AnalysisResult analysisResul
UnnecessaryCodeDescriptor,
additionalUnnecessaryLocations[0],
NotificationOption2.ForSeverity(UnnecessaryCodeDescriptor.DefaultSeverity),
context.Options,
additionalLocations: locations,
additionalUnnecessaryLocations: additionalUnnecessaryLocations,
properties: properties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private void AnalyzeInvocationExpression(SyntaxNodeAnalysisContext context, INam
Descriptor,
memberAccess.Name.Identifier.GetLocation(),
option.Notification,
context.Options,
additionalLocations: locations,
properties));

Expand All @@ -73,6 +74,7 @@ private void AnalyzeInvocationExpression(SyntaxNodeAnalysisContext context, INam
UnnecessaryCodeDescriptor,
additionalUnnecessaryLocations[0],
NotificationOption2.ForSeverity(UnnecessaryCodeDescriptor.DefaultSeverity),
context.Options,
additionalLocations: locations,
additionalUnnecessaryLocations: additionalUnnecessaryLocations,
properties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private void AnalyzeMemberAccess(SyntaxNodeAnalysisContext context, INamedTypeSy
Descriptor,
memberAccess.Name.Identifier.GetLocation(),
option.Notification,
context.Options,
additionalLocations: ImmutableArray.Create(nodeToReplace.GetLocation()),
properties: changesSemantics ? ChangesSemantics : null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private void AnalyzeMemberAccess(SyntaxNodeAnalysisContext context, INamedTypeSy
Descriptor,
memberAccess.Name.Identifier.GetLocation(),
option.Notification,
context.Options,
additionalLocations: ImmutableArray.Create(invocation.GetLocation()),
properties: analysisResult.Value.ChangesSemantics ? ChangesSemantics : null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private void AnalyzeImplicitStackAllocExpression(SyntaxNodeAnalysisContext conte
Descriptor,
expression.GetFirstToken().GetLocation(),
option.Notification,
context.Options,
additionalLocations: locations,
properties: null));

Expand All @@ -71,6 +72,7 @@ private void AnalyzeImplicitStackAllocExpression(SyntaxNodeAnalysisContext conte
UnnecessaryCodeDescriptor,
additionalUnnecessaryLocations[0],
NotificationOption2.ForSeverity(UnnecessaryCodeDescriptor.DefaultSeverity),
context.Options,
additionalLocations: locations,
additionalUnnecessaryLocations: additionalUnnecessaryLocations));
}
Expand All @@ -97,6 +99,7 @@ private void AnalyzeExplicitStackAllocExpression(SyntaxNodeAnalysisContext conte
Descriptor,
expression.GetFirstToken().GetLocation(),
option.Notification,
context.Options,
additionalLocations: locations,
properties: null));

Expand All @@ -109,6 +112,7 @@ private void AnalyzeExplicitStackAllocExpression(SyntaxNodeAnalysisContext conte
UnnecessaryCodeDescriptor,
additionalUnnecessaryLocations[0],
NotificationOption2.ForSeverity(UnnecessaryCodeDescriptor.DefaultSeverity),
context.Options,
additionalLocations: locations,
additionalUnnecessaryLocations: additionalUnnecessaryLocations));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private void AnalyzeCoalesceExpression(SyntaxNodeAnalysisContext context)
Descriptor,
coalesceExpression.OperatorToken.GetLocation(),
option.Notification,
context.Options,
additionalLocations: ImmutableArray.Create(coalesceExpression.GetLocation()),
properties: null));
}
Expand Down Expand Up @@ -168,6 +169,7 @@ private void AnalyzeIfStatement(SyntaxNodeAnalysisContext context)
Descriptor,
ifStatement.IfKeyword.GetLocation(),
option.Notification,
context.Options,
additionalLocations: ImmutableArray.Create(ifStatement.GetLocation()),
properties: null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private void AnalyzeVariableDeclaration(
Descriptor,
variableDeclaration.Variables[0].Identifier.GetLocation(),
notificationOption,
context.Options,
additionalLocations: null,
properties: null));
}
Expand All @@ -80,6 +81,7 @@ private void AnalyzeForEachStatement(
Descriptor,
forEachStatement.Identifier.GetLocation(),
notificationOption,
context.Options,
additionalLocations: null,
properties: null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
Descriptor,
defaultExpression.GetLocation(),
preference.Notification,
context.Options,
additionalLocations: [],
additionalUnnecessaryLocations: [defaultExpression.SyntaxTree.GetLocation(fadeSpan)]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
var properties = ImmutableDictionary<string, string?>.Empty.Add(nameof(UseExpressionBody), "");
return DiagnosticHelper.Create(
CreateDescriptorWithId(helper.DiagnosticId, helper.EnforceOnBuild, hasAnyCodeStyleOption: true, helper.UseExpressionBodyTitle, helper.UseExpressionBodyTitle),
location, preference.Notification, additionalLocations: additionalLocations, properties: properties);
location, preference.Notification, context.Options, additionalLocations: additionalLocations, properties: properties);
}

if (helper.CanOfferUseBlockBody(preference, declaration, forAnalyzer: true, out var fixesError, out var expressionBody))
Expand All @@ -124,7 +124,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
var additionalLocations = ImmutableArray.Create(declaration.GetLocation());
return DiagnosticHelper.Create(
CreateDescriptorWithId(helper.DiagnosticId, helper.EnforceOnBuild, hasAnyCodeStyleOption: true, helper.UseBlockBodyTitle, helper.UseBlockBodyTitle),
location, preference.Notification, additionalLocations: additionalLocations, properties: properties);
location, preference.Notification, context.Options, additionalLocations: additionalLocations, properties: properties);
}

return null;
Expand Down
Loading
Loading