Support language version based on schema

This commit is contained in:
David Fowler 2015-11-06 05:53:16 -08:00
parent b50ae8bbeb
commit f1f1db0d8e

View file

@ -114,7 +114,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
if (options.LanguageVersion != null) if (options.LanguageVersion != null)
{ {
commonArgs.Add($"-langversion:{options.LanguageVersion}"); commonArgs.Add($"-langversion:{GetLanguageVersion(options.LanguageVersion)}");
} }
if (options.Platform != null) if (options.Platform != null)
@ -159,6 +159,17 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
return commonArgs; return commonArgs;
} }
private static string GetLanguageVersion(string languageVersion)
{
// project.json supports the enum that the roslyn APIs expose
if (languageVersion?.StartsWith("csharp", StringComparison.OrdinalIgnoreCase) == true)
{
// We'll be left with the number csharp6 = 6
return languageVersion.Substring("csharp".Length);
}
return languageVersion;
}
private static Command RunCsc(string cscArgs) private static Command RunCsc(string cscArgs)
{ {
// Locate CoreRun // Locate CoreRun