未验证 提交 06207712 编写于 作者: A Andy Gocke 提交者: GitHub

Add netstandard to the exclusion list for the AnalyzerConsistencyChecker (#36976)

Fixes #36963
上级 64007b69
......@@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.CompilerServer
{
internal static class AnalyzerConsistencyChecker
{
private static readonly ImmutableArray<string> s_defaultIgnorableReferenceNames = ImmutableArray.Create("mscorlib", "System", "Microsoft.CodeAnalysis");
private static readonly ImmutableArray<string> s_defaultIgnorableReferenceNames = ImmutableArray.Create("mscorlib", "System", "Microsoft.CodeAnalysis", "netstandard");
public static bool Check(string baseDirectory, IEnumerable<CommandLineAnalyzerReference> analyzerReferences, IAnalyzerAssemblyLoader loader, IEnumerable<string> ignorableReferenceNames = null)
{
......
......@@ -8,6 +8,7 @@
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Roslyn.Test.Utilities;
using Xunit;
......@@ -86,6 +87,27 @@ public void AssemblyLoadException()
Assert.False(result);
}
[Fact]
public void NetstandardIgnored()
{
var directory = Temp.CreateDirectory();
const string name = "netstandardRef";
var comp = CSharpCompilation.Create(
name,
new[] { SyntaxFactory.ParseSyntaxTree(@"class C {}") },
references: new MetadataReference[] { MetadataReference.CreateFromImage(TestResources.NetFX.netstandard20.netstandard) },
options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
var compFile = directory.CreateFile(name);
comp.Emit(compFile.Path);
var analyzerReferences = ImmutableArray.Create(new CommandLineAnalyzerReference(name));
var result = AnalyzerConsistencyChecker.Check(directory.Path, analyzerReferences, new InMemoryAssemblyLoader());
Assert.True(result);
}
private class InMemoryAssemblyLoader : IAnalyzerAssemblyLoader
{
private readonly Dictionary<string, Assembly> _assemblies = new Dictionary<string, Assembly>(StringComparer.OrdinalIgnoreCase);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册