提交 3c7a4d47 编写于 作者: J Jared Parsons

Fix assembly name check

The calculation of assembly name for a project needs to take into
account default when it's a new SDK project.
上级 24ae6bb4
......@@ -367,6 +367,11 @@ private List<ProjectKey> GetProjectReferencesTransitive(IEnumerable<ProjectKey>
return list;
}
/// <summary>
/// Our infrastructure depends on test assembly names having a very specific set of
/// suffixes: UnitTest and IntegrationTests. This check will verify that both test assemblies
/// are properly named and non-test assemblies are not incorrectly named.
/// </summary>
private bool IsUnitTestCorrectlySpecified(TextWriter textWriter, RoslynProjectData data)
{
if (ProjectType != ProjectFileType.CSharp && ProjectType != ProjectFileType.Basic)
......@@ -379,14 +384,22 @@ private bool IsUnitTestCorrectlySpecified(TextWriter textWriter, RoslynProjectDa
return true;
}
string name = null;
var element = _projectUtil.FindSingleProperty("AssemblyName");
if (element == null)
if (element != null)
{
name = element.Value.Trim();
}
else if (_projectUtil.IsNewSdk)
{
name = Path.GetFileNameWithoutExtension(_data.FileName);
}
else
{
textWriter.WriteLine($"Need to specify AssemblyName");
return false;
}
var name = element.Value.Trim();
if (Regex.IsMatch(name, @"(UnitTests|IntegrationTests)$", RegexOptions.IgnoreCase) && !data.IsAnyUnitTest)
{
textWriter.WriteLine($"Assembly named {name} is not marked as a unit test");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册