diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 799c6a982a..ae31f7a019 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -4,7 +4,7 @@ Example: [Microsoft.CodeAnalysis.FxCopAnalyzers](https://www.nuget.org/packages/
#### Package Version
-Example: v2.9.4 (Latest)
+Example: v2.9.5-beta1.final (Latest)
#### Diagnostic ID
diff --git a/VERSIONING.md b/VERSIONING.md
index 6f065ac42b..7176253d97 100644
--- a/VERSIONING.md
+++ b/VERSIONING.md
@@ -40,3 +40,4 @@ Sr. No. | Release Version | Commit Tag | Commit SHA
20 | 2.9.3 | v2.9.3 | [7f096af](https://github.com/dotnet/roslyn-analyzers/commit/7f096aff22c1fd35652d55a9405e13d421dfe512) | Microsoft.CodeAnalysis.Analyzers, Microsoft.CodeAnalysis.FxCopAnalyzers, Microsoft.CodeAnalysis.Metrics, Microsoft.CodeAnalysis.VersionCheckAnalyzer, Microsoft.CodeQuality.Analyzers, Microsoft.NetCore.Analyzers, Microsoft.NetFramework.Analyzers, Roslyn.Diagnostics.Analyzers, Microsoft.CodeAnalysis.PublicApiAnalyzers, Microsoft.CodeAnalysis.BannedApiAnalyzers
21 | 2.9.4-beta1.final (pre-release) | v2.9.4-beta1.final | [3b22a6a](https://github.com/dotnet/roslyn-analyzers/commit/3b22a6a82d450350ab0cf27504adab8d1226b2a8) | Microsoft.CodeAnalysis.Analyzers, Microsoft.CodeAnalysis.FxCopAnalyzers, Microsoft.CodeAnalysis.Metrics, Microsoft.CodeAnalysis.VersionCheckAnalyzer, Microsoft.CodeQuality.Analyzers, Microsoft.NetCore.Analyzers, Microsoft.NetFramework.Analyzers, Roslyn.Diagnostics.Analyzers, Microsoft.CodeAnalysis.PublicApiAnalyzers, Microsoft.CodeAnalysis.BannedApiAnalyzers, Microsoft.CodeAnalysis.FlowAnalysis.Utilities
22 | 2.9.4 | v2.9.4 | [a1a198d](https://github.com/dotnet/roslyn-analyzers/commit/a1a198d1c5d2359e93dd4ab4b1c4f7421512724e) | Microsoft.CodeAnalysis.Analyzers, Microsoft.CodeAnalysis.FxCopAnalyzers, Microsoft.CodeAnalysis.Metrics, Microsoft.CodeAnalysis.VersionCheckAnalyzer, Microsoft.CodeQuality.Analyzers, Microsoft.NetCore.Analyzers, Microsoft.NetFramework.Analyzers, Roslyn.Diagnostics.Analyzers, Microsoft.CodeAnalysis.PublicApiAnalyzers, Microsoft.CodeAnalysis.BannedApiAnalyzers, Microsoft.CodeAnalysis.FlowAnalysis.Utilities
+23 | 2.9.5-beta1.final (pre-release) | v2.9.5-beta1.final | [494de6f](https://github.com/dotnet/roslyn-analyzers/commit/494de6f80082746e41d69355535f8dc3bfef494a) | Microsoft.CodeAnalysis.Analyzers, Microsoft.CodeAnalysis.FxCopAnalyzers, Microsoft.CodeAnalysis.Metrics, Microsoft.CodeAnalysis.VersionCheckAnalyzer, Microsoft.CodeQuality.Analyzers, Microsoft.NetCore.Analyzers, Microsoft.NetFramework.Analyzers, Roslyn.Diagnostics.Analyzers, Microsoft.CodeAnalysis.PublicApiAnalyzers, Microsoft.CodeAnalysis.BannedApiAnalyzers
diff --git a/eng/Analyzers_NonShippingRules.ruleset b/eng/Analyzers_NonShippingRules.ruleset
index 9d67b91e3a..11dfde9320 100644
--- a/eng/Analyzers_NonShippingRules.ruleset
+++ b/eng/Analyzers_NonShippingRules.ruleset
@@ -28,4 +28,8 @@
+
+
+
+
diff --git a/eng/Versions.props b/eng/Versions.props
index 7229609f39..9a2a375a5c 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -4,7 +4,7 @@
2.9.5
2.9.6
- beta1
+ beta2
true
@@ -20,10 +20,10 @@
2.9.0
- 3.0.0
- 2.9.4
+ 3.3.1-beta3-final
+ 2.9.5-beta1.final
3.0.0-beta2.19218.3+e96bad97
- 2.11.0-beta2-63603-03
+ 3.3.0-beta2-19376-02
2.0.0-pre-20160714
diff --git a/src/GenerateAnalyzerRulesets/Program.cs b/src/GenerateAnalyzerRulesets/Program.cs
index 4f8b482d10..5412fafb4d 100644
--- a/src/GenerateAnalyzerRulesets/Program.cs
+++ b/src/GenerateAnalyzerRulesets/Program.cs
@@ -277,32 +277,24 @@ bool shouldSkipRule(DiagnosticDescriptor rule)
string getRuleAction(DiagnosticDescriptor rule)
{
- switch (rulesetKind)
+ return rulesetKind switch
{
- case RulesetKind.CategoryDefault:
- return getRuleActionCore(enable: categoryPass && rule.IsEnabledByDefault);
+ RulesetKind.CategoryDefault => getRuleActionCore(enable: categoryPass && rule.IsEnabledByDefault),
- case RulesetKind.CategoryEnabled:
- return getRuleActionCore(enable: categoryPass);
+ RulesetKind.CategoryEnabled => getRuleActionCore(enable: categoryPass),
- case RulesetKind.CustomTagDefault:
- return getRuleActionCore(enable: customTagPass && rule.IsEnabledByDefault);
+ RulesetKind.CustomTagDefault => getRuleActionCore(enable: customTagPass && rule.IsEnabledByDefault),
- case RulesetKind.CustomTagEnabled:
- return getRuleActionCore(enable: customTagPass);
+ RulesetKind.CustomTagEnabled => getRuleActionCore(enable: customTagPass),
- case RulesetKind.AllDefault:
- return getRuleActionCore(enable: rule.IsEnabledByDefault);
+ RulesetKind.AllDefault => getRuleActionCore(enable: rule.IsEnabledByDefault),
- case RulesetKind.AllEnabled:
- return getRuleActionCore(enable: true);
+ RulesetKind.AllEnabled => getRuleActionCore(enable: true),
- case RulesetKind.AllDisabled:
- return getRuleActionCore(enable: false);
+ RulesetKind.AllDisabled => getRuleActionCore(enable: false),
- default:
- throw new InvalidProgramException();
- }
+ _ => throw new InvalidProgramException(),
+ };
string getRuleActionCore(bool enable)
{
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingKindArgumentToRegisterActionRuleTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingKindArgumentToRegisterActionRuleTests.cs
index 5f4f6455a9..9e1f179267 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingKindArgumentToRegisterActionRuleTests.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/MissingKindArgumentToRegisterActionRuleTests.cs
@@ -240,24 +240,16 @@ private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column,
private static DiagnosticResult GetExpectedDiagnostic(int line, int column, MissingKindArgument kind)
{
- string message;
- switch (kind)
+ var message = kind switch
{
- case MissingKindArgument.SymbolKind:
- message = CodeAnalysisDiagnosticsResources.MissingSymbolKindArgumentToRegisterActionMessage;
- break;
+ MissingKindArgument.SymbolKind => CodeAnalysisDiagnosticsResources.MissingSymbolKindArgumentToRegisterActionMessage,
- case MissingKindArgument.SyntaxKind:
- message = CodeAnalysisDiagnosticsResources.MissingSyntaxKindArgumentToRegisterActionMessage;
- break;
+ MissingKindArgument.SyntaxKind => CodeAnalysisDiagnosticsResources.MissingSyntaxKindArgumentToRegisterActionMessage,
- case MissingKindArgument.OperationKind:
- message = CodeAnalysisDiagnosticsResources.MissingOperationKindArgumentToRegisterActionMessage;
- break;
+ MissingKindArgument.OperationKind => CodeAnalysisDiagnosticsResources.MissingOperationKindArgumentToRegisterActionMessage,
- default:
- throw new ArgumentException("Unsupported argument kind", nameof(kind));
- }
+ _ => throw new ArgumentException("Unsupported argument kind", nameof(kind)),
+ };
return new DiagnosticResult(DiagnosticIds.MissingKindArgumentToRegisterActionRuleId, DiagnosticHelpers.DefaultDiagnosticSeverity)
.WithLocation(line, column)
diff --git a/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Core/RestrictedInternalsVisibleToAnalyzer.cs b/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Core/RestrictedInternalsVisibleToAnalyzer.cs
index 8e9f33cad7..18dc5d3e17 100644
--- a/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Core/RestrictedInternalsVisibleToAnalyzer.cs
+++ b/src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Core/RestrictedInternalsVisibleToAnalyzer.cs
@@ -78,33 +78,17 @@ private void OnCompilationStart(CompilationStartAnalysisContext compilationConte
compilationContext.RegisterOperationAction(
context =>
{
- ISymbol symbol;
- switch (context.Operation)
+ var symbol = context.Operation switch
{
- case IObjectCreationOperation objectCreation:
- symbol = objectCreation.Constructor;
- break;
- case IInvocationOperation invocation:
- symbol = invocation.TargetMethod;
- break;
- case IMemberReferenceOperation memberReference:
- symbol = memberReference.Member;
- break;
- case IConversionOperation conversion:
- symbol = conversion.OperatorMethod;
- break;
- case IUnaryOperation unary:
- symbol = unary.OperatorMethod;
- break;
- case IBinaryOperation binary:
- symbol = binary.OperatorMethod;
- break;
- case IIncrementOrDecrementOperation incrementOrDecrement:
- symbol = incrementOrDecrement.OperatorMethod;
- break;
- default:
- throw new NotImplementedException($"Unhandled OperationKind: {context.Operation.Kind}");
- }
+ IObjectCreationOperation objectCreation => objectCreation.Constructor,
+ IInvocationOperation invocation => invocation.TargetMethod,
+ IMemberReferenceOperation memberReference => memberReference.Member,
+ IConversionOperation conversion => conversion.OperatorMethod,
+ IUnaryOperation unary => unary.OperatorMethod,
+ IBinaryOperation binary => binary.OperatorMethod,
+ IIncrementOrDecrementOperation incrementOrDecrement => incrementOrDecrement.OperatorMethod,
+ _ => throw new NotImplementedException($"Unhandled OperationKind: {context.Operation.Kind}"),
+ };
VerifySymbol(symbol, context.Operation.Syntax,
context.ReportDiagnostic, restrictedInternalsVisibleToMap, namespaceToIsBannedMap);
diff --git a/src/Microsoft.CodeQuality.Analyzers/CSharp/QualityGuidelines/CSharpRemoveEmptyFinalizersAnalyzer.cs b/src/Microsoft.CodeQuality.Analyzers/CSharp/QualityGuidelines/CSharpRemoveEmptyFinalizersAnalyzer.cs
index 4acc8ebe10..43dbf28d20 100644
--- a/src/Microsoft.CodeQuality.Analyzers/CSharp/QualityGuidelines/CSharpRemoveEmptyFinalizersAnalyzer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/CSharp/QualityGuidelines/CSharpRemoveEmptyFinalizersAnalyzer.cs
@@ -62,16 +62,14 @@ private static bool IsEmptyBlockBody(BlockSyntax blockBody, SemanticModel semant
private static bool IsEmptyExpressionBody(ArrowExpressionClauseSyntax expressionBody, SemanticModel semanticModel)
{
- switch (expressionBody.Expression.Kind())
+ return (expressionBody.Expression.Kind()) switch
{
- case SyntaxKind.ThrowExpression:
- return true;
+ SyntaxKind.ThrowExpression => true,
- case SyntaxKind.InvocationExpression:
- return IsConditionalInvocation((InvocationExpressionSyntax)expressionBody.Expression, semanticModel);
- }
+ SyntaxKind.InvocationExpression => IsConditionalInvocation((InvocationExpressionSyntax)expressionBody.Expression, semanticModel),
- return false;
+ _ => false,
+ };
}
private static bool IsConditionalInvocation(InvocationExpressionSyntax invocationExpr, SemanticModel semanticModel)
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/EnumStorageShouldBeInt32.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/EnumStorageShouldBeInt32.Fixer.cs
index c8324a5bf1..c967b6ef91 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/EnumStorageShouldBeInt32.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/EnumStorageShouldBeInt32.Fixer.cs
@@ -1,6 +1,5 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/ExceptionsShouldBePublic.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/ExceptionsShouldBePublic.Fixer.cs
index f4c8f5b6eb..3098859738 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/ExceptionsShouldBePublic.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/ExceptionsShouldBePublic.Fixer.cs
@@ -2,7 +2,6 @@
using System.Collections.Immutable;
using System.Composition;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypes.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypes.Fixer.cs
index 7df36fb5e0..e3ce67c49f 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypes.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/InterfaceMethodsShouldBeCallableByChildTypes.Fixer.cs
@@ -185,20 +185,16 @@ private static IEnumerable GetExplicitImplementations(ISymbol symbol)
return null;
}
- switch (symbol.Kind)
+ return symbol.Kind switch
{
- case SymbolKind.Method:
- return ((IMethodSymbol)symbol).ExplicitInterfaceImplementations;
+ SymbolKind.Method => ((IMethodSymbol)symbol).ExplicitInterfaceImplementations,
- case SymbolKind.Event:
- return ((IEventSymbol)symbol).ExplicitInterfaceImplementations;
+ SymbolKind.Event => ((IEventSymbol)symbol).ExplicitInterfaceImplementations,
- case SymbolKind.Property:
- return ((IPropertySymbol)symbol).ExplicitInterfaceImplementations;
+ SymbolKind.Property => ((IPropertySymbol)symbol).ExplicitInterfaceImplementations,
- default:
- return null;
- }
+ _ => null,
+ };
}
private static async Task MakeContainingTypeSealed(Document document, IMethodSymbol methodSymbol, CancellationToken cancellationToken)
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OperatorsShouldHaveSymmetricalOverloads.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OperatorsShouldHaveSymmetricalOverloads.Fixer.cs
index 77139d6821..2f635ded60 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OperatorsShouldHaveSymmetricalOverloads.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OperatorsShouldHaveSymmetricalOverloads.Fixer.cs
@@ -106,17 +106,16 @@ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context)
private static OperatorKind GetInvertedOperatorKind(IMethodSymbol containingOperator)
{
- switch (containingOperator.Name)
+ return containingOperator.Name switch
{
- case WellKnownMemberNames.EqualityOperatorName: return OperatorKind.Inequality;
- case WellKnownMemberNames.InequalityOperatorName: return OperatorKind.Equality;
- case WellKnownMemberNames.LessThanOperatorName: return OperatorKind.GreaterThan;
- case WellKnownMemberNames.LessThanOrEqualOperatorName: return OperatorKind.GreaterThanOrEqual;
- case WellKnownMemberNames.GreaterThanOperatorName: return OperatorKind.LessThan;
- case WellKnownMemberNames.GreaterThanOrEqualOperatorName: return OperatorKind.LessThanOrEqual;
- }
-
- throw new InvalidOperationException();
+ WellKnownMemberNames.EqualityOperatorName => OperatorKind.Inequality,
+ WellKnownMemberNames.InequalityOperatorName => OperatorKind.Equality,
+ WellKnownMemberNames.LessThanOperatorName => OperatorKind.GreaterThan,
+ WellKnownMemberNames.LessThanOrEqualOperatorName => OperatorKind.GreaterThanOrEqual,
+ WellKnownMemberNames.GreaterThanOperatorName => OperatorKind.LessThan,
+ WellKnownMemberNames.GreaterThanOrEqualOperatorName => OperatorKind.LessThanOrEqual,
+ _ => throw new InvalidOperationException(),
+ };
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEquals.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEquals.Fixer.cs
index 828fad13fc..4ecb35a03f 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEquals.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverloadOperatorEqualsOnOverridingValueTypeEquals.Fixer.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Immutable;
using System.Composition;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideEqualsOnOverloadingOperatorEquals.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideEqualsOnOverloadingOperatorEquals.Fixer.cs
index 3877c948fc..61e4f104e5 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideEqualsOnOverloadingOperatorEquals.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideEqualsOnOverloadingOperatorEquals.Fixer.cs
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideGetHashCodeOnOverridingEquals.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideGetHashCodeOnOverridingEquals.Fixer.cs
index b620e327e1..0867bd5b08 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideGetHashCodeOnOverridingEquals.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideGetHashCodeOnOverridingEquals.Fixer.cs
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideMethodsOnComparableTypes.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideMethodsOnComparableTypes.Fixer.cs
index 00cb0e7642..30238f2bae 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideMethodsOnComparableTypes.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/OverrideMethodsOnComparableTypes.Fixer.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Immutable;
using System.Composition;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/AvoidUnusedPrivateFields.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/AvoidUnusedPrivateFields.Fixer.cs
index 9ba1a31232..e78227d0df 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/AvoidUnusedPrivateFields.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/AvoidUnusedPrivateFields.Fixer.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Immutable;
using System.Composition;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/CodeMetricsAnalyzer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/CodeMetricsAnalyzer.cs
index 15de6a30a4..5021534be0 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/CodeMetricsAnalyzer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/CodeMetricsAnalyzer.cs
@@ -288,23 +288,18 @@ static bool isApplicableByDefault(string ruleId, SymbolKind symbolKind)
}
// Compat: we match the default threshold values for old FxCop implementation.
- switch (ruleId)
+ return ruleId switch
{
- case CA1501RuleId:
- return 5;
+ CA1501RuleId => 5,
- case CA1502RuleId:
- return 25;
+ CA1502RuleId => 25,
- case CA1505RuleId:
- return 10;
+ CA1505RuleId => 10,
- case CA1506RuleId:
- return symbolKind == SymbolKind.NamedType ? 95 : (uint)40;
+ CA1506RuleId => symbolKind == SymbolKind.NamedType ? 95 : (uint)40,
- default:
- throw new NotImplementedException();
- }
+ _ => throw new NotImplementedException(),
+ };
}
});
}
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/RemoveEmptyFinalizers.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/RemoveEmptyFinalizers.Fixer.cs
index c14bba943b..027e33ab19 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/RemoveEmptyFinalizers.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/RemoveEmptyFinalizers.Fixer.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Immutable;
using System.Composition;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/UseLiteralsWhereAppropriate.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/UseLiteralsWhereAppropriate.Fixer.cs
index 942f019b72..2590c15e83 100644
--- a/src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/UseLiteralsWhereAppropriate.Fixer.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/UseLiteralsWhereAppropriate.Fixer.cs
@@ -2,7 +2,6 @@
using System;
using System.Collections.Immutable;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
diff --git a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscoresTests.cs b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscoresTests.cs
index 41316f664a..4699d02f42 100644
--- a/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscoresTests.cs
+++ b/src/Microsoft.CodeQuality.Analyzers/UnitTests/ApiDesignGuidelines/IdentifiersShouldNotContainUnderscoresTests.cs
@@ -882,27 +882,18 @@ private void Verify(string source, string language, DiagnosticAnalyzer analyzer,
private static string GetApproriateMessage(SymbolKind symbolKind)
{
- switch (symbolKind)
+ return symbolKind switch
{
- case SymbolKind.Assembly:
- return MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageAssembly;
- case SymbolKind.Namespace:
- return MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageNamespace;
- case SymbolKind.NamedType:
- return MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageType;
- case SymbolKind.Member:
- return MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageMember;
- case SymbolKind.DelegateParameter:
- return MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageDelegateParameter;
- case SymbolKind.MemberParameter:
- return MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageMemberParameter;
- case SymbolKind.TypeTypeParameter:
- return MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageTypeTypeParameter;
- case SymbolKind.MethodTypeParameter:
- return MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageMethodTypeParameter;
- default:
- throw new System.Exception("Unknown Symbol Kind");
- }
+ SymbolKind.Assembly => MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageAssembly,
+ SymbolKind.Namespace => MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageNamespace,
+ SymbolKind.NamedType => MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageType,
+ SymbolKind.Member => MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageMember,
+ SymbolKind.DelegateParameter => MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageDelegateParameter,
+ SymbolKind.MemberParameter => MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageMemberParameter,
+ SymbolKind.TypeTypeParameter => MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageTypeTypeParameter,
+ SymbolKind.MethodTypeParameter => MicrosoftCodeQualityAnalyzersResources.IdentifiersShouldNotContainUnderscoresMessageMethodTypeParameter,
+ _ => throw new System.Exception("Unknown Symbol Kind"),
+ };
}
private enum SymbolKind
diff --git a/src/Microsoft.NetCore.Analyzers/Core/InteropServices/SpecifyMarshalingForPInvokeStringArguments.Fixer.cs b/src/Microsoft.NetCore.Analyzers/Core/InteropServices/SpecifyMarshalingForPInvokeStringArguments.Fixer.cs
index bd37250f54..e7db0e2ba1 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/InteropServices/SpecifyMarshalingForPInvokeStringArguments.Fixer.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/InteropServices/SpecifyMarshalingForPInvokeStringArguments.Fixer.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
diff --git a/src/Microsoft.NetCore.Analyzers/Core/Runtime/AvoidUnsealedAttributes.Fixer.cs b/src/Microsoft.NetCore.Analyzers/Core/Runtime/AvoidUnsealedAttributes.Fixer.cs
index f1dc2c6b38..e7446b4a20 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/Runtime/AvoidUnsealedAttributes.Fixer.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/Runtime/AvoidUnsealedAttributes.Fixer.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Immutable;
using System.Composition;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
diff --git a/src/Microsoft.NetCore.Analyzers/Core/Runtime/MarkISerializableTypesWithSerializable.Fixer.cs b/src/Microsoft.NetCore.Analyzers/Core/Runtime/MarkISerializableTypesWithSerializable.Fixer.cs
index 9449b9b60d..db2796be3a 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/Runtime/MarkISerializableTypesWithSerializable.Fixer.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/Runtime/MarkISerializableTypesWithSerializable.Fixer.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Immutable;
using System.Composition;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Microsoft.NetCore.Analyzers/Core/Runtime/TestForNaNCorrectly.Fixer.cs b/src/Microsoft.NetCore.Analyzers/Core/Runtime/TestForNaNCorrectly.Fixer.cs
index 7c0ddba1ab..59db43bba7 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/Runtime/TestForNaNCorrectly.Fixer.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/Runtime/TestForNaNCorrectly.Fixer.cs
@@ -2,7 +2,6 @@
using Microsoft.CodeAnalysis.CodeFixes;
using System.Collections.Immutable;
-using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
diff --git a/src/Microsoft.NetCore.Analyzers/Core/Runtime/UseOrdinalStringComparison.Fixer.cs b/src/Microsoft.NetCore.Analyzers/Core/Runtime/UseOrdinalStringComparison.Fixer.cs
index f49cbe3808..390efa104c 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/Runtime/UseOrdinalStringComparison.Fixer.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/Runtime/UseOrdinalStringComparison.Fixer.cs
@@ -2,7 +2,6 @@
using System;
using System.Collections.Immutable;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
diff --git a/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotDisableHttpClientCRLCheck.cs b/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotDisableHttpClientCRLCheck.cs
index cc4d5ece2c..a35161e7ce 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotDisableHttpClientCRLCheck.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotDisableHttpClientCRLCheck.cs
@@ -83,31 +83,23 @@ class DoNotDisableHttpClientCRLCheck : DiagnosticAnalyzer
"handler",
(IMethodSymbol methodSymbol, PropertySetAbstractValue abstractValue) =>
{
- switch (abstractValue[ServerCertificateValidationCallbackIndex])
+ return (abstractValue[ServerCertificateValidationCallbackIndex]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- switch (abstractValue[CheckCertificateRevocationListIndex])
- {
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => (abstractValue[CheckCertificateRevocationListIndex]) switch
+ {
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ },
- case PropertySetAbstractValueKind.MaybeFlagged:
- switch (abstractValue[CheckCertificateRevocationListIndex])
- {
- case PropertySetAbstractValueKind.Unflagged:
- return HazardousUsageEvaluationResult.Unflagged;
- default:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- }
+ PropertySetAbstractValueKind.MaybeFlagged => (abstractValue[CheckCertificateRevocationListIndex]) switch
+ {
+ PropertySetAbstractValueKind.Unflagged => HazardousUsageEvaluationResult.Unflagged,
+ _ => HazardousUsageEvaluationResult.MaybeFlagged,
+ },
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
},
true));
diff --git a/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotInstallRootCert.cs b/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotInstallRootCert.cs
index 6f8bd7c0c2..483453aec7 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotInstallRootCert.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotInstallRootCert.cs
@@ -52,17 +52,14 @@ public sealed class DoNotInstallRootCert : DiagnosticAnalyzer
private static HazardousUsageEvaluationResult HazardousUsageCallback(IMethodSymbol methodSymbol, PropertySetAbstractValue propertySetAbstractValue)
{
- switch (propertySetAbstractValue[0])
+ return (propertySetAbstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
}
public override void Initialize(AnalysisContext context)
diff --git a/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolver.cs b/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolver.cs
index 22966e1703..a5eb0091b4 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolver.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolver.cs
@@ -54,15 +54,12 @@ class DoNotUseInsecureDeserializerJavaScriptSerializerWithSimpleTypeResolver : D
private static HazardousUsageEvaluationResult HazardousUsageCallback(IMethodSymbol methodSymbol, PropertySetAbstractValue propertySetAbstractValue)
{
- switch (propertySetAbstractValue[0])
+ return (propertySetAbstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.Unflagged:
- return HazardousUsageEvaluationResult.Unflagged;
- default:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.Unflagged => HazardousUsageEvaluationResult.Unflagged,
+ _ => HazardousUsageEvaluationResult.MaybeFlagged,
+ };
}
public override void Initialize(AnalysisContext context)
diff --git a/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotUseWeakKDFInsufficientIterationCount.cs b/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotUseWeakKDFInsufficientIterationCount.cs
index 0f98274c67..65bd75fd31 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotUseWeakKDFInsufficientIterationCount.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/Security/DoNotUseWeakKDFInsufficientIterationCount.cs
@@ -49,17 +49,14 @@ public sealed class DoNotUseWeakKDFInsufficientIterationCount : DiagnosticAnalyz
private static HazardousUsageEvaluationResult HazardousUsageCallback(IMethodSymbol methodSymbol, PropertySetAbstractValue propertySetAbstractValue)
{
- switch (propertySetAbstractValue[0])
+ return (propertySetAbstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
}
public override void Initialize(AnalysisContext context)
diff --git a/src/Microsoft.NetCore.Analyzers/Core/Security/UseSecureCookiesASPNetCore.cs b/src/Microsoft.NetCore.Analyzers/Core/Security/UseSecureCookiesASPNetCore.cs
index 819c9b2359..a6d443928b 100644
--- a/src/Microsoft.NetCore.Analyzers/Core/Security/UseSecureCookiesASPNetCore.cs
+++ b/src/Microsoft.NetCore.Analyzers/Core/Security/UseSecureCookiesASPNetCore.cs
@@ -57,17 +57,14 @@ public sealed class UseSecureCookiesASPNetCore : DiagnosticAnalyzer
private static HazardousUsageEvaluationResult HazardousUsageCallback(IMethodSymbol methodSymbol, PropertySetAbstractValue propertySetAbstractValue)
{
- switch (propertySetAbstractValue[0])
+ return (propertySetAbstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
}
public override void Initialize(AnalysisContext context)
diff --git a/src/Microsoft.NetCore.Analyzers/UnitTests/Performance/DoNotUseCountWhenAnyCanBeUsedTests.Code.cs b/src/Microsoft.NetCore.Analyzers/UnitTests/Performance/DoNotUseCountWhenAnyCanBeUsedTests.Code.cs
index ade2943bd3..e3f09a4789 100644
--- a/src/Microsoft.NetCore.Analyzers/UnitTests/Performance/DoNotUseCountWhenAnyCanBeUsedTests.Code.cs
+++ b/src/Microsoft.NetCore.Analyzers/UnitTests/Performance/DoNotUseCountWhenAnyCanBeUsedTests.Code.cs
@@ -198,17 +198,17 @@ public static class {className}
public override string GetOperatorCode(BinaryOperatorKind binaryOperatorKind)
{
- switch (binaryOperatorKind)
+ return binaryOperatorKind switch
{
- case BinaryOperatorKind.Add: return "+";
- case BinaryOperatorKind.Equals: return "==";
- case BinaryOperatorKind.GreaterThan: return ">";
- case BinaryOperatorKind.GreaterThanOrEqual: return ">=";
- case BinaryOperatorKind.LessThan: return "<";
- case BinaryOperatorKind.LessThanOrEqual: return "<=";
- case BinaryOperatorKind.NotEquals: return "!=";
- default: throw new ArgumentOutOfRangeException(nameof(binaryOperatorKind), binaryOperatorKind, $"Invalid value: {binaryOperatorKind}");
- }
+ BinaryOperatorKind.Add => "+",
+ BinaryOperatorKind.Equals => "==",
+ BinaryOperatorKind.GreaterThan => ">",
+ BinaryOperatorKind.GreaterThanOrEqual => ">=",
+ BinaryOperatorKind.LessThan => "<",
+ BinaryOperatorKind.LessThanOrEqual => "<=",
+ BinaryOperatorKind.NotEquals => "!=",
+ _ => throw new ArgumentOutOfRangeException(nameof(binaryOperatorKind), binaryOperatorKind, $"Invalid value: {binaryOperatorKind}"),
+ };
}
public override string GetPredicateCode() => "_ => true";
@@ -345,17 +345,17 @@ End Namespace
public override string GetOperatorCode(BinaryOperatorKind binaryOperatorKind)
{
- switch (binaryOperatorKind)
+ return binaryOperatorKind switch
{
- case BinaryOperatorKind.Add: return "+";
- case BinaryOperatorKind.Equals: return "=";
- case BinaryOperatorKind.GreaterThan: return ">";
- case BinaryOperatorKind.GreaterThanOrEqual: return ">=";
- case BinaryOperatorKind.LessThan: return "<";
- case BinaryOperatorKind.LessThanOrEqual: return "<=";
- case BinaryOperatorKind.NotEquals: return "<>";
- default: throw new ArgumentOutOfRangeException(nameof(binaryOperatorKind), binaryOperatorKind, $"Invalid value: {binaryOperatorKind}");
- }
+ BinaryOperatorKind.Add => "+",
+ BinaryOperatorKind.Equals => "=",
+ BinaryOperatorKind.GreaterThan => ">",
+ BinaryOperatorKind.GreaterThanOrEqual => ">=",
+ BinaryOperatorKind.LessThan => "<",
+ BinaryOperatorKind.LessThanOrEqual => "<=",
+ BinaryOperatorKind.NotEquals => "<>",
+ _ => throw new ArgumentOutOfRangeException(nameof(binaryOperatorKind), binaryOperatorKind, $"Invalid value: {binaryOperatorKind}"),
+ };
}
public override string GetPredicateCode() => "Function(x) True";
diff --git a/src/ReleaseNotesUtil/Program.cs b/src/ReleaseNotesUtil/Program.cs
index bf078f4f11..63b96d61ab 100644
--- a/src/ReleaseNotesUtil/Program.cs
+++ b/src/ReleaseNotesUtil/Program.cs
@@ -49,8 +49,10 @@ private static void PrintUsage()
private static void GetRulesJson(string nugetInstalledPackagesPath, string version, string outputPath)
{
IEnumerable dllPaths = GetFxCopAnalyzerBinaries(nugetInstalledPackagesPath, version);
- RuleFileContent ruleFileContent = new RuleFileContent();
- ruleFileContent.Rules = GetRules(dllPaths);
+ RuleFileContent ruleFileContent = new RuleFileContent
+ {
+ Rules = GetRules(dllPaths)
+ };
ruleFileContent.Rules.Sort(CategoryThenIdComparer.Instance);
WriteRuleFileContent(ruleFileContent, outputPath);
}
@@ -65,13 +67,13 @@ private static void GetRulesJson(string nugetInstalledPackagesPath, string versi
RuleFileContent newContent = ReadRuleFileContent(newRulesJsonPath);
// If we have the latest rules, we can backfill missing help link URLs.
- if (!String.IsNullOrWhiteSpace(latestRulesJsonPath))
+ if (!string.IsNullOrWhiteSpace(latestRulesJsonPath))
{
RuleFileContent latestContent = ReadRuleFileContent(latestRulesJsonPath);
Dictionary latestRulesById = latestContent.Rules.ToDictionary(r => r.Id);
foreach (RuleInfo rule in oldContent.Rules.Concat(newContent.Rules))
{
- if (String.IsNullOrWhiteSpace(rule.HelpLink)
+ if (string.IsNullOrWhiteSpace(rule.HelpLink)
&& latestRulesById.TryGetValue(rule.Id, out RuleInfo latestRule))
{
rule.HelpLink = latestRule.HelpLink;
diff --git a/src/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs b/src/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs
index 1762693410..5efce04998 100644
--- a/src/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs
+++ b/src/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs
@@ -222,17 +222,13 @@ public static void StaticMethod(TestTypeToTrack staticMethodParameter)
"AString",
(PointsToAbstractValue pointsToAbstractValue) =>
{
- switch (pointsToAbstractValue.NullState)
+ return pointsToAbstractValue.NullState switch
{
- case NullAbstractValue.Null:
- return PropertySetAbstractValueKind.Unflagged;
- case NullAbstractValue.NotNull:
- return PropertySetAbstractValueKind.Flagged;
- case NullAbstractValue.MaybeNull:
- return PropertySetAbstractValueKind.MaybeFlagged;
- default:
- return PropertySetAbstractValueKind.Unknown;
- }
+ NullAbstractValue.Null => PropertySetAbstractValueKind.Unflagged,
+ NullAbstractValue.NotNull => PropertySetAbstractValueKind.Flagged,
+ NullAbstractValue.MaybeNull => PropertySetAbstractValueKind.MaybeFlagged,
+ _ => PropertySetAbstractValueKind.Unknown,
+ };
})),
new HazardousUsageEvaluatorCollection(
new HazardousUsageEvaluator( // When TypeToTrack.Method() is invoked, need to evaluate its state.
@@ -242,15 +238,12 @@ public static void StaticMethod(TestTypeToTrack staticMethodParameter)
// When doing this for reals, need to examine the method to make sure we're looking at the right method and arguments.
// With only one property being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
}),
new HazardousUsageEvaluator( // When OtherClass.OtherMethod() is invoked, evaluate its "TypeToTrack t" argument.
"OtherClass",
@@ -262,15 +255,12 @@ public static void StaticMethod(TestTypeToTrack staticMethodParameter)
// With only one property being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
}),
new HazardousUsageEvaluator( // When OtherClass.StaticMethod() is invoked, evaluate its "TypeToTrack staticMethodParameter" argument.
"OtherClass",
@@ -282,15 +272,12 @@ public static void StaticMethod(TestTypeToTrack staticMethodParameter)
// With only one property being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
})));
[Fact]
@@ -415,21 +402,13 @@ void TestMethod()
if (method.Parameters.Length >= 2)
{
// Definitely null => unflagged, definitely non-null => flagged, otherwise => maybe.
- switch (argumentPointsToAbstractValues[2].NullState)
+ kind = argumentPointsToAbstractValues[2].NullState switch
{
- case NullAbstractValue.Null:
- kind = PropertySetAbstractValueKind.Unflagged;
- break;
- case NullAbstractValue.NotNull:
- kind = PropertySetAbstractValueKind.Flagged;
- break;
- case NullAbstractValue.MaybeNull:
- kind = PropertySetAbstractValueKind.MaybeFlagged;
- break;
- default:
- kind = PropertySetAbstractValueKind.Unknown;
- break;
- }
+ NullAbstractValue.Null => PropertySetAbstractValueKind.Unflagged,
+ NullAbstractValue.NotNull => PropertySetAbstractValueKind.Flagged,
+ NullAbstractValue.MaybeNull => PropertySetAbstractValueKind.MaybeFlagged,
+ _ => PropertySetAbstractValueKind.Unknown,
+ };
}
return PropertySetAbstractValue.GetInstance(kind);
@@ -439,17 +418,13 @@ void TestMethod()
"AString",
(PointsToAbstractValue pointsToAbstractValue) =>
{
- switch (pointsToAbstractValue.NullState)
+ return pointsToAbstractValue.NullState switch
{
- case NullAbstractValue.Null:
- return PropertySetAbstractValueKind.Unflagged;
- case NullAbstractValue.NotNull:
- return PropertySetAbstractValueKind.Flagged;
- case NullAbstractValue.MaybeNull:
- return PropertySetAbstractValueKind.MaybeFlagged;
- default:
- return PropertySetAbstractValueKind.Unknown;
- }
+ NullAbstractValue.Null => PropertySetAbstractValueKind.Unflagged,
+ NullAbstractValue.NotNull => PropertySetAbstractValueKind.Flagged,
+ NullAbstractValue.MaybeNull => PropertySetAbstractValueKind.MaybeFlagged,
+ _ => PropertySetAbstractValueKind.Unknown,
+ };
})),
new HazardousUsageEvaluatorCollection(
new HazardousUsageEvaluator(
@@ -459,15 +434,12 @@ void TestMethod()
// When doing this for reals, need to examine the method to make sure we're looking at the right method and arguments.
// With only one property being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
})));
[Fact]
@@ -560,15 +532,12 @@ void TestMethod()
// When doing this for reals, need to examine the method to make sure we're looking at the right method and arguments.
// With only one property being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
})));
[Fact]
@@ -635,15 +604,12 @@ void TestMethod()
// When doing this for reals, need to examine the method to make sure we're looking at the right method and arguments.
// With only one property being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
})));
[Fact]
@@ -897,15 +863,12 @@ void TestMethod()
// When doing this for reals, need to examine the method to make sure we're looking at the right method and arguments.
// With only one property being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
})));
[Fact]
@@ -1003,15 +966,12 @@ void TestMethod()
// When doing this for reals, need to examine the method to make sure we're looking at the right method and arguments.
// With only one property being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
})));
[Fact]
@@ -1071,17 +1031,13 @@ TestTypeToTrackWithConstructor GetTestType()
"AString",
(PointsToAbstractValue pointsToAbstractValue) =>
{
- switch (pointsToAbstractValue.NullState)
+ return pointsToAbstractValue.NullState switch
{
- case NullAbstractValue.Null:
- return PropertySetAbstractValueKind.Unflagged;
- case NullAbstractValue.NotNull:
- return PropertySetAbstractValueKind.Flagged;
- case NullAbstractValue.MaybeNull:
- return PropertySetAbstractValueKind.MaybeFlagged;
- default:
- return PropertySetAbstractValueKind.Unknown;
- }
+ NullAbstractValue.Null => PropertySetAbstractValueKind.Unflagged,
+ NullAbstractValue.NotNull => PropertySetAbstractValueKind.Flagged,
+ NullAbstractValue.MaybeNull => PropertySetAbstractValueKind.MaybeFlagged,
+ _ => PropertySetAbstractValueKind.Unknown,
+ };
})),
new HazardousUsageEvaluatorCollection(
new HazardousUsageEvaluator(
@@ -1089,15 +1045,12 @@ TestTypeToTrackWithConstructor GetTestType()
(PropertySetAbstractValue abstractValue) =>
{
// With only one property being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
})));
[Fact]
@@ -1181,34 +1134,26 @@ object TestMethod()
"AString",
(PointsToAbstractValue pointsToAbstractValue) =>
{
- switch (pointsToAbstractValue.NullState)
+ return pointsToAbstractValue.NullState switch
{
- case NullAbstractValue.Null:
- return PropertySetAbstractValueKind.Unflagged;
- case NullAbstractValue.NotNull:
- return PropertySetAbstractValueKind.Flagged;
- case NullAbstractValue.MaybeNull:
- return PropertySetAbstractValueKind.MaybeFlagged;
- default:
- return PropertySetAbstractValueKind.Unknown;
- }
+ NullAbstractValue.Null => PropertySetAbstractValueKind.Unflagged,
+ NullAbstractValue.NotNull => PropertySetAbstractValueKind.Flagged,
+ NullAbstractValue.MaybeNull => PropertySetAbstractValueKind.MaybeFlagged,
+ _ => PropertySetAbstractValueKind.Unknown,
+ };
},
propertyIndex: 0), // Both AString and AnObject point to index 0.
new PropertyMapper( // Definitely null => unflagged, definitely non-null => flagged, otherwise => maybe.
"AnObject",
(PointsToAbstractValue pointsToAbstractValue) =>
{
- switch (pointsToAbstractValue.NullState)
+ return pointsToAbstractValue.NullState switch
{
- case NullAbstractValue.Null:
- return PropertySetAbstractValueKind.Unflagged;
- case NullAbstractValue.NotNull:
- return PropertySetAbstractValueKind.Flagged;
- case NullAbstractValue.MaybeNull:
- return PropertySetAbstractValueKind.MaybeFlagged;
- default:
- return PropertySetAbstractValueKind.Unknown;
- }
+ NullAbstractValue.Null => PropertySetAbstractValueKind.Unflagged,
+ NullAbstractValue.NotNull => PropertySetAbstractValueKind.Flagged,
+ NullAbstractValue.MaybeNull => PropertySetAbstractValueKind.MaybeFlagged,
+ _ => PropertySetAbstractValueKind.Unknown,
+ };
},
propertyIndex: 0)), // Both AString and AnObject point to index 0.
new HazardousUsageEvaluatorCollection(
@@ -1219,15 +1164,12 @@ object TestMethod()
// When doing this for reals, need to examine the method to make sure we're looking at the right method and arguments.
// With only underlying value (from the two "aliased" properties) being tracked, this is straightforward.
- switch (abstractValue[0])
+ return (abstractValue[0]) switch
{
- case PropertySetAbstractValueKind.Flagged:
- return HazardousUsageEvaluationResult.Flagged;
- case PropertySetAbstractValueKind.MaybeFlagged:
- return HazardousUsageEvaluationResult.MaybeFlagged;
- default:
- return HazardousUsageEvaluationResult.Unflagged;
- }
+ PropertySetAbstractValueKind.Flagged => HazardousUsageEvaluationResult.Flagged,
+ PropertySetAbstractValueKind.MaybeFlagged => HazardousUsageEvaluationResult.MaybeFlagged,
+ _ => HazardousUsageEvaluationResult.Unflagged,
+ };
})));
[Fact]
diff --git a/src/Utilities/Compiler/CodeMetrics/CodeAnalysisMetricData.cs b/src/Utilities/Compiler/CodeMetrics/CodeAnalysisMetricData.cs
index a88c21b53f..28fba83df8 100644
--- a/src/Utilities/Compiler/CodeMetrics/CodeAnalysisMetricData.cs
+++ b/src/Utilities/Compiler/CodeMetrics/CodeAnalysisMetricData.cs
@@ -164,32 +164,24 @@ public static Task ComputeAsync(ISymbol symbol, Compilat
internal async static Task ComputeAsync(ISymbol symbol, SemanticModelProvider semanticModelProvider, CancellationToken cancellationToken)
{
- switch (symbol.Kind)
+ return symbol.Kind switch
{
- case SymbolKind.Assembly:
- return await AssemblyMetricData.ComputeAsync((IAssemblySymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false);
+ SymbolKind.Assembly => await AssemblyMetricData.ComputeAsync((IAssemblySymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false),
- case SymbolKind.Namespace:
- return await NamespaceMetricData.ComputeAsync((INamespaceSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false);
+ SymbolKind.Namespace => await NamespaceMetricData.ComputeAsync((INamespaceSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false),
- case SymbolKind.NamedType:
- return await NamedTypeMetricData.ComputeAsync((INamedTypeSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false);
+ SymbolKind.NamedType => await NamedTypeMetricData.ComputeAsync((INamedTypeSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false),
- case SymbolKind.Method:
- return await MethodMetricData.ComputeAsync((IMethodSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false);
+ SymbolKind.Method => await MethodMetricData.ComputeAsync((IMethodSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false),
- case SymbolKind.Property:
- return await PropertyMetricData.ComputeAsync((IPropertySymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false);
+ SymbolKind.Property => await PropertyMetricData.ComputeAsync((IPropertySymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false),
- case SymbolKind.Field:
- return await FieldMetricData.ComputeAsync((IFieldSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false);
+ SymbolKind.Field => await FieldMetricData.ComputeAsync((IFieldSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false),
- case SymbolKind.Event:
- return await EventMetricData.ComputeAsync((IEventSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false);
+ SymbolKind.Event => await EventMetricData.ComputeAsync((IEventSymbol)symbol, semanticModelProvider, cancellationToken).ConfigureAwait(false),
- default:
- throw new NotSupportedException();
- }
+ _ => throw new NotSupportedException(),
+ };
}
internal static async Task> ComputeAsync(IEnumerable children, SemanticModelProvider semanticModelProvider, CancellationToken cancellationToken)
diff --git a/src/Utilities/Compiler/CodeMetrics/MetricsHelper.cs b/src/Utilities/Compiler/CodeMetrics/MetricsHelper.cs
index bdf905e246..e9b13ff950 100644
--- a/src/Utilities/Compiler/CodeMetrics/MetricsHelper.cs
+++ b/src/Utilities/Compiler/CodeMetrics/MetricsHelper.cs
@@ -305,15 +305,12 @@ internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet GetParameters(this ISymbol member)
{
- switch (member.Kind)
+ return member.Kind switch
{
- case SymbolKind.Method:
- return ((IMethodSymbol)member).Parameters;
- case SymbolKind.Property:
- return ((IPropertySymbol)member).Parameters;
- default:
- return ImmutableArray.Empty;
- }
+ SymbolKind.Method => ((IMethodSymbol)member).Parameters,
+ SymbolKind.Property => ((IPropertySymbol)member).Parameters,
+ _ => ImmutableArray.Empty,
+ };
}
}
}
diff --git a/src/Utilities/Compiler/Extensions/IOperationExtensions.cs b/src/Utilities/Compiler/Extensions/IOperationExtensions.cs
index c875b216f5..5e9f1e7ade 100644
--- a/src/Utilities/Compiler/Extensions/IOperationExtensions.cs
+++ b/src/Utilities/Compiler/Extensions/IOperationExtensions.cs
@@ -532,32 +532,21 @@ public static bool IsWithinLambdaOrLocalFunction(this IOperation operation)
public static ITypeSymbol GetPatternType(this IPatternOperation pattern)
{
- switch (pattern)
+ return pattern switch
{
- case IDeclarationPatternOperation declarationPattern:
- switch (declarationPattern.DeclaredSymbol)
- {
- case ILocalSymbol local:
- return local.Type;
+ IDeclarationPatternOperation declarationPattern => declarationPattern.DeclaredSymbol switch
+ {
+ ILocalSymbol local => local.Type,
- case IDiscardSymbol discard:
- return discard.Type;
+ IDiscardSymbol discard => discard.Type,
- default:
- // TODO use the new IOperation API 'IDeclarationPatternOperation.MatchedType' when we move the repo
- // to use Microsoft.CodeAnalysis 3.0 or greater.
- return null;
- }
+ _ => null,
+ },
- case IConstantPatternOperation constantPattern:
- return constantPattern.Value.Type;
+ IConstantPatternOperation constantPattern => constantPattern.Value.Type,
- default:
- // Below assert fires for IDiscardPatternOperation.
- // https://github.com/dotnet/roslyn-analyzers/issues/2185 tracks enabling this assert.
- //Debug.Fail($"Unhandled pattern kind '{pattern.Kind}'");
- return null;
- }
+ _ => null,
+ };
}
///
@@ -612,26 +601,20 @@ public static SyntaxNode GetInstance(this IInvocationOperation invocationOperati
public static ISymbol GetReferencedMemberOrLocalOrParameter(this IOperation operation)
{
- switch (operation)
+ return operation switch
{
- case IMemberReferenceOperation memberReference:
- return memberReference.Member;
+ IMemberReferenceOperation memberReference => memberReference.Member,
- case IParameterReferenceOperation parameterReference:
- return parameterReference.Parameter;
+ IParameterReferenceOperation parameterReference => parameterReference.Parameter,
- case ILocalReferenceOperation localReference:
- return localReference.Local;
+ ILocalReferenceOperation localReference => localReference.Local,
- case IParenthesizedOperation parenthesized:
- return parenthesized.Operand.GetReferencedMemberOrLocalOrParameter();
+ IParenthesizedOperation parenthesized => parenthesized.Operand.GetReferencedMemberOrLocalOrParameter(),
- case IConversionOperation conversion:
- return conversion.Operand.GetReferencedMemberOrLocalOrParameter();
+ IConversionOperation conversion => conversion.Operand.GetReferencedMemberOrLocalOrParameter(),
- default:
- return null;
- }
+ _ => null,
+ };
}
///
diff --git a/src/Utilities/Compiler/Extensions/ISymbolExtensions.cs b/src/Utilities/Compiler/Extensions/ISymbolExtensions.cs
index 7a048c8979..482b8c7387 100644
--- a/src/Utilities/Compiler/Extensions/ISymbolExtensions.cs
+++ b/src/Utilities/Compiler/Extensions/ISymbolExtensions.cs
@@ -555,20 +555,16 @@ public static ISymbol GetOverriddenMember(this ISymbol symbol)
Debug.Assert(symbol != null);
Debug.Assert(symbol.IsOverride);
- switch (symbol)
+ return symbol switch
{
- case IMethodSymbol methodSymbol:
- return methodSymbol.OverriddenMethod;
+ IMethodSymbol methodSymbol => methodSymbol.OverriddenMethod,
- case IPropertySymbol propertySymbol:
- return propertySymbol.OverriddenProperty;
+ IPropertySymbol propertySymbol => propertySymbol.OverriddenProperty,
- case IEventSymbol eventSymbol:
- return eventSymbol.OverriddenEvent;
+ IEventSymbol eventSymbol => eventSymbol.OverriddenEvent,
- default:
- throw new NotImplementedException();
- }
+ _ => throw new NotImplementedException(),
+ };
}
///
@@ -596,53 +592,42 @@ public static bool IsImplementationOfAnyExplicitInterfaceMember(this ISymbol sym
public static ITypeSymbol GetMemberOrLocalOrParameterType(this ISymbol symbol)
{
- switch (symbol.Kind)
+ return symbol.Kind switch
{
- case SymbolKind.Local:
- return ((ILocalSymbol)symbol).Type;
+ SymbolKind.Local => ((ILocalSymbol)symbol).Type,
- case SymbolKind.Parameter:
- return ((IParameterSymbol)symbol).Type;
+ SymbolKind.Parameter => ((IParameterSymbol)symbol).Type,
- default:
- return GetMemberType(symbol);
- }
+ _ => GetMemberType(symbol),
+ };
}
public static ITypeSymbol GetMemberType(this ISymbol symbol)
{
- switch (symbol.Kind)
+ return symbol.Kind switch
{
- case SymbolKind.Event:
- return ((IEventSymbol)symbol).Type;
+ SymbolKind.Event => ((IEventSymbol)symbol).Type,
- case SymbolKind.Field:
- return ((IFieldSymbol)symbol).Type;
+ SymbolKind.Field => ((IFieldSymbol)symbol).Type,
- case SymbolKind.Method:
- return ((IMethodSymbol)symbol).ReturnType;
+ SymbolKind.Method => ((IMethodSymbol)symbol).ReturnType,
- case SymbolKind.Property:
- return ((IPropertySymbol)symbol).Type;
+ SymbolKind.Property => ((IPropertySymbol)symbol).Type,
- default:
- return null;
- }
+ _ => null,
+ };
}
public static bool IsReadOnlyFieldOrProperty(this ISymbol symbol)
{
- switch (symbol)
+ return symbol switch
{
- case IFieldSymbol field:
- return field.IsReadOnly;
+ IFieldSymbol field => field.IsReadOnly,
- case IPropertySymbol property:
- return property.IsReadOnly;
+ IPropertySymbol property => property.IsReadOnly,
- default:
- return false;
- }
+ _ => false,
+ };
}
///
@@ -690,35 +675,29 @@ public static bool IsSymbolWithSpecialDiscardName(this ISymbol symbol)
public static bool IsConst(this ISymbol symbol)
{
- switch (symbol)
+ return symbol switch
{
- case IFieldSymbol field:
- return field.IsConst;
+ IFieldSymbol field => field.IsConst,
- case ILocalSymbol local:
- return local.IsConst;
+ ILocalSymbol local => local.IsConst,
- default:
- return false;
- }
+ _ => false,
+ };
}
public static bool IsReadOnly(this ISymbol symbol)
{
- switch (symbol)
+ return symbol switch
{
- case IFieldSymbol field:
- return field.IsReadOnly;
+ IFieldSymbol field => field.IsReadOnly,
- case IPropertySymbol property:
- return property.IsReadOnly;
+ IPropertySymbol property => property.IsReadOnly,
// TODO: IMethodSymbol and ITypeSymbol also have IsReadOnly in Microsoft.CodeAnalysis 3.x
// Add these cases once we move to the required Microsoft.CodeAnalysis.nupkg.
- default:
- return false;
- }
+ _ => false,
+ };
}
}
}
diff --git a/src/Utilities/Compiler/Extensions/SymbolVisibility.cs b/src/Utilities/Compiler/Extensions/SymbolVisibility.cs
index 66df7d6a9d..c859efc826 100644
--- a/src/Utilities/Compiler/Extensions/SymbolVisibility.cs
+++ b/src/Utilities/Compiler/Extensions/SymbolVisibility.cs
@@ -26,35 +26,27 @@ internal static class SymbolVisibilityExtensions
///
public static bool IsAtLeastAsVisibleAs(this SymbolVisibility typeVisibility, SymbolVisibility comparisonVisibility)
{
- switch (typeVisibility)
+ return typeVisibility switch
{
- case SymbolVisibility.Public:
- return true;
- case SymbolVisibility.Internal:
- return comparisonVisibility != SymbolVisibility.Public;
- case SymbolVisibility.Private:
- return comparisonVisibility == SymbolVisibility.Private;
- default:
- throw new ArgumentOutOfRangeException(nameof(typeVisibility), typeVisibility, null);
- }
+ SymbolVisibility.Public => true,
+ SymbolVisibility.Internal => comparisonVisibility != SymbolVisibility.Public,
+ SymbolVisibility.Private => comparisonVisibility == SymbolVisibility.Private,
+ _ => throw new ArgumentOutOfRangeException(nameof(typeVisibility), typeVisibility, null),
+ };
}
public static SymbolVisibilityGroup ToSymbolVisibilityGroup(this SymbolVisibility symbolVisibility)
{
- switch (symbolVisibility)
+ return symbolVisibility switch
{
- case SymbolVisibility.Public:
- return SymbolVisibilityGroup.Public;
+ SymbolVisibility.Public => SymbolVisibilityGroup.Public,
- case SymbolVisibility.Internal:
- return SymbolVisibilityGroup.Internal;
+ SymbolVisibility.Internal => SymbolVisibilityGroup.Internal,
- case SymbolVisibility.Private:
- return SymbolVisibilityGroup.Private;
+ SymbolVisibility.Private => SymbolVisibilityGroup.Private,
- default:
- throw new ArgumentOutOfRangeException(nameof(symbolVisibility), symbolVisibility, null);
- }
+ _ => throw new ArgumentOutOfRangeException(nameof(symbolVisibility), symbolVisibility, null),
+ };
}
}
}
\ No newline at end of file
diff --git a/src/Utilities/Compiler/Options/SymbolVisibilityGroup.cs b/src/Utilities/Compiler/Options/SymbolVisibilityGroup.cs
index b3dfbe9288..5903f091c3 100644
--- a/src/Utilities/Compiler/Options/SymbolVisibilityGroup.cs
+++ b/src/Utilities/Compiler/Options/SymbolVisibilityGroup.cs
@@ -28,20 +28,16 @@ internal static class SymbolVisibilityGroupExtensions
{
public static bool Contains(this SymbolVisibilityGroup symbolVisibilityGroup, SymbolVisibility symbolVisibility)
{
- switch (symbolVisibility)
+ return symbolVisibility switch
{
- case SymbolVisibility.Public:
- return (symbolVisibilityGroup & SymbolVisibilityGroup.Public) != 0;
+ SymbolVisibility.Public => (symbolVisibilityGroup & SymbolVisibilityGroup.Public) != 0,
- case SymbolVisibility.Internal:
- return (symbolVisibilityGroup & SymbolVisibilityGroup.Internal) != 0;
+ SymbolVisibility.Internal => (symbolVisibilityGroup & SymbolVisibilityGroup.Internal) != 0,
- case SymbolVisibility.Private:
- return (symbolVisibilityGroup & SymbolVisibilityGroup.Private) != 0;
+ SymbolVisibility.Private => (symbolVisibilityGroup & SymbolVisibilityGroup.Private) != 0,
- default:
- throw new ArgumentOutOfRangeException(nameof(symbolVisibility), symbolVisibility, null);
- }
+ _ => throw new ArgumentOutOfRangeException(nameof(symbolVisibility), symbolVisibility, null),
+ };
}
}
}
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAbstractValue.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAbstractValue.cs
index a60b2f6714..32cacb426c 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAbstractValue.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAbstractValue.cs
@@ -7,8 +7,6 @@
using System.Linq;
using Analyzer.Utilities;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - CacheBasedEquatable handles equality
-
namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.CopyAnalysis
{
///
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAnalysisContext.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAnalysisContext.cs
index 4d6007628e..4ab10b9ac9 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAnalysisContext.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAnalysisContext.cs
@@ -5,8 +5,6 @@
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis;
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable
-
namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.CopyAnalysis
{
using CopyAnalysisResult = DataFlowAnalysisResult;
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAbstractValue.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAbstractValue.cs
index 8310a30969..4a0a0a2d1f 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAbstractValue.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAbstractValue.cs
@@ -5,8 +5,6 @@
using System.Diagnostics;
using Analyzer.Utilities;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - CacheBasedEquatable handles equality
-
namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.DisposeAnalysis
{
///
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.DisposeDataFlowOperationVisitor.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.DisposeDataFlowOperationVisitor.cs
index 7b62bbb9db..1dfdee42af 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.DisposeDataFlowOperationVisitor.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysis.DisposeDataFlowOperationVisitor.cs
@@ -384,19 +384,16 @@ bool IsDisposeOwnershipTransfer()
return false;
}
- switch (operation.Parent)
+ return operation.Parent switch
{
- case IObjectCreationOperation _:
- return DisposeOwnershipTransferAtConstructor ||
- DisposeOwnershipTransferLikelyTypes.Contains(operation.Parameter.Type);
+ IObjectCreationOperation _ => DisposeOwnershipTransferAtConstructor ||
+ DisposeOwnershipTransferLikelyTypes.Contains(operation.Parameter.Type),
- case IInvocationOperation invocation:
- return DisposeOwnershipTransferAtMethodCall ||
- IsDisposableCreationSpecialCase(invocation.TargetMethod) && DisposeOwnershipTransferLikelyTypes.Contains(operation.Parameter.Type);
+ IInvocationOperation invocation => DisposeOwnershipTransferAtMethodCall ||
+ IsDisposableCreationSpecialCase(invocation.TargetMethod) && DisposeOwnershipTransferLikelyTypes.Contains(operation.Parameter.Type),
- default:
- return false;
- }
+ _ => false,
+ };
}
}
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisContext.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisContext.cs
index 6b53c4adc4..12ea7aef74 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisContext.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/DisposeAnalysis/DisposeAnalysisContext.cs
@@ -9,8 +9,6 @@
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis;
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable
-
namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.DisposeAnalysis
{
using CopyAnalysisResult = DataFlowAnalysisResult;
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ParameterValidationAnalysis/ParameterValidationAnalysis.ParameterValidationDataFlowOperationVisitor.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ParameterValidationAnalysis/ParameterValidationAnalysis.ParameterValidationDataFlowOperationVisitor.cs
index 0876a72593..52074dd3cd 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ParameterValidationAnalysis/ParameterValidationAnalysis.ParameterValidationDataFlowOperationVisitor.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ParameterValidationAnalysis/ParameterValidationAnalysis.ParameterValidationDataFlowOperationVisitor.cs
@@ -150,19 +150,16 @@ private static bool IsHazardousIfNull(IOperation operation)
return false;
}
- switch (operation.Parent)
+ return operation.Parent switch
{
- case IMemberReferenceOperation memberReference:
- return memberReference.Instance == operation;
+ IMemberReferenceOperation memberReference => memberReference.Instance == operation,
- case IArrayElementReferenceOperation arrayElementReference:
- return arrayElementReference.ArrayReference == operation;
+ IArrayElementReferenceOperation arrayElementReference => arrayElementReference.ArrayReference == operation,
- case IInvocationOperation invocation:
- return invocation.Instance == operation;
- }
+ IInvocationOperation invocation => invocation.Instance == operation,
- return false;
+ _ => false,
+ };
}
private void HandlePotentiallyHazardousOperation(IOperation operation, IEnumerable nonValidatedLocations)
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ParameterValidationAnalysis/ParameterValidationAnalysisContext.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ParameterValidationAnalysis/ParameterValidationAnalysisContext.cs
index 47f58350ef..a0a378d865 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ParameterValidationAnalysis/ParameterValidationAnalysisContext.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ParameterValidationAnalysis/ParameterValidationAnalysisContext.cs
@@ -8,8 +8,6 @@
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis;
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable
-
namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ParameterValidationAnalysis
{
using CopyAnalysisResult = DataFlowAnalysisResult;
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAbstractValue.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAbstractValue.cs
index 30f2901dcc..d66a8de1ae 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAbstractValue.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAbstractValue.cs
@@ -6,8 +6,6 @@
using System.Diagnostics;
using System.Linq;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - CacheBasedEquatable handles equality
-
namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis
{
///
@@ -97,17 +95,14 @@ internal static PointsToAbstractValue Create(ImmutableHashSet
}
else if (locations.Count > LocationThreshold)
{
- switch (nullState)
+ return nullState switch
{
- case NullAbstractValue.Null:
- return UnknownNull;
+ NullAbstractValue.Null => UnknownNull,
- case NullAbstractValue.NotNull:
- return UnknownNotNull;
+ NullAbstractValue.NotNull => UnknownNotNull,
- default:
- return Unknown;
- }
+ _ => Unknown,
+ };
}
return new PointsToAbstractValue(locations, nullState);
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAnalysis.PointsToDataFlowOperationVisitor.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAnalysis.PointsToDataFlowOperationVisitor.cs
index f12b6e7c7b..a3e1df3404 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAnalysis.PointsToDataFlowOperationVisitor.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAnalysis.PointsToDataFlowOperationVisitor.cs
@@ -227,24 +227,16 @@ private static void ResetAbstractValueIfTracked(AnalysisEntity analysisEntity, P
existingValue = defaultPointsToValueGenerator.GetOrCreateDefaultValue(analysisEntity);
}
- PointsToAbstractValue newPointsToValue;
- switch (nullState)
+ var newPointsToValue = nullState switch
{
- case NullAbstractValue.Null:
- newPointsToValue = existingValue.MakeNull();
- break;
+ NullAbstractValue.Null => existingValue.MakeNull(),
- case NullAbstractValue.NotNull:
- newPointsToValue = existingValue.MakeNonNull();
- break;
+ NullAbstractValue.NotNull => existingValue.MakeNonNull(),
- case NullAbstractValue.Invalid:
- newPointsToValue = PointsToAbstractValue.Invalid;
- break;
+ NullAbstractValue.Invalid => PointsToAbstractValue.Invalid,
- default:
- throw new InvalidProgramException();
- }
+ _ => throw new InvalidProgramException(),
+ };
targetAnalysisData.SetAbstractValue(analysisEntity, newPointsToValue);
AssertValidPointsToAnalysisData(targetAnalysisData);
@@ -514,17 +506,14 @@ private static NullAbstractValue NegatePredicateValue(NullAbstractValue value)
{
Debug.Assert(IsValidValueForPredicateAnalysis(value));
- switch (value)
+ return value switch
{
- case NullAbstractValue.Null:
- return NullAbstractValue.NotNull;
+ NullAbstractValue.Null => NullAbstractValue.NotNull,
- case NullAbstractValue.NotNull:
- return NullAbstractValue.Null;
+ NullAbstractValue.NotNull => NullAbstractValue.Null,
- default:
- throw new InvalidProgramException();
- }
+ _ => throw new InvalidProgramException(),
+ };
}
#endregion
@@ -983,20 +972,16 @@ private NullAbstractValue GetNullStateBasedOnInstanceOrReferenceValue(IOperation
private PointsToAbstractValue GetValueBasedOnInstanceOrReferenceValue(IOperation referenceOrInstance, IOperation operation, PointsToAbstractValue defaultValue)
{
NullAbstractValue nullState = GetNullStateBasedOnInstanceOrReferenceValue(referenceOrInstance, operation.Type, defaultValue.NullState);
- switch (nullState)
+ return nullState switch
{
- case NullAbstractValue.NotNull:
- return defaultValue.MakeNonNull();
+ NullAbstractValue.NotNull => defaultValue.MakeNonNull(),
- case NullAbstractValue.Null:
- return defaultValue.MakeNull();
+ NullAbstractValue.Null => defaultValue.MakeNull(),
- case NullAbstractValue.Invalid:
- return PointsToAbstractValue.Invalid;
+ NullAbstractValue.Invalid => PointsToAbstractValue.Invalid,
- default:
- return defaultValue;
- }
+ _ => defaultValue,
+ };
}
public override PointsToAbstractValue VisitFieldReference(IFieldReferenceOperation operation, object argument)
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAnalysisContext.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAnalysisContext.cs
index 7e64b2de71..62ae85b5d9 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAnalysisContext.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAnalysisContext.cs
@@ -6,8 +6,6 @@
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.CopyAnalysis;
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable
-
namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis
{
using CopyAnalysisResult = DataFlowAnalysisResult;
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisContext.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisContext.cs
index a517c4af3f..2552ae6d61 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisContext.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisContext.cs
@@ -11,8 +11,6 @@
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis;
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable
-
namespace Analyzer.Utilities.FlowAnalysis.Analysis.PropertySetAnalysis
{
using CopyAnalysisResult = DataFlowAnalysisResult;
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetCallbacks.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetCallbacks.cs
index c8b0ac38e8..6d50e440f0 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetCallbacks.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetCallbacks.cs
@@ -22,20 +22,16 @@ internal static class PropertySetCallbacks
/// Flagged if null, Unflagged if not null, MaybeFlagged otherwise.
public static PropertySetAbstractValueKind FlagIfNull(PointsToAbstractValue pointsToAbstractValue)
{
- switch (pointsToAbstractValue.NullState)
+ return pointsToAbstractValue.NullState switch
{
- case NullAbstractValue.Null:
- return PropertySetAbstractValueKind.Flagged;
+ NullAbstractValue.Null => PropertySetAbstractValueKind.Flagged,
- case NullAbstractValue.NotNull:
- return PropertySetAbstractValueKind.Unflagged;
+ NullAbstractValue.NotNull => PropertySetAbstractValueKind.Unflagged,
- case NullAbstractValue.MaybeNull:
- return PropertySetAbstractValueKind.MaybeFlagged;
+ NullAbstractValue.MaybeNull => PropertySetAbstractValueKind.MaybeFlagged,
- default:
- return PropertySetAbstractValueKind.Unknown;
- }
+ _ => PropertySetAbstractValueKind.Unknown,
+ };
}
///
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/SymbolAccess.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/SymbolAccess.cs
index 5f1f355de4..4b508da744 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/SymbolAccess.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/SymbolAccess.cs
@@ -6,8 +6,6 @@
namespace Analyzer.Utilities.FlowAnalysis.Analysis.TaintedDataAnalysis
{
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable
-
///
/// Represents an access to a symbol.
///
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataAbstractValue.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataAbstractValue.cs
index 31bfbffcc8..938bc1a87b 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataAbstractValue.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataAbstractValue.cs
@@ -10,8 +10,6 @@
namespace Analyzer.Utilities.FlowAnalysis.Analysis.TaintedDataAnalysis
{
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable
-
///
/// Abstract tainted data value shared by a set of one of more instances tracked by .
///
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataAnalysisContext.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataAnalysisContext.cs
index eafc298d20..85294b2bcb 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataAnalysisContext.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataAnalysisContext.cs
@@ -10,8 +10,6 @@
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis;
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable
-
namespace Analyzer.Utilities.FlowAnalysis.Analysis.TaintedDataAnalysis
{
using CopyAnalysisResult = DataFlowAnalysisResult;
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataSymbolMapExtensions.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataSymbolMapExtensions.cs
index e4d011b619..5c596c5796 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataSymbolMapExtensions.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataSymbolMapExtensions.cs
@@ -198,16 +198,16 @@ out PooledHashSet<(string, string)> taintedParameterPairs)
taintedParameterPairs = null;
foreach (SourceInfo sourceInfo in sourceSymbolMap.GetInfosForType(method.ContainingType))
{
- foreach ((MethodMatcher methodMatcher, ImmutableHashSet<(string source, string end)> sourceToEnds) passerMethod in sourceInfo.TransferMethods)
+ foreach ((MethodMatcher methodMatcher, ImmutableHashSet<(string source, string end)> sourceToEnds) in sourceInfo.TransferMethods)
{
- if (passerMethod.methodMatcher(method.Name, arguments))
+ if (methodMatcher(method.Name, arguments))
{
if (taintedParameterPairs == null)
{
taintedParameterPairs = PooledHashSet<(string, string)>.GetInstance();
}
- taintedParameterPairs.UnionWith(passerMethod.sourceToEnds.Where(s => taintedParameterNames.Contains(s.source)));
+ taintedParameterPairs.UnionWith(sourceToEnds.Where(s => taintedParameterNames.Contains(s.source)));
}
}
}
diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAbstractValue.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAbstractValue.cs
index cf77bbc140..499089e6b4 100644
--- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAbstractValue.cs
+++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAbstractValue.cs
@@ -10,8 +10,6 @@
using Analyzer.Utilities.PooledObjects;
using Microsoft.CodeAnalysis.Operations;
-#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable
-
namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis
{
///
@@ -82,17 +80,13 @@ private static ValueContentAbstractValue Create(ImmutableHashSet