Skip to content

Commit 91b88f3

Browse files
committed
Make analyzer test package name comparison case insensitive
Depending on whether we're using preview versions, some of the packages may be downloaded by NuGet and have lowercased names, while at other times they may be shipped in the packs folder and have mixed case.
1 parent 9490405 commit 91b88f3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToUseAnalyzers.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public void It_resolves_analyzers_correctly(string language, string testAssetNam
6464
case "C#":
6565
analyzers.Select(x => GetPackageAndPath(x)).Should().BeEquivalentTo(new[]
6666
{
67-
("Microsoft.NET.Sdk", (string) null, "analyzers/Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll"),
68-
("Microsoft.NET.Sdk", (string)null, "analyzers/Microsoft.CodeAnalysis.NetAnalyzers.dll"),
67+
("microsoft.net.sdk", (string) null, "analyzers/Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll"),
68+
("microsoft.net.sdk", (string)null, "analyzers/Microsoft.CodeAnalysis.NetAnalyzers.dll"),
6969
("microsoft.netcore.app.ref", (string)null, "analyzers/dotnet/cs/System.Text.Json.SourceGeneration.dll"),
7070
("microsoft.netcore.app.ref", (string)null, "analyzers/dotnet/cs/System.Text.RegularExpressions.Generator.dll"),
7171
("microsoft.codequality.analyzers", "2.6.0", "analyzers/dotnet/cs/Microsoft.CodeQuality.Analyzers.dll"),
@@ -81,8 +81,8 @@ public void It_resolves_analyzers_correctly(string language, string testAssetNam
8181
case "VB":
8282
analyzers.Select(x => GetPackageAndPath(x)).Should().BeEquivalentTo( new[]
8383
{
84-
("Microsoft.NET.Sdk", (string)null, "analyzers/Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers.dll"),
85-
("Microsoft.NET.Sdk", (string)null, "analyzers/Microsoft.CodeAnalysis.NetAnalyzers.dll"),
84+
("microsoft.net.sdk", (string)null, "analyzers/Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers.dll"),
85+
("microsoft.net.sdk", (string)null, "analyzers/Microsoft.CodeAnalysis.NetAnalyzers.dll"),
8686
("microsoft.codequality.analyzers", "2.6.0", "analyzers/dotnet/vb/Microsoft.CodeQuality.Analyzers.dll"),
8787
("microsoft.codequality.analyzers", "2.6.0", "analyzers/dotnet/vb/Microsoft.CodeQuality.VisualBasic.Analyzers.dll"),
8888
("microsoft.dependencyvalidation.analyzers", "0.9.0", "analyzers/dotnet/Microsoft.DependencyValidation.Analyzers.dll")
@@ -161,7 +161,7 @@ public void It_resolves_multitargeted_analyzers()
161161
var components = path.Split(new char[] { '/' }, 2);
162162
string sdkName = components[0];
163163
string pathInSdk = components[1];
164-
return (sdkName, null, pathInSdk);
164+
return (sdkName.ToLowerInvariant(), null, pathInSdk);
165165
}
166166

167167
foreach (var nugetRoot in nugetRoots)
@@ -175,11 +175,11 @@ public void It_resolves_multitargeted_analyzers()
175175
var packageVersion = components[1];
176176
var pathInPackage = components[2];
177177
// Don't check package version for analyzers included in targeting pack, as the version changes during development
178-
if (packageName.Equals("microsoft.netcore.app.ref", StringComparison.Ordinal))
178+
if (packageName.Equals("microsoft.netcore.app.ref", StringComparison.OrdinalIgnoreCase))
179179
{
180180
packageVersion = null;
181181
}
182-
return (packageName, packageVersion, pathInPackage);
182+
return (packageName.ToLowerInvariant(), packageVersion, pathInPackage);
183183
}
184184
}
185185

0 commit comments

Comments
 (0)