From 3b458b2541858ede33e5edb2c3a332e0af7a92d1 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 11 Sep 2019 05:43:24 -0700 Subject: [PATCH 1/7] Update Versions.props --- eng/Versions.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 7229609f39..c7607f7416 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -4,7 +4,7 @@ 2.9.5 2.9.6 - beta1 + beta2 true @@ -21,7 +21,7 @@ 2.9.0 3.0.0 - 2.9.4 + 2.9.5-beta1.final 3.0.0-beta2.19218.3+e96bad97 2.11.0-beta2-63603-03 2.0.0-pre-20160714 From 549dcc5e9ad361208639510fc3ade11674843ad9 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 11 Sep 2019 05:45:14 -0700 Subject: [PATCH 2/7] Update Versioning.md --- VERSIONING.md | 1 + 1 file changed, 1 insertion(+) 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 From 8c63820db2f9089f507aeead792d5eef8d5de60b Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 11 Sep 2019 05:46:49 -0700 Subject: [PATCH 3/7] Remove unnecessary usings --- .../Core/ApiDesignGuidelines/EnumStorageShouldBeInt32.Fixer.cs | 1 - .../Core/ApiDesignGuidelines/ExceptionsShouldBePublic.Fixer.cs | 1 - .../OverloadOperatorEqualsOnOverridingValueTypeEquals.Fixer.cs | 1 - .../OverrideEqualsOnOverloadingOperatorEquals.Fixer.cs | 1 - .../OverrideGetHashCodeOnOverridingEquals.Fixer.cs | 1 - .../OverrideMethodsOnComparableTypes.Fixer.cs | 1 - .../Core/Maintainability/AvoidUnusedPrivateFields.Fixer.cs | 1 - .../Core/QualityGuidelines/RemoveEmptyFinalizers.Fixer.cs | 1 - .../Core/QualityGuidelines/UseLiteralsWhereAppropriate.Fixer.cs | 1 - .../SpecifyMarshalingForPInvokeStringArguments.Fixer.cs | 1 - .../Core/Runtime/AvoidUnsealedAttributes.Fixer.cs | 1 - .../Core/Runtime/MarkISerializableTypesWithSerializable.Fixer.cs | 1 - .../Core/Runtime/TestForNaNCorrectly.Fixer.cs | 1 - .../Core/Runtime/UseOrdinalStringComparison.Fixer.cs | 1 - 14 files changed, 14 deletions(-) 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/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/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.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; From e3e748da5748e2cd20f5127b7dbabac6b8abbfc0 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 11 Sep 2019 05:47:19 -0700 Subject: [PATCH 4/7] Remove CA1067 suppressions which are no longer required --- .../FlowAnalysis/Analysis/CopyAnalysis/CopyAbstractValue.cs | 2 -- .../FlowAnalysis/Analysis/CopyAnalysis/CopyAnalysisContext.cs | 2 -- .../Analysis/DisposeAnalysis/DisposeAbstractValue.cs | 2 -- .../Analysis/DisposeAnalysis/DisposeAnalysisContext.cs | 2 -- .../ParameterValidationAnalysisContext.cs | 2 -- .../Analysis/PointsToAnalysis/PointsToAbstractValue.cs | 2 -- .../Analysis/PointsToAnalysis/PointsToAnalysisContext.cs | 2 -- .../Analysis/PropertySetAnalysis/PropertySetAnalysisContext.cs | 2 -- .../FlowAnalysis/Analysis/TaintedDataAnalysis/SymbolAccess.cs | 2 -- .../Analysis/TaintedDataAnalysis/TaintedDataAbstractValue.cs | 2 -- .../Analysis/TaintedDataAnalysis/TaintedDataAnalysisContext.cs | 2 -- .../Analysis/ValueContentAnalysis/ValueContentAbstractValue.cs | 2 -- .../ValueContentAnalysis/ValueContentAnalysisContext.cs | 2 -- .../Framework/DataFlow/AbstractIndex.ConstantValueIndex.cs | 3 --- .../Framework/DataFlow/AbstractIndex.OperationBasedIndex.cs | 2 -- .../Framework/DataFlow/AbstractIndex.SymbolBasedIndex.cs | 2 -- .../FlowAnalysis/Framework/DataFlow/AbstractIndex.cs | 2 -- .../FlowAnalysis/Framework/DataFlow/AbstractLocation.cs | 2 -- .../FlowAnalysis/Framework/DataFlow/AnalysisEntity.cs | 2 -- .../FlowAnalysis/Framework/DataFlow/ArgumentInfo.cs | 2 -- .../FlowAnalysis/Framework/DataFlow/DictionaryAnalysisData.cs | 1 - .../Framework/DataFlow/InterproceduralAnalysisData.cs | 2 -- 22 files changed, 44 deletions(-) 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/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/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..992606ce64 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 { /// 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/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/ValueContentAnalysis/ValueContentAbstractValue.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAbstractValue.cs index bb54585374..381ea6f78b 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 { /// diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAnalysisContext.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAnalysisContext.cs index 9d236726e1..5e918cdba0 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAnalysisContext.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAnalysisContext.cs @@ -6,8 +6,6 @@ using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.CopyAnalysis; using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis; -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.ValueContentAnalysis { using CopyAnalysisResult = DataFlowAnalysisResult; diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.ConstantValueIndex.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.ConstantValueIndex.cs index 9088e4be30..6259cb739e 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.ConstantValueIndex.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.ConstantValueIndex.cs @@ -1,7 +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. -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - using System; namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow @@ -17,7 +15,6 @@ public ConstantValueIndex(int index) public int Index { get; } -#pragma warning disable CA1307 // Specify StringComparison - string.GetHashCode(StringComparison) not available in all projects that reference this shared project protected override void ComputeHashCodeParts(Action addPart) { addPart(Index.GetHashCode()); diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.OperationBasedIndex.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.OperationBasedIndex.cs index 5af242f87f..e4d295a453 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.OperationBasedIndex.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.OperationBasedIndex.cs @@ -3,8 +3,6 @@ using System; using System.Diagnostics; -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - CacheBasedEquatable handles equality - namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow { public abstract partial class AbstractIndex diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.SymbolBasedIndex.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.SymbolBasedIndex.cs index a3749202d0..6107f6118b 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.SymbolBasedIndex.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.SymbolBasedIndex.cs @@ -1,7 +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. -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - CacheBasedEquatable handles equality - using System; namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.cs index 207940d94b..938bb670ab 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.cs @@ -1,7 +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. -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - CacheBasedEquatable handles equality - namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow { /// diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractLocation.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractLocation.cs index d4e19dcf21..54fdd48716 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractLocation.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractLocation.cs @@ -8,8 +8,6 @@ using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis; using Microsoft.CodeAnalysis.Operations; -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow { /// diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AnalysisEntity.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AnalysisEntity.cs index 5fe7b1a72d..78b448d2e6 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AnalysisEntity.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AnalysisEntity.cs @@ -10,8 +10,6 @@ using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis; using Microsoft.CodeAnalysis.Operations; -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - CacheBasedEquatable handles equality - namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow { /// diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/ArgumentInfo.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/ArgumentInfo.cs index 404cd76dc5..b77326f464 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/ArgumentInfo.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/ArgumentInfo.cs @@ -4,8 +4,6 @@ using Analyzer.Utilities; using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis; -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow { /// diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DictionaryAnalysisData.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DictionaryAnalysisData.cs index 221783414b..3e1209346d 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DictionaryAnalysisData.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DictionaryAnalysisData.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using Analyzer.Utilities.PooledObjects; -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable #pragma warning disable CA1710 // Rename DictionaryAnalysisData to end in 'Dictionary' namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/InterproceduralAnalysisData.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/InterproceduralAnalysisData.cs index 1eaa9b45ee..457c21170b 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/InterproceduralAnalysisData.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/InterproceduralAnalysisData.cs @@ -7,8 +7,6 @@ using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.CopyAnalysis; using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis; -#pragma warning disable CA1067 // Override Object.Equals(object) when implementing IEquatable - namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow { /// From 9312653e8456e91f455c640259f0f6e038a0c5e8 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 11 Sep 2019 06:16:30 -0700 Subject: [PATCH 5/7] Move to a newer CodeStyle analyzers package and apply code style suggestions (primarily usage of switch expressions) --- eng/Analyzers_NonShippingRules.ruleset | 4 + eng/Versions.props | 2 +- src/GenerateAnalyzerRulesets/Program.cs | 28 +-- ...ngKindArgumentToRegisterActionRuleTests.cs | 20 +- .../RestrictedInternalsVisibleToAnalyzer.cs | 36 +-- .../CSharpRemoveEmptyFinalizersAnalyzer.cs | 12 +- ...thodsShouldBeCallableByChildTypes.Fixer.cs | 16 +- ...orsShouldHaveSymmetricalOverloads.Fixer.cs | 19 +- .../Maintainability/CodeMetricsAnalyzer.cs | 19 +- ...tifiersShouldNotContainUnderscoresTests.cs | 31 +-- .../DoNotDisableHttpClientCRLCheck.cs | 36 ++- .../Core/Security/DoNotInstallRootCert.cs | 13 +- ...ascriptSerializerWithSimpleTypeResolver.cs | 13 +- ...NotUseWeakKDFInsufficientIterationCount.cs | 13 +- .../Security/UseSecureCookiesASPNetCore.cs | 13 +- ...DoNotUseCountWhenAnyCanBeUsedTests.Code.cs | 40 +-- src/ReleaseNotesUtil/Program.cs | 10 +- .../PropertySetAnalysisTests.cs | 230 +++++++----------- .../CodeMetrics/CodeAnalysisMetricData.cs | 28 +-- .../Compiler/CodeMetrics/MetricsHelper.cs | 13 +- .../Extensions/IOperationExtensions.cs | 53 ++-- .../Compiler/Extensions/ISymbolExtensions.cs | 87 +++---- .../Compiler/Extensions/SymbolVisibility.cs | 32 +-- .../Compiler/Options/SymbolVisibilityGroup.cs | 16 +- ...nalysis.DisposeDataFlowOperationVisitor.cs | 17 +- ...meterValidationDataFlowOperationVisitor.cs | 15 +- .../PointsToAnalysis/PointsToAbstractValue.cs | 13 +- ...alysis.PointsToDataFlowOperationVisitor.cs | 49 ++-- .../PropertySetCallbacks.cs | 16 +- .../TaintedDataSymbolMapExtensions.cs | 6 +- .../ValueContentAbstractValue.cs | 16 +- ...is.ValueContentDataFlowOperationVisitor.cs | 13 +- .../Framework/DataFlow/AbstractLocation.cs | 17 +- .../Framework/DataFlow/AnalysisEntity.cs | 13 +- .../DataFlow/DataFlowOperationVisitor.cs | 12 +- 35 files changed, 369 insertions(+), 602 deletions(-) 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 c7607f7416..80f0da104c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -23,7 +23,7 @@ 3.0.0 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/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/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/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/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 4567b1f5d9..bd616413e7 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 16b987191e..8b89e95d23 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/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/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/PointsToAnalysis/PointsToAbstractValue.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAbstractValue.cs index 992606ce64..d66a8de1ae 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAbstractValue.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PointsToAnalysis/PointsToAbstractValue.cs @@ -95,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/PropertySetAnalysis/PropertySetCallbacks.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetCallbacks.cs index d68a75e2bb..092cc477a4 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/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 381ea6f78b..a0c71d31ea 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAbstractValue.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAbstractValue.cs @@ -77,17 +77,13 @@ private static ValueContentAbstractValue Create(ImmutableHashSet literal { if (literalValues.IsEmpty) { - switch (nonLiteralState) + return nonLiteralState switch { - case ValueContainsNonLiteralState.Undefined: - return UndefinedState; - case ValueContainsNonLiteralState.Invalid: - return InvalidState; - case ValueContainsNonLiteralState.No: - return DoesNotContainLiteralOrNonLiteralState; - default: - return MayBeContainsNonLiteralState; - } + ValueContainsNonLiteralState.Undefined => UndefinedState, + ValueContainsNonLiteralState.Invalid => InvalidState, + ValueContainsNonLiteralState.No => DoesNotContainLiteralOrNonLiteralState, + _ => MayBeContainsNonLiteralState, + }; } else if (literalValues.Count == 1 && nonLiteralState == ValueContainsNonLiteralState.No) { diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAnalysis.ValueContentDataFlowOperationVisitor.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAnalysis.ValueContentDataFlowOperationVisitor.cs index 83fd91230a..1b10696cfd 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAnalysis.ValueContentDataFlowOperationVisitor.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/ValueContentAnalysis/ValueContentAnalysis.ValueContentDataFlowOperationVisitor.cs @@ -169,17 +169,14 @@ public override ValueContentAbstractValue DefaultVisit(IOperation operation, obj } else { - switch (GetNullAbstractValue(operation)) + return (GetNullAbstractValue(operation)) switch { - case PointsToAnalysis.NullAbstractValue.Invalid: - return ValueContentAbstractValue.InvalidState; + PointsToAnalysis.NullAbstractValue.Invalid => ValueContentAbstractValue.InvalidState, - case PointsToAnalysis.NullAbstractValue.Null: - return ValueContentAbstractValue.DoesNotContainLiteralOrNonLiteralState; + PointsToAnalysis.NullAbstractValue.Null => ValueContentAbstractValue.DoesNotContainLiteralOrNonLiteralState, - default: - return ValueContentAbstractValue.MayBeContainsNonLiteralState; - } + _ => ValueContentAbstractValue.MayBeContainsNonLiteralState, + }; } } diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractLocation.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractLocation.cs index 54fdd48716..a320024512 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractLocation.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractLocation.cs @@ -140,21 +140,14 @@ public SyntaxNode TryGetNodeToReportDiagnostic(PointsToAnalysisResult pointsToAn SyntaxNode TryGetSyntaxNodeToReportDiagnostic(IOperation creation) { // If any of the argument to creation points to this location, then use the argument. - ImmutableArray arguments; - switch (creation) + var arguments = creation switch { - case IInvocationOperation invocation: - arguments = invocation.Arguments; - break; + IInvocationOperation invocation => invocation.Arguments, - case IObjectCreationOperation objectCreation: - arguments = objectCreation.Arguments; - break; + IObjectCreationOperation objectCreation => objectCreation.Arguments, - default: - arguments = ImmutableArray.Empty; - break; - } + _ => ImmutableArray.Empty, + }; foreach (var argument in arguments) { diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AnalysisEntity.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AnalysisEntity.cs index 78b448d2e6..ef64788607 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AnalysisEntity.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AnalysisEntity.cs @@ -171,17 +171,14 @@ public bool HasConstantValue { get { - switch (SymbolOpt) + return SymbolOpt switch { - case IFieldSymbol field: - return field.HasConstantValue; + IFieldSymbol field => field.HasConstantValue, - case ILocalSymbol local: - return local.HasConstantValue; + ILocalSymbol local => local.HasConstantValue, - default: - return false; - } + _ => false, + }; } } diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowOperationVisitor.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowOperationVisitor.cs index 1d38d7646b..930faaf855 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowOperationVisitor.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowOperationVisitor.cs @@ -638,16 +638,14 @@ bool isPredicateAlwaysFalseForBranch(PredicateValueKind predicateValueKind) { Debug.Assert(branch.ControlFlowConditionKind != ControlFlowConditionKind.None); - switch (predicateValueKind) + return predicateValueKind switch { - case PredicateValueKind.AlwaysFalse: - return branch.ControlFlowConditionKind == ControlFlowConditionKind.WhenTrue; + PredicateValueKind.AlwaysFalse => branch.ControlFlowConditionKind == ControlFlowConditionKind.WhenTrue, - case PredicateValueKind.AlwaysTrue: - return branch.ControlFlowConditionKind == ControlFlowConditionKind.WhenFalse; - } + PredicateValueKind.AlwaysTrue => branch.ControlFlowConditionKind == ControlFlowConditionKind.WhenFalse, - return false; + _ => false, + }; } } From 5fd13855ac8ac369527316a219f9b6da2b3dd01e Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 11 Sep 2019 06:18:51 -0700 Subject: [PATCH 6/7] Update issue template --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From d7a6b37d2c89f41133343cf73ffa72a04ae5bd5d Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 11 Sep 2019 06:56:49 -0700 Subject: [PATCH 7/7] Move to latest compiler toolset --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 80f0da104c..9a2a375a5c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -20,7 +20,7 @@ 2.9.0 - 3.0.0 + 3.3.1-beta3-final 2.9.5-beta1.final 3.0.0-beta2.19218.3+e96bad97 3.3.0-beta2-19376-02