Update Roslyn package versions (#23630)
* Update Roslyn package versions * Fixes * Fix analyzer warnings * Fix root cause for analyzer warnings * Fixed RuntimeCompilation test * Add back nowarns
This commit is contained in:
parent
499a3bcdc1
commit
7412976b4c
|
|
@ -185,9 +185,9 @@
|
||||||
<MicrosoftBuildFrameworkPackageVersion>15.8.166</MicrosoftBuildFrameworkPackageVersion>
|
<MicrosoftBuildFrameworkPackageVersion>15.8.166</MicrosoftBuildFrameworkPackageVersion>
|
||||||
<MicrosoftBuildLocatorPackageVersion>1.2.6</MicrosoftBuildLocatorPackageVersion>
|
<MicrosoftBuildLocatorPackageVersion>1.2.6</MicrosoftBuildLocatorPackageVersion>
|
||||||
<MicrosoftBuildUtilitiesCorePackageVersion>15.8.166</MicrosoftBuildUtilitiesCorePackageVersion>
|
<MicrosoftBuildUtilitiesCorePackageVersion>15.8.166</MicrosoftBuildUtilitiesCorePackageVersion>
|
||||||
<MicrosoftCodeAnalysisCommonPackageVersion>3.4.0</MicrosoftCodeAnalysisCommonPackageVersion>
|
<MicrosoftCodeAnalysisCommonPackageVersion>3.7.0-4.20351.7</MicrosoftCodeAnalysisCommonPackageVersion>
|
||||||
<MicrosoftCodeAnalysisCSharpPackageVersion>3.4.0</MicrosoftCodeAnalysisCSharpPackageVersion>
|
<MicrosoftCodeAnalysisCSharpPackageVersion>3.7.0-4.20351.7</MicrosoftCodeAnalysisCSharpPackageVersion>
|
||||||
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>3.4.0</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
|
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>3.7.0-4.20351.7</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
|
||||||
<MicrosoftIdentityModelClientsActiveDirectoryPackageVersion>3.19.8</MicrosoftIdentityModelClientsActiveDirectoryPackageVersion>
|
<MicrosoftIdentityModelClientsActiveDirectoryPackageVersion>3.19.8</MicrosoftIdentityModelClientsActiveDirectoryPackageVersion>
|
||||||
<MicrosoftIdentityModelLoggingPackageVersion>6.6.0</MicrosoftIdentityModelLoggingPackageVersion>
|
<MicrosoftIdentityModelLoggingPackageVersion>6.6.0</MicrosoftIdentityModelLoggingPackageVersion>
|
||||||
<MicrosoftIdentityModelProtocolsOpenIdConnectPackageVersion>6.6.0</MicrosoftIdentityModelProtocolsOpenIdConnectPackageVersion>
|
<MicrosoftIdentityModelProtocolsOpenIdConnectPackageVersion>6.6.0</MicrosoftIdentityModelProtocolsOpenIdConnectPackageVersion>
|
||||||
|
|
|
||||||
|
|
@ -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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
if (context.Operation is IInvocationOperation invocation &&
|
if (context.Operation is IInvocationOperation invocation &&
|
||||||
invocation.Instance == null &&
|
invocation.Instance == null &&
|
||||||
invocation.Arguments.Length >= 1 &&
|
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));
|
middleware.Add(new MiddlewareItem(invocation));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
if (context.Operation is IInvocationOperation invocation &&
|
if (context.Operation is IInvocationOperation invocation &&
|
||||||
invocation.Instance == null &&
|
invocation.Instance == null &&
|
||||||
invocation.Arguments.Length >= 1 &&
|
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));
|
services.Add(new ServicesItem(invocation));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
{
|
{
|
||||||
public partial class StartupAnalyzer : DiagnosticAnalyzer
|
public partial class StartupAnalyzer : DiagnosticAnalyzer
|
||||||
{
|
{
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking")]
|
||||||
internal static class Diagnostics
|
internal static class Diagnostics
|
||||||
{
|
{
|
||||||
public static readonly ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics;
|
public static readonly ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics;
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,7 @@ namespace Microsoft.AspNetCore.Analyzers
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (symbol.Parameters[0].Type != symbols.IServiceCollection)
|
return SymbolEqualityComparer.Default.Equals(symbol.Parameters[0].Type, symbols.IServiceCollection);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Based on StartupLoader. The philosophy is that we want to do analysis only on things
|
// 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.
|
// IApplicationBuilder can appear in any parameter, but must appear.
|
||||||
for (var i = 0; i < symbol.Parameters.Length; i++)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Components.Analyzers
|
namespace Microsoft.AspNetCore.Components.Analyzers
|
||||||
{
|
{
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking")]
|
||||||
internal static class DiagnosticDescriptors
|
internal static class DiagnosticDescriptors
|
||||||
{
|
{
|
||||||
// Note: The Razor Compiler (including Components features) use the RZ prefix for diagnostics, so there's currently
|
// Note: The Razor Compiler (including Components features) use the RZ prefix for diagnostics, so there's currently
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Analyzers
|
namespace Microsoft.AspNetCore.Mvc.Analyzers
|
||||||
{
|
{
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking")]
|
||||||
public static class DiagnosticDescriptors
|
public static class DiagnosticDescriptors
|
||||||
{
|
{
|
||||||
public static readonly DiagnosticDescriptor MVC1000_HtmlHelperPartialShouldBeAvoided =
|
public static readonly DiagnosticDescriptor MVC1000_HtmlHelperPartialShouldBeAvoided =
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,9 @@ namespace Microsoft.AspNetCore.Mvc.Api.Analyzers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
|
||||||
var semanticModel = operationAnalysisContext.Compilation.GetSemanticModel(methodSyntax.SyntaxTree);
|
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);
|
var methodSymbol = semanticModel.GetDeclaredSymbol(methodSyntax, operationAnalysisContext.CancellationToken);
|
||||||
|
|
||||||
if (!ApiControllerFacts.IsApiControllerAction(symbolCache, methodSymbol))
|
if (!ApiControllerFacts.IsApiControllerAction(symbolCache, methodSymbol))
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Api.Analyzers
|
namespace Microsoft.AspNetCore.Mvc.Api.Analyzers
|
||||||
{
|
{
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking")]
|
||||||
internal static class ApiDiagnosticDescriptors
|
internal static class ApiDiagnosticDescriptors
|
||||||
{
|
{
|
||||||
public static readonly DiagnosticDescriptor API1000_ActionReturnsUndocumentedStatusCode =
|
public static readonly DiagnosticDescriptor API1000_ActionReturnsUndocumentedStatusCode =
|
||||||
|
|
|
||||||
|
|
@ -765,7 +765,7 @@ this should fail";
|
||||||
// Arrange
|
// Arrange
|
||||||
var viewPath = "some-relative-path";
|
var viewPath = "some-relative-path";
|
||||||
var fileContent = "file content";
|
var fileContent = "file content";
|
||||||
var content = "this should fail";
|
var content = "public class Bad { this should fail }";
|
||||||
|
|
||||||
var compiler = GetViewCompiler(new TestFileProvider());
|
var compiler = GetViewCompiler(new TestFileProvider());
|
||||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(fileContent, viewPath));
|
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(fileContent, viewPath));
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
||||||
|
|
||||||
protected CSharpSyntaxTree AddCSharpSyntaxTree(string text, string? filePath = null)
|
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);
|
CSharpSyntaxTrees.Add(syntaxTree);
|
||||||
return syntaxTree;
|
return syntaxTree;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue