Merge pull request #1160 from agocke/infer-analyzer-lang-id
Infer the analyzer languageId from compilerName
This commit is contained in:
commit
5e0329f417
1 changed files with 20 additions and 3 deletions
|
@ -26,12 +26,29 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
|
|
||||||
return compilerName;
|
return compilerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly KeyValuePair<string, string>[] s_compilerNameToLanguageId =
|
||||||
|
{
|
||||||
|
new KeyValuePair<string, string>("csc", "cs"),
|
||||||
|
new KeyValuePair<string, string>("vbc", "vb"),
|
||||||
|
new KeyValuePair<string, string>("fsc", "fs")
|
||||||
|
};
|
||||||
|
|
||||||
public static string ResolveLanguageId(ProjectContext context)
|
public static string ResolveLanguageId(ProjectContext context)
|
||||||
{
|
{
|
||||||
var languageId = context.ProjectFile.AnalyzerOptions?.LanguageId;
|
var languageId = context.ProjectFile.AnalyzerOptions?.LanguageId;
|
||||||
languageId = languageId ?? "cs";
|
if (languageId == null)
|
||||||
|
{
|
||||||
|
var compilerName = ResolveCompilerName(context);
|
||||||
|
foreach (var kvp in s_compilerNameToLanguageId)
|
||||||
|
{
|
||||||
|
if (kvp.Key == compilerName)
|
||||||
|
{
|
||||||
|
languageId = kvp.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return languageId;
|
return languageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue