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:
Ajay Bhargav B 2020-07-06 14:35:10 -07:00 committed by GitHub
parent 499a3bcdc1
commit 7412976b4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 17 additions and 16 deletions

View File

@ -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>

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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 =

View File

@ -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))

View File

@ -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 =

View File

@ -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));

View File

@ -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;
}