未验证 提交 e1dcbb3d 编写于 作者: D Drew Noakes 提交者: GitHub

Merge pull request #45101 from drewnoakes/update-analyzer-node-file-path

Handle new CPS analyzer node path format
......@@ -48,6 +48,18 @@ public static string ExtractAnalyzerFilePath(string projectDirectoryPath, string
return null;
}
// If the path does not contain "analyzerdependency\" immediately after the first slash, it
// is a newer form of the analyzer tree item's file path (VS16.7) which requires no processing.
//
// It is theoretically possible that this incorrectly identifies an analyzer assembly
// defined under "c:\analyzerdependency\..." as data in the old format, however this is very
// unlikely. The side effect of such a problem is that analyzer's diagnostics would not
// populate in the tree.
if (analyzerNodeCanonicalName.IndexOf(@"analyzerdependency\", backslashIndex + 1, @"analyzerdependency\".Length, StringComparison.OrdinalIgnoreCase) != backslashIndex + 1)
{
return analyzerNodeCanonicalName;
}
// Find the slash after "analyzerdependency"
backslashIndex = analyzerNodeCanonicalName.IndexOf('\\', backslashIndex + 1);
if (backslashIndex < 0)
......
......@@ -18,7 +18,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.SolutionExplorer
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.Diagnostics)>
Public Sub ExtractAnalyzerFilePath_WithoutProjectPath()
Public Sub ExtractAnalyzerFilePath_WithoutProjectPath_WithTfmAndProviderType()
Dim projectDirectoryFullPath = "C:\users\me\Solution\Project"
Dim analyzerCanonicalName = "netstandard2.0\analyzerdependency\C:\users\me\.nuget\package\analyzer\MyAnalyzer.dll"
......@@ -26,6 +26,15 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.SolutionExplorer
Assert.Equal(expected:="C:\users\me\.nuget\package\analyzer\MyAnalyzer.dll", actual:=analyzerFileFullPath)
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.Diagnostics)>
Public Sub ExtractAnalyzerFilePath_WithoutProjectPath_WithoutTfmAndProviderType()
Dim projectDirectoryFullPath = "C:\users\me\Solution\Project"
Dim analyzerCanonicalName = "C:\users\me\.nuget\package\analyzer\MyAnalyzer.dll"
Dim analyzerFileFullPath = CpsUtilities.ExtractAnalyzerFilePath(projectDirectoryFullPath, analyzerCanonicalName)
Assert.Equal(expected:="C:\users\me\.nuget\package\analyzer\MyAnalyzer.dll", actual:=analyzerFileFullPath)
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.Diagnostics)>
Public Sub ExtractAnalyzerFilePath_MalformedCanonicalName()
Dim projectDirectoryFullPath = "C:\users\me\Solution\Project"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册