in src/Tasks/Microsoft.NET.Build.Tasks/NuGetUtils.NuGet.cs [50:81]
public static bool IsApplicableAnalyzer(string file, string projectLanguage)
{
// This logic is preserved from previous implementations.
// See https://github.com/NuGet/Home/issues/6279#issuecomment-353696160 for possible issues with it.
bool IsAnalyzer()
{
return file.StartsWith("analyzers", StringComparison.Ordinal)
&& file.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)
&& !file.EndsWith(".resources.dll", StringComparison.OrdinalIgnoreCase);
}
bool CS() => file.IndexOf("/cs/", StringComparison.OrdinalIgnoreCase) >= 0;
bool VB() => file.IndexOf("/vb/", StringComparison.OrdinalIgnoreCase) >= 0;
bool FileMatchesProjectLanguage()
{
switch (projectLanguage)
{
case "C#":
return CS() || !VB();
case "VB":
return VB() || !CS();
default:
return false;
}
}
return IsAnalyzer() && FileMatchesProjectLanguage();
}