提交 0caffeb7 编写于 作者: V Vladimir Koshelev

Add a unit test to ensure that issue 20187 is resolved.

上级 9e66471e
// 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.IO;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Host.Mef;
......@@ -110,5 +111,20 @@ public void TestAdditionalFiles()
Assert.Equal("foo.cs", firstDoc.Name);
Assert.Equal("bar.cs", secondDoc.Name);
}
[Fact]
public void TestAnalyzerReferences()
{
var pathToAssembly = typeof(object).Assembly.Location;
var assemblyBaseDir = Path.GetDirectoryName(pathToAssembly);
var relativePath = Path.Combine(".", Path.GetFileName(pathToAssembly));
string commandLine = @"foo.cs /a:" + relativePath;
var info = CommandLineProject.CreateProjectInfo("TestProject", LanguageNames.CSharp, commandLine, assemblyBaseDir);
var firstDoc = info.Documents.Single();
var analyzerRef = info.AnalyzerReferences.First();
Assert.Equal("foo.cs", firstDoc.Name);
Assert.Equal(pathToAssembly, analyzerRef.FullPath);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册