diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/EnumWithFlagsAttribute.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/EnumWithFlagsAttribute.Fixer.cs index b5641fb619..d841fac6e1 100644 --- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/EnumWithFlagsAttribute.Fixer.cs +++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/EnumWithFlagsAttribute.Fixer.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Immutable; using System.Composition; -using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/ImplementStandardExceptionConstructors.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/ImplementStandardExceptionConstructors.cs index fc5ac15fd8..e59eded262 100644 --- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/ImplementStandardExceptionConstructors.cs +++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/ImplementStandardExceptionConstructors.cs @@ -130,7 +130,7 @@ private void AnalyzeCompilationSymbol(CompilationStartAnalysisContext context) private static void ReportDiagnostic(SymbolAnalysisContext context, INamedTypeSymbol namedTypeSymbol, MissingCtorSignature missingCtorSignature, string constructorSignature) { //store MissingCtorSignature enum type into dictionary, to set diagnostic property. This is needed because Diagnostic is immutable - ImmutableDictionary.Builder builder = ImmutableDictionary.CreateBuilder(); + ImmutableDictionary.Builder builder = ImmutableDictionary.CreateBuilder(); builder.Add("Signature", missingCtorSignature.ToString()); //create dignostic and store signature into diagnostic property for fixer diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/UseGenericEventHandlerInstances.cs b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/UseGenericEventHandlerInstances.cs index b653e4795f..8b6093b446 100644 --- a/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/UseGenericEventHandlerInstances.cs +++ b/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/UseGenericEventHandlerInstances.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Immutable; -using System.Diagnostics; using System.Linq; using Analyzer.Utilities; using Analyzer.Utilities.Extensions; diff --git a/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/UseNameofInPlaceOfString.Fixer.cs b/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/UseNameofInPlaceOfString.Fixer.cs index f147f5a72d..40f5281d68 100644 --- a/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/UseNameofInPlaceOfString.Fixer.cs +++ b/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/UseNameofInPlaceOfString.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.Collections.Immutable; -using System.Diagnostics; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; diff --git a/src/Microsoft.CodeQuality.Analyzers/VisualBasic/QualityGuidelines/BasicRemoveEmptyFinalizersAnalyzer.vb b/src/Microsoft.CodeQuality.Analyzers/VisualBasic/QualityGuidelines/BasicRemoveEmptyFinalizersAnalyzer.vb index a7ff4b3934..1c46ca2c33 100644 --- a/src/Microsoft.CodeQuality.Analyzers/VisualBasic/QualityGuidelines/BasicRemoveEmptyFinalizersAnalyzer.vb +++ b/src/Microsoft.CodeQuality.Analyzers/VisualBasic/QualityGuidelines/BasicRemoveEmptyFinalizersAnalyzer.vb @@ -1,4 +1,5 @@ -Imports Analyzer.Utilities +' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + Imports Analyzer.Utilities.Extensions Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Diagnostics diff --git a/src/Microsoft.NetCore.Analyzers/CSharp/Performance/CSharpUsePropertyInsteadOfCountMethodWhenAvailable.cs b/src/Microsoft.NetCore.Analyzers/CSharp/Performance/CSharpUsePropertyInsteadOfCountMethodWhenAvailable.cs index f33002576d..fd3d11876a 100644 --- a/src/Microsoft.NetCore.Analyzers/CSharp/Performance/CSharpUsePropertyInsteadOfCountMethodWhenAvailable.cs +++ b/src/Microsoft.NetCore.Analyzers/CSharp/Performance/CSharpUsePropertyInsteadOfCountMethodWhenAvailable.cs @@ -42,7 +42,7 @@ internal CSharpOperationActionsHandler(OperationActionsContext context) { } - protected override ITypeSymbol GetEnumerableCountInvocationTargetType(IInvocationOperation invocationOperation) + protected override ITypeSymbol? GetEnumerableCountInvocationTargetType(IInvocationOperation invocationOperation) { var method = invocationOperation.TargetMethod; diff --git a/src/Microsoft.NetCore.Analyzers/CSharp/Runtime/CSharpMarkAllNonSerializableFields.Fixer.cs b/src/Microsoft.NetCore.Analyzers/CSharp/Runtime/CSharpMarkAllNonSerializableFields.Fixer.cs index 117d2a3fb7..13e0d8d767 100644 --- a/src/Microsoft.NetCore.Analyzers/CSharp/Runtime/CSharpMarkAllNonSerializableFields.Fixer.cs +++ b/src/Microsoft.NetCore.Analyzers/CSharp/Runtime/CSharpMarkAllNonSerializableFields.Fixer.cs @@ -11,7 +11,7 @@ namespace Microsoft.NetCore.CSharp.Analyzers.Runtime [ExportCodeFixProvider(LanguageNames.CSharp, Name = "CA2237 CodeFix provider"), Shared] public class CSharpMarkAllNonSerializableFieldsFixer : MarkAllNonSerializableFieldsFixer { - protected override SyntaxNode GetFieldDeclarationNode(SyntaxNode node) + protected override SyntaxNode? GetFieldDeclarationNode(SyntaxNode node) { SyntaxNode fieldNode = node; while (fieldNode != null && fieldNode.Kind() != SyntaxKind.FieldDeclaration) diff --git a/src/Microsoft.NetCore.Analyzers/CSharp/Runtime/CSharpUseOrdinalStringComparison.cs b/src/Microsoft.NetCore.Analyzers/CSharp/Runtime/CSharpUseOrdinalStringComparison.cs index 82d0fadb6c..d2d1a8630e 100644 --- a/src/Microsoft.NetCore.Analyzers/CSharp/Runtime/CSharpUseOrdinalStringComparison.cs +++ b/src/Microsoft.NetCore.Analyzers/CSharp/Runtime/CSharpUseOrdinalStringComparison.cs @@ -16,7 +16,7 @@ protected override Location GetMethodNameLocation(SyntaxNode invocationNode) { Debug.Assert(invocationNode.IsKind(SyntaxKind.InvocationExpression)); - var invocation = invocationNode as InvocationExpressionSyntax; + var invocation = (InvocationExpressionSyntax)invocationNode; if (invocation.Expression.IsKind(SyntaxKind.SimpleMemberAccessExpression)) { return ((MemberAccessExpressionSyntax)invocation.Expression).Name.GetLocation(); diff --git a/src/Microsoft.NetCore.Analyzers/Core/Performance/UsePropertyInsteadOfCountMethodWhenAvailable.cs b/src/Microsoft.NetCore.Analyzers/Core/Performance/UsePropertyInsteadOfCountMethodWhenAvailable.cs index 0c424fda9a..cacae19be1 100644 --- a/src/Microsoft.NetCore.Analyzers/Core/Performance/UsePropertyInsteadOfCountMethodWhenAvailable.cs +++ b/src/Microsoft.NetCore.Analyzers/Core/Performance/UsePropertyInsteadOfCountMethodWhenAvailable.cs @@ -291,7 +291,7 @@ internal void AnalyzeInvocationOperation(OperationAnalysisContext context) /// /// The invocation operation. /// The of the receiver of the extension method. - protected abstract ITypeSymbol GetEnumerableCountInvocationTargetType(IInvocationOperation invocationOperation); + protected abstract ITypeSymbol? GetEnumerableCountInvocationTargetType(IInvocationOperation invocationOperation); /// /// Gets the replacement property. diff --git a/src/Microsoft.NetCore.Analyzers/Core/Runtime/MarkAllNonSerializableFields.Fixer.cs b/src/Microsoft.NetCore.Analyzers/Core/Runtime/MarkAllNonSerializableFields.Fixer.cs index 0f72d123e2..3a008b5bec 100644 --- a/src/Microsoft.NetCore.Analyzers/Core/Runtime/MarkAllNonSerializableFields.Fixer.cs +++ b/src/Microsoft.NetCore.Analyzers/Core/Runtime/MarkAllNonSerializableFields.Fixer.cs @@ -20,13 +20,13 @@ public abstract class MarkAllNonSerializableFieldsFixer : CodeFixProvider { public override ImmutableArray FixableDiagnosticIds => ImmutableArray.Create(SerializationRulesDiagnosticAnalyzer.RuleCA2235Id); - protected abstract SyntaxNode GetFieldDeclarationNode(SyntaxNode node); + protected abstract SyntaxNode? GetFieldDeclarationNode(SyntaxNode node); public override async Task RegisterCodeFixesAsync(CodeFixContext context) { SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); SyntaxNode node = root.FindNode(context.Span); - SyntaxNode fieldNode = GetFieldDeclarationNode(node); + SyntaxNode? fieldNode = GetFieldDeclarationNode(node); if (fieldNode == null) { return; diff --git a/src/Roslyn.Diagnostics.Analyzers/CSharp/CSharpSpecializedEnumerableCreationAnalyzer.cs b/src/Roslyn.Diagnostics.Analyzers/CSharp/CSharpSpecializedEnumerableCreationAnalyzer.cs index a0d546262a..e6b8c4464c 100644 --- a/src/Roslyn.Diagnostics.Analyzers/CSharp/CSharpSpecializedEnumerableCreationAnalyzer.cs +++ b/src/Roslyn.Diagnostics.Analyzers/CSharp/CSharpSpecializedEnumerableCreationAnalyzer.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.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/Tools/ReleaseNotesUtil/RuleFileContent.cs b/src/Tools/ReleaseNotesUtil/RuleFileContent.cs index 5715ff6d70..d804c01767 100644 --- a/src/Tools/ReleaseNotesUtil/RuleFileContent.cs +++ b/src/Tools/ReleaseNotesUtil/RuleFileContent.cs @@ -7,6 +7,6 @@ namespace ReleaseNotesUtil internal class RuleFileContent { [DataMember] - public List Rules { get; set; } + public List? Rules { get; set; } } } diff --git a/src/Utilities/Compiler/CodeMetrics/ComputationalComplexityMetrics.cs b/src/Utilities/Compiler/CodeMetrics/ComputationalComplexityMetrics.cs index 949114aa90..72670a9a01 100644 --- a/src/Utilities/Compiler/CodeMetrics/ComputationalComplexityMetrics.cs +++ b/src/Utilities/Compiler/CodeMetrics/ComputationalComplexityMetrics.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Immutable; -using System.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Operations; diff --git a/src/Utilities/Compiler/Extensions/CompilationExtensions.cs b/src/Utilities/Compiler/Extensions/CompilationExtensions.cs index f48756e146..35af56f541 100644 --- a/src/Utilities/Compiler/Extensions/CompilationExtensions.cs +++ b/src/Utilities/Compiler/Extensions/CompilationExtensions.cs @@ -1,5 +1,6 @@ -using System.Diagnostics.CodeAnalysis; -using System.Linq; +// 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.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; namespace Analyzer.Utilities.Extensions diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAnalysis.CoreCopyAnalysisDataDomain.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAnalysis.CoreCopyAnalysisDataDomain.cs index ba3d1451ba..d2c8e9f089 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAnalysis.CoreCopyAnalysisDataDomain.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/CopyAnalysis/CopyAnalysis.CoreCopyAnalysisDataDomain.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.Diagnostics; namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.CopyAnalysis { diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysis.PropertySetAbstractValueDomain.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysis.PropertySetAbstractValueDomain.cs index a531059933..59d43eeb00 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysis.PropertySetAbstractValueDomain.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysis.PropertySetAbstractValueDomain.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.Diagnostics; using Analyzer.Utilities.PooledObjects; using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow; diff --git a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.OperationBasedIndex.cs b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.OperationBasedIndex.cs index 75ce53d12c..472a9be1ef 100644 --- a/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.OperationBasedIndex.cs +++ b/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/AbstractIndex.OperationBasedIndex.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.Diagnostics; namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow {