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

Bump code style package to 3.9.0 #4919

Merged
merged 12 commits into from
Apr 14, 2021
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
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ indent_style = space
# https://github.com/dotnet/roslyn-analyzers/issues/3389
dotnet_diagnostic.RS1024.severity = none

# IDE0078: Use pattern matching
# https://github.com/dotnet/roslyn/issues/51691
# https://github.com/dotnet/roslyn/issues/51693
dotnet_diagnostic.IDE0078.severity = silent

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ See [VERSIONING.md](.//VERSIONING.md) for the versioning scheme for all analyzer

Recommended Analyzer Package Version: [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeAnalysis.NetAnalyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeAnalysis.NetAnalyzers)

Required Visual Studio Version: **Visual Studio 2019 16.8 RTW or later**
Required Visual Studio Version: **Visual Studio 2019 16.9 RTW or later**

Required .NET SDK Version: **.NET 5.0 SDK or later**

Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<!-- Use the correct compiler version -->
<UsingToolMicrosoftNetCompilers>true</UsingToolMicrosoftNetCompilers>
<!-- Dependencies from https://github.com/dotnet/roslyn -->
<MicrosoftNETCoreCompilersPackageVersion>3.8.0</MicrosoftNETCoreCompilersPackageVersion>
<MicrosoftNETCoreCompilersPackageVersion>3.9.0</MicrosoftNETCoreCompilersPackageVersion>
<MicrosoftNetCompilersToolsetVersion>$(MicrosoftNETCoreCompilersPackageVersion)</MicrosoftNetCompilersToolsetVersion>
<CodeStyleAnalyersVersion>$(MicrosoftNETCoreCompilersPackageVersion)</CodeStyleAnalyersVersion>
<!-- Roslyn -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class ClassIsNotDiagnosticAnalyzer : DiagnosticAnalyzer
private static readonly LocalizableString s_localizableTitleNotDiagnosticAnalyzer = new LocalizableResourceString(nameof(CodeAnalysisDiagnosticsResources.ClassIsNotDiagnosticAnalyzerTitle), CodeAnalysisDiagnosticsResources.ResourceManager, typeof(CodeAnalysisDiagnosticsResources));
private static readonly LocalizableString s_localizableMessageNotDiagnosticAnalyzer = new LocalizableResourceString(nameof(CodeAnalysisDiagnosticsResources.ClassIsNotDiagnosticAnalyzerMessage), CodeAnalysisDiagnosticsResources.ResourceManager, typeof(CodeAnalysisDiagnosticsResources));

public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
public static readonly DiagnosticDescriptor Rule = new(
DiagnosticIds.TypeIsNotDiagnosticAnalyzerRuleId,
s_localizableTitleNotDiagnosticAnalyzer,
s_localizableMessageNotDiagnosticAnalyzer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna
/// <summary>
/// RS1031 (<inheritdoc cref="CodeAnalysisDiagnosticsResources.DefineDiagnosticTitleCorrectlyTitle"/>)
/// </summary>
public static readonly DiagnosticDescriptor DefineDiagnosticTitleCorrectlyRule = new DiagnosticDescriptor(
public static readonly DiagnosticDescriptor DefineDiagnosticTitleCorrectlyRule = new(
DiagnosticIds.DefineDiagnosticTitleCorrectlyRuleId,
s_localizableDefineDiagnosticTitleCorrectlyTitle,
s_localizableDefineDiagnosticTitleCorrectlyMessage,
Expand All @@ -183,7 +183,7 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna
/// <summary>
/// RS1032 (<inheritdoc cref="CodeAnalysisDiagnosticsResources.DefineDiagnosticMessageCorrectlyTitle"/>)
/// </summary>
public static readonly DiagnosticDescriptor DefineDiagnosticMessageCorrectlyRule = new DiagnosticDescriptor(
public static readonly DiagnosticDescriptor DefineDiagnosticMessageCorrectlyRule = new(
DiagnosticIds.DefineDiagnosticMessageCorrectlyRuleId,
s_localizableDefineDiagnosticMessageCorrectlyTitle,
s_localizableDefineDiagnosticMessageCorrectlyMessage,
Expand All @@ -195,7 +195,7 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer : DiagnosticAna
/// <summary>
/// RS1033 (<inheritdoc cref="CodeAnalysisDiagnosticsResources.DefineDiagnosticDescriptionCorrectlyTitle"/>)
/// </summary>
public static readonly DiagnosticDescriptor DefineDiagnosticDescriptionCorrectlyRule = new DiagnosticDescriptor(
public static readonly DiagnosticDescriptor DefineDiagnosticDescriptionCorrectlyRule = new(
DiagnosticIds.DefineDiagnosticDescriptionCorrectlyRuleId,
s_localizableDefineDiagnosticDescriptionCorrectlyTitle,
s_localizableDefineDiagnosticDescriptionCorrectlyMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer
/// <summary>
/// RS1018 (<inheritdoc cref="CodeAnalysisDiagnosticsResources.DiagnosticIdMustBeInSpecifiedFormatTitle"/>)
/// </summary>
public static readonly DiagnosticDescriptor DiagnosticIdMustBeInSpecifiedFormatRule = new DiagnosticDescriptor(
public static readonly DiagnosticDescriptor DiagnosticIdMustBeInSpecifiedFormatRule = new(
DiagnosticIds.DiagnosticIdMustBeInSpecifiedFormatRuleId,
s_localizableDiagnosticIdMustBeInSpecifiedFormatTitle,
s_localizableDiagnosticIdMustBeInSpecifiedFormatMessage,
Expand All @@ -48,7 +48,7 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer
/// <summary>
/// RS1020 (<inheritdoc cref="CodeAnalysisDiagnosticsResources.UseCategoriesFromSpecifiedRangeTitle"/>)
/// </summary>
public static readonly DiagnosticDescriptor UseCategoriesFromSpecifiedRangeRule = new DiagnosticDescriptor(
public static readonly DiagnosticDescriptor UseCategoriesFromSpecifiedRangeRule = new(
DiagnosticIds.UseCategoriesFromSpecifiedRangeRuleId,
s_localizableUseCategoriesFromSpecifiedRangeTitle,
s_localizableUseCategoriesFromSpecifiedRangeMessage,
Expand All @@ -61,7 +61,7 @@ public sealed partial class DiagnosticDescriptorCreationAnalyzer
/// <summary>
/// RS1021 (<inheritdoc cref="CodeAnalysisDiagnosticsResources.AnalyzerCategoryAndIdRangeFileInvalidTitle"/>)
/// </summary>
public static readonly DiagnosticDescriptor AnalyzerCategoryAndIdRangeFileInvalidRule = new DiagnosticDescriptor(
public static readonly DiagnosticDescriptor AnalyzerCategoryAndIdRangeFileInvalidRule = new(
DiagnosticIds.AnalyzerCategoryAndIdRangeFileInvalidRuleId,
s_localizableAnalyzerCategoryAndIdRangeFileInvalidTitle,
s_localizableAnalyzerCategoryAndIdRangeFileInvalidMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed class DoNotUseCompilationGetSemanticModelAnalyzer : DiagnosticAnal
private static readonly LocalizableString s_localizableMessage = new LocalizableResourceString(nameof(CodeAnalysisDiagnosticsResources.DoNotUseCompilationGetSemanticModelMessage), CodeAnalysisDiagnosticsResources.ResourceManager, typeof(CodeAnalysisDiagnosticsResources));
private static readonly LocalizableString s_localizableDescription = new LocalizableResourceString(nameof(CodeAnalysisDiagnosticsResources.DoNotUseCompilationGetSemanticModelDescription), CodeAnalysisDiagnosticsResources.ResourceManager, typeof(CodeAnalysisDiagnosticsResources));

public static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
public static readonly DiagnosticDescriptor Rule = new(
DiagnosticIds.DoNotUseCompilationGetSemanticModelRuleId,
s_localizableTitle,
s_localizableMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed partial class DefineDiagnosticDescriptorArgumentsCorrectlyFix : Co
{
private sealed class CustomFixAllProvider : FixAllProvider
{
public static CustomFixAllProvider Instance = new CustomFixAllProvider();
public static CustomFixAllProvider Instance = new();

private CustomFixAllProvider()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@ public sealed class IdentifiersShouldHaveCorrectSuffixAnalyzer : DiagnosticAnaly

// Tuple says <TypeInheritedOrImplemented, AppropriateSuffix, Bool value saying if the suffix can `Collection` or the `AppropriateSuffix`>s
// The bool values are as mentioned in the Uri
private static readonly List<(string typeName, string suffix, bool canSuffixBeCollection)> s_baseTypesAndTheirSuffix = new List<(string, string, bool)>()
{
("System.Attribute", "Attribute", false),
("System.EventArgs", "EventArgs", false),
("System.Exception", "Exception", false),
("System.Collections.ICollection", "Collection", false),
("System.Collections.IDictionary", "Dictionary", false),
("System.Collections.IEnumerable", "Collection", false),
("System.Collections.Queue", "Queue", true),
("System.Collections.Stack", "Stack", true),
("System.Collections.Generic.Queue`1", "Queue", true),
("System.Collections.Generic.Stack`1", "Stack", true),
("System.Collections.Generic.ICollection`1", "Collection", false),
("System.Collections.Generic.IDictionary`2", "Dictionary", false),
("System.Collections.Generic.IReadOnlyDictionary`2", "Dictionary", false),
("System.Data.DataSet", "DataSet", false),
("System.Data.DataTable", "DataTable", true),
("System.IO.Stream", "Stream", false),
("System.Security.IPermission","Permission", false),
("System.Security.Policy.IMembershipCondition", "Condition", false)
};
private static readonly List<(string typeName, string suffix, bool canSuffixBeCollection)> s_baseTypesAndTheirSuffix = new()
{
("System.Attribute", "Attribute", false),
("System.EventArgs", "EventArgs", false),
("System.Exception", "Exception", false),
("System.Collections.ICollection", "Collection", false),
("System.Collections.IDictionary", "Dictionary", false),
("System.Collections.IEnumerable", "Collection", false),
("System.Collections.Queue", "Queue", true),
("System.Collections.Stack", "Stack", true),
("System.Collections.Generic.Queue`1", "Queue", true),
("System.Collections.Generic.Stack`1", "Stack", true),
("System.Collections.Generic.ICollection`1", "Collection", false),
("System.Collections.Generic.IDictionary`2", "Dictionary", false),
("System.Collections.Generic.IReadOnlyDictionary`2", "Dictionary", false),
("System.Data.DataSet", "DataSet", false),
("System.Data.DataTable", "DataTable", true),
("System.IO.Stream", "Stream", false),
("System.Security.IPermission", "Permission", false),
("System.Security.Policy.IMembershipCondition", "Condition", false)
};

public override void Initialize(AnalysisContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static bool isApplicableByDefault(string ruleId, SymbolKind symbolKind)

CA1505RuleId => 10,

CA1506RuleId => symbolKind == SymbolKind.NamedType ? 95 : 40,
CA1506RuleId => symbolKind == SymbolKind.NamedType ? 95 : (uint)40,

_ => throw new NotImplementedException(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private void AnalyzeOperationBlock(

return;

OperationVisitor CreateOperationVisitor(GlobalFlowStateAnalysisContext context) => new OperationVisitor(guardMethods, osPlatformType, context);
OperationVisitor CreateOperationVisitor(GlobalFlowStateAnalysisContext context) => new(guardMethods, osPlatformType, context);

ValueContentAbstractValue GetValueContentValue(IOperation operation)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ internal class DoNotDisableHttpClientCRLCheck : DiagnosticAnalyzer
"handler",
(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
{
return (abstractValue[ServerCertificateValidationCallbackIndex]) switch
return abstractValue[ServerCertificateValidationCallbackIndex] switch
{
PropertySetAbstractValueKind.Flagged => (abstractValue[CheckCertificateRevocationListIndex]) switch
PropertySetAbstractValueKind.Flagged => abstractValue[CheckCertificateRevocationListIndex] switch
{
PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
_ => HazardousUsageEvaluationResult.Unflagged,
},

PropertySetAbstractValueKind.MaybeFlagged => (abstractValue[CheckCertificateRevocationListIndex]) switch
PropertySetAbstractValueKind.MaybeFlagged => abstractValue[CheckCertificateRevocationListIndex] switch
{
PropertySetAbstractValueKind.Unflagged => HazardousUsageEvaluationResult.Unflagged,
_ => HazardousUsageEvaluationResult.MaybeFlagged,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public sealed class DoNotInstallRootCert : DiagnosticAnalyzer

private static HazardousUsageEvaluationResult HazardousUsageCallback(IMethodSymbol methodSymbol, PropertySetAbstractValue propertySetAbstractValue)
{
return (propertySetAbstractValue[0]) switch
return propertySetAbstractValue[0] switch
{
PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal class DoNotUseInsecureDeserializerJavaScriptSerializerWithSimpleTypeRes

private static HazardousUsageEvaluationResult HazardousUsageCallback(IMethodSymbol methodSymbol, PropertySetAbstractValue propertySetAbstractValue)
{
return (propertySetAbstractValue[0]) switch
return propertySetAbstractValue[0] switch
{
PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
PropertySetAbstractValueKind.Unflagged => HazardousUsageEvaluationResult.Unflagged,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public sealed class DoNotUseWeakKDFInsufficientIterationCount : DiagnosticAnalyz

private static HazardousUsageEvaluationResult HazardousUsageCallback(IMethodSymbol methodSymbol, PropertySetAbstractValue propertySetAbstractValue)
{
return (propertySetAbstractValue[0]) switch
return propertySetAbstractValue[0] switch
{
PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public sealed class UseSecureCookiesASPNetCore : DiagnosticAnalyzer

private static HazardousUsageEvaluationResult HazardousUsageCallback(IMethodSymbol methodSymbol, PropertySetAbstractValue propertySetAbstractValue)
{
return (propertySetAbstractValue[0]) switch
return propertySetAbstractValue[0] switch
{
PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void AnalyzeNode(SyntaxNodeAnalysisContext context)

private bool ShouldAnalyzeExpression(SyntaxNode expression, SemanticModel semanticModel, CancellationToken cancellationToken)
{
return (expression.Kind()) switch
return expression.Kind() switch
{
SyntaxKind.ArrayCreationExpression
or SyntaxKind.ImplicitArrayCreationExpression => ShouldAnalyzeArrayCreationExpression(expression, semanticModel, cancellationToken),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public sealed class IdentifiersShouldBeSpelledCorrectlyAnalyzer : DiagnosticAnal
private static readonly LocalizableString s_localizableMessageMethodTypeParameterMoreMeaningfulName = new LocalizableResourceString(nameof(TextAnalyzersResources.IdentifiersShouldBeSpelledCorrectlyMessageMethodTypeParameterMoreMeaningfulName), TextAnalyzersResources.ResourceManager, typeof(TextAnalyzersResources));
private static readonly LocalizableString s_localizableDescription = new LocalizableResourceString(nameof(TextAnalyzersResources.IdentifiersShouldBeSpelledCorrectlyDescription), TextAnalyzersResources.ResourceManager, typeof(TextAnalyzersResources));

private static readonly SourceTextValueProvider<CodeAnalysisDictionary> s_xmlDictionaryProvider = new SourceTextValueProvider<CodeAnalysisDictionary>(ParseXmlDictionary);
private static readonly SourceTextValueProvider<CodeAnalysisDictionary> s_dicDictionaryProvider = new SourceTextValueProvider<CodeAnalysisDictionary>(ParseDicDictionary);
private static readonly SourceTextValueProvider<CodeAnalysisDictionary> s_xmlDictionaryProvider = new(ParseXmlDictionary);
private static readonly SourceTextValueProvider<CodeAnalysisDictionary> s_dicDictionaryProvider = new(ParseDicDictionary);
private static readonly CodeAnalysisDictionary s_mainDictionary = GetMainDictionary();

internal static DiagnosticDescriptor FileParseRule = DiagnosticDescriptorHelper.Create(
Expand Down
Loading