提交 c83a3908 编写于 作者: J Julien Couvreur 提交者: GitHub

Error messsage should mention C# 7.0 not C# 7 (#22255)

上级 633f8b2f
......@@ -4598,7 +4598,7 @@ internal class CSharpResources {
}
/// <summary>
/// Looks up a localized string similar to Feature &apos;{0}&apos; is not available in C# 7. Please use language version {1} or greater..
/// Looks up a localized string similar to Feature &apos;{0}&apos; is not available in C# 7.0. Please use language version {1} or greater..
/// </summary>
internal static string ERR_FeatureNotAvailableInVersion7 {
get {
......
......@@ -4402,7 +4402,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<value>Feature '{0}' is not available in C# 6. Please use language version {1} or greater.</value>
</data>
<data name="ERR_FeatureNotAvailableInVersion7" xml:space="preserve">
<value>Feature '{0}' is not available in C# 7. Please use language version {1} or greater.</value>
<value>Feature '{0}' is not available in C# 7.0. Please use language version {1} or greater.</value>
</data>
<data name="ERR_FeatureIsExperimental" xml:space="preserve">
<value>Feature '{0}' is experimental and unsupported; use '/features:{1}' to enable.</value>
......
......@@ -659,11 +659,12 @@ async static Task Main(string[] args)
}";
var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7));
compilation.VerifyDiagnostics(
// (6,18): error CS8107: Feature 'async main' is not available in C# 7. Please use language version 7.1 or greater.
// (6,18): error CS8107: Feature 'async main' is not available in C# 7.0. Please use language version 7.1 or greater.
// async static Task Main(string[] args)
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "Task").WithArguments("async main", "7.1").WithLocation(6, 18),
// error CS5001: Program does not contain a static 'Main' method suitable for an entry point
Diagnostic(ErrorCode.ERR_NoEntryPoint).WithLocation(1, 1));
Diagnostic(ErrorCode.ERR_NoEntryPoint).WithLocation(1, 1)
);
}
[Fact]
......
......@@ -3427,15 +3427,17 @@ async public static Task Main()
{
}
}";
CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7)).VerifyDiagnostics(
var comp = CreateCompilationWithMscorlib45(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7));
comp.VerifyDiagnostics(
// (5,30): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
// async public static Task Main()
Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "Main").WithLocation(5, 30),
// (5,25): error CS8107: Feature 'async main' is not available in C# 7. Please use language version 7.1 or greater.
// (5,25): error CS8107: Feature 'async main' is not available in C# 7.0. Please use language version 7.1 or greater.
// async public static Task Main()
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "Task").WithArguments("async main", "7.1").WithLocation(5, 25),
// error CS5001: Program does not contain a static 'Main' method suitable for an entry point
Diagnostic(ErrorCode.ERR_NoEntryPoint).WithLocation(1, 1));
Diagnostic(ErrorCode.ERR_NoEntryPoint).WithLocation(1, 1)
);
}
[Fact, WorkItem(547088, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/547088")]
......
......@@ -26,7 +26,7 @@ static void Main()
";
var comp = CreateStandardCompilation(source, parseOptions: TestOptions.Regular7);
comp.VerifyDiagnostics(
// (6,17): error CS8107: Feature 'default literal' is not available in C# 7. Please use language version 7.1 or greater.
// (6,17): error CS8107: Feature 'default literal' is not available in C# 7.0. Please use language version 7.1 or greater.
// int x = default;
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "default").WithArguments("default literal", "7.1").WithLocation(6, 17)
);
......@@ -47,7 +47,7 @@ class C
";
var comp = CreateCompilationWithMscorlib46(source,parseOptions: TestOptions.Regular7 );
comp.VerifyDiagnostics(
// (7,40): error CS8107: Feature 'default literal' is not available in C# 7. Please use language version 7.1 or greater.
// (7,40): error CS8107: Feature 'default literal' is not available in C# 7.0. Please use language version 7.1 or greater.
// async Task M(CancellationToken t = default) { await Task.Delay(0); }
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "default").WithArguments("default literal", "7.1").WithLocation(7, 40)
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册