diff --git a/eng/Versions.props b/eng/Versions.props index 99fd5d6f4ec1fe1d9ec4157476aeeeb788735df3..7db7ce7940696494ed699eb0ff3cc253e70ea23d 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -185,9 +185,9 @@ <MicrosoftBuildFrameworkPackageVersion>15.8.166</MicrosoftBuildFrameworkPackageVersion> <MicrosoftBuildLocatorPackageVersion>1.2.6</MicrosoftBuildLocatorPackageVersion> <MicrosoftBuildUtilitiesCorePackageVersion>15.8.166</MicrosoftBuildUtilitiesCorePackageVersion> - <MicrosoftCodeAnalysisCommonPackageVersion>3.4.0</MicrosoftCodeAnalysisCommonPackageVersion> - <MicrosoftCodeAnalysisCSharpPackageVersion>3.4.0</MicrosoftCodeAnalysisCSharpPackageVersion> - <MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>3.4.0</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion> + <MicrosoftCodeAnalysisCommonPackageVersion>3.7.0-4.20351.7</MicrosoftCodeAnalysisCommonPackageVersion> + <MicrosoftCodeAnalysisCSharpPackageVersion>3.7.0-4.20351.7</MicrosoftCodeAnalysisCSharpPackageVersion> + <MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>3.7.0-4.20351.7</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion> <MicrosoftIdentityModelClientsActiveDirectoryPackageVersion>3.19.8</MicrosoftIdentityModelClientsActiveDirectoryPackageVersion> <MicrosoftIdentityModelLoggingPackageVersion>6.6.0</MicrosoftIdentityModelLoggingPackageVersion> <MicrosoftIdentityModelProtocolsOpenIdConnectPackageVersion>6.6.0</MicrosoftIdentityModelProtocolsOpenIdConnectPackageVersion> diff --git a/src/Analyzers/Analyzers/src/MiddlewareAnalyzer.cs b/src/Analyzers/Analyzers/src/MiddlewareAnalyzer.cs index 0a8deb5dc4b3680a516518cb3dc91df110eb29c6..1395969e1035efeebba31bc5942da34ef8d632e7 100644 --- a/src/Analyzers/Analyzers/src/MiddlewareAnalyzer.cs +++ b/src/Analyzers/Analyzers/src/MiddlewareAnalyzer.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. 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; @@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Analyzers if (context.Operation is IInvocationOperation invocation && invocation.Instance == null && invocation.Arguments.Length >= 1 && - invocation.Arguments[0].Parameter?.Type == _context.StartupSymbols.IApplicationBuilder) + SymbolEqualityComparer.Default.Equals(invocation.Arguments[0].Parameter?.Type, _context.StartupSymbols.IApplicationBuilder)) { middleware.Add(new MiddlewareItem(invocation)); } diff --git a/src/Analyzers/Analyzers/src/ServicesAnalyzer.cs b/src/Analyzers/Analyzers/src/ServicesAnalyzer.cs index dc79cf472796acd4dfacc128550ce0b72b39a792..ac74481a8854d787610e1b919ef295883ebde23f 100644 --- a/src/Analyzers/Analyzers/src/ServicesAnalyzer.cs +++ b/src/Analyzers/Analyzers/src/ServicesAnalyzer.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. 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; @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Analyzers if (context.Operation is IInvocationOperation invocation && invocation.Instance == null && invocation.Arguments.Length >= 1 && - invocation.Arguments[0].Parameter?.Type == _context.StartupSymbols.IServiceCollection) + SymbolEqualityComparer.Default.Equals(invocation.Arguments[0].Parameter?.Type, _context.StartupSymbols.IServiceCollection)) { services.Add(new ServicesItem(invocation)); } diff --git a/src/Analyzers/Analyzers/src/StartupAnalyzer.Diagnostics.cs b/src/Analyzers/Analyzers/src/StartupAnalyzer.Diagnostics.cs index 0ba7239936c2583296c3bb93b6d14403ddc43582..cb2f50997ee17a998efe5fbb734944c872b1bcca 100644 --- a/src/Analyzers/Analyzers/src/StartupAnalyzer.Diagnostics.cs +++ b/src/Analyzers/Analyzers/src/StartupAnalyzer.Diagnostics.cs @@ -9,6 +9,7 @@ namespace Microsoft.AspNetCore.Analyzers { public partial class StartupAnalyzer : DiagnosticAnalyzer { + [System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking")] internal static class Diagnostics { public static readonly ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics; diff --git a/src/Analyzers/Analyzers/src/StartupFacts.cs b/src/Analyzers/Analyzers/src/StartupFacts.cs index f5f833429a6936b01c49d3740196b0b1f1b99ad5..3c5bc9ee9a48a18b51ef88b0e2ecfad9bd3f2a1c 100644 --- a/src/Analyzers/Analyzers/src/StartupFacts.cs +++ b/src/Analyzers/Analyzers/src/StartupFacts.cs @@ -74,12 +74,7 @@ namespace Microsoft.AspNetCore.Analyzers return false; } - if (symbol.Parameters[0].Type != symbols.IServiceCollection) - { - return false; - } - - return true; + return SymbolEqualityComparer.Default.Equals(symbol.Parameters[0].Type, symbols.IServiceCollection); } // Based on StartupLoader. The philosophy is that we want to do analysis only on things @@ -114,7 +109,7 @@ namespace Microsoft.AspNetCore.Analyzers // IApplicationBuilder can appear in any parameter, but must appear. for (var i = 0; i < symbol.Parameters.Length; i++) { - if (symbol.Parameters[i].Type == symbols.IApplicationBuilder) + if (SymbolEqualityComparer.Default.Equals(symbol.Parameters[i].Type, symbols.IApplicationBuilder)) { return true; } diff --git a/src/Components/Analyzers/src/DiagnosticDescriptors.cs b/src/Components/Analyzers/src/DiagnosticDescriptors.cs index 05b98d3b4afba40dac235d6320b720356366d5a4..8b4bfdb154465459cdd5d311319aa4f4c10a74b6 100644 --- a/src/Components/Analyzers/src/DiagnosticDescriptors.cs +++ b/src/Components/Analyzers/src/DiagnosticDescriptors.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis; namespace Microsoft.AspNetCore.Components.Analyzers { + [System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking")] internal static class DiagnosticDescriptors { // Note: The Razor Compiler (including Components features) use the RZ prefix for diagnostics, so there's currently diff --git a/src/Mvc/Mvc.Analyzers/src/DiagnosticDescriptors.cs b/src/Mvc/Mvc.Analyzers/src/DiagnosticDescriptors.cs index 76b068a928964b6fe8569ffb00d64dad140c20aa..8c374422f8c975622a8be3275db15f6ebda96aca 100644 --- a/src/Mvc/Mvc.Analyzers/src/DiagnosticDescriptors.cs +++ b/src/Mvc/Mvc.Analyzers/src/DiagnosticDescriptors.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis; namespace Microsoft.AspNetCore.Mvc.Analyzers { + [System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking")] public static class DiagnosticDescriptors { public static readonly DiagnosticDescriptor MVC1000_HtmlHelperPartialShouldBeAvoided = diff --git a/src/Mvc/Mvc.Api.Analyzers/src/ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs b/src/Mvc/Mvc.Api.Analyzers/src/ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs index 274609128f379c821bbcdb0af78dc60d2baefba1..d884ed3504c801cca8b6119a3530ce2cc36e7644 100644 --- a/src/Mvc/Mvc.Api.Analyzers/src/ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs +++ b/src/Mvc/Mvc.Api.Analyzers/src/ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs @@ -84,7 +84,9 @@ namespace Microsoft.AspNetCore.Mvc.Api.Analyzers return; } +#pragma warning disable RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer var semanticModel = operationAnalysisContext.Compilation.GetSemanticModel(methodSyntax.SyntaxTree); +#pragma warning restore RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer var methodSymbol = semanticModel.GetDeclaredSymbol(methodSyntax, operationAnalysisContext.CancellationToken); if (!ApiControllerFacts.IsApiControllerAction(symbolCache, methodSymbol)) diff --git a/src/Mvc/Mvc.Api.Analyzers/src/ApiDiagnosticDescriptors.cs b/src/Mvc/Mvc.Api.Analyzers/src/ApiDiagnosticDescriptors.cs index ff56f64f1c660623b5ad13eda509713ae9a0a643..da4184604c18478de92b8efc8d394819a11cda93 100644 --- a/src/Mvc/Mvc.Api.Analyzers/src/ApiDiagnosticDescriptors.cs +++ b/src/Mvc/Mvc.Api.Analyzers/src/ApiDiagnosticDescriptors.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis; namespace Microsoft.AspNetCore.Mvc.Api.Analyzers { + [System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking")] internal static class ApiDiagnosticDescriptors { public static readonly DiagnosticDescriptor API1000_ActionReturnsUndocumentedStatusCode = diff --git a/src/Mvc/Mvc.Razor.RuntimeCompilation/test/RuntimeViewCompilerTest.cs b/src/Mvc/Mvc.Razor.RuntimeCompilation/test/RuntimeViewCompilerTest.cs index e9f22da610a466ad6bed376a6adc9db0c6b7290d..6c916309dc6dbccc81fcabff50e731c4bd31d6cc 100644 --- a/src/Mvc/Mvc.Razor.RuntimeCompilation/test/RuntimeViewCompilerTest.cs +++ b/src/Mvc/Mvc.Razor.RuntimeCompilation/test/RuntimeViewCompilerTest.cs @@ -765,7 +765,7 @@ this should fail"; // Arrange var viewPath = "some-relative-path"; var fileContent = "file content"; - var content = "this should fail"; + var content = "public class Bad { this should fail }"; var compiler = GetViewCompiler(new TestFileProvider()); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(fileContent, viewPath)); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs index 4cb0df598b2cc68514bb9477734797adff89acaa..02024ecb1d49bda522fcfee5b9aed1667b7af1ce 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs @@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests protected CSharpSyntaxTree AddCSharpSyntaxTree(string text, string? filePath = null) { - var syntaxTree = (CSharpSyntaxTree)CSharpSyntaxTree.ParseText(text, CSharpParseOptions, path: filePath); + var syntaxTree = (CSharpSyntaxTree)CSharpSyntaxTree.ParseText(text, CSharpParseOptions, path: filePath ?? string.Empty); CSharpSyntaxTrees.Add(syntaxTree); return syntaxTree; }