diff --git a/docs/compilers/CSharp/CommandLine.md b/docs/compilers/CSharp/CommandLine.md
index 79c30791229c9..83d77bd2be760 100644
--- a/docs/compilers/CSharp/CommandLine.md
+++ b/docs/compilers/CSharp/CommandLine.md
@@ -50,7 +50,7 @@
| `/checked`{`+`|`-`} | Generate overflow checks
| `/unsafe`{`+`|`-`} | Allow 'unsafe' code
| `/define:`*symbol list* | Define conditional compilation symbol(s) (Short form: `/d`)
-| `/langversion`:*string* | Specify language version mode: `ISO-1`, `ISO-2`, `3`, `4`, `5`, `6`, `7`, `7.1`, `Default` (latest major version), or `Latest` (latest version, including minor versions)
+| `/langversion`:*string* | Specify language version mode: `ISO-1`, `ISO-2`, `3`, `4`, `5`, `6`, `7`, `7.1`, `7.2`, `Default` (latest major version), or `Latest` (latest version, including minor versions)
| **SECURITY**
| `/delaysign`{`+`|`-`} | Delay-sign the assembly using only the public portion of the strong name key
| `/keyfile:`*file* | Specify a strong name key file
diff --git a/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs b/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs
index 6544acbdfb2eb..d31745ff0ac72 100644
--- a/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs
+++ b/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs
@@ -1232,7 +1232,7 @@ internal static string ERR_BadCoClassSig {
}
///
- /// Looks up a localized string similar to Invalid option '{0}' for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1..
+ /// Looks up a localized string similar to Invalid option '{0}' for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.2..
///
internal static string ERR_BadCompatMode {
get {
@@ -4480,6 +4480,15 @@ internal static string ERR_FeatureNotAvailableInVersion7_1 {
}
}
+ ///
+ /// Looks up a localized string similar to Feature '{0}' is not available in C# 7.2. Please use language version {1} or greater..
+ ///
+ internal static string ERR_FeatureNotAvailableInVersion7_2 {
+ get {
+ return ResourceManager.GetString("ERR_FeatureNotAvailableInVersion7_2", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to An expression tree may not contain '{0}'.
///
diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx
index fcd9bea8ba0cf..c6bec4bea3604 100644
--- a/src/Compilers/CSharp/Portable/CSharpResources.resx
+++ b/src/Compilers/CSharp/Portable/CSharpResources.resx
@@ -2705,7 +2705,7 @@ A catch() block after a catch (System.Exception e) block can catch non-CLS excep
This warning occurs if the assembly attributes AssemblyKeyFileAttribute or AssemblyKeyNameAttribute found in source conflict with the /keyfile or /keycontainer command line option or key file name or key container specified in the Project Properties.
- Invalid option '{0}' for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1.
+ Invalid option '{0}' for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.2.
Cannot create delegate with '{0}' because it or a method it overrides has a Conditional attribute
@@ -4472,7 +4472,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
/define:<symbol list> Define conditional compilation symbol(s) (Short
form: /d)
/langversion:<string> Specify language version mode: ISO-1, ISO-2, 3,
- 4, 5, 6, 7.0, 7.1, Default, or Latest
+ 4, 5, 6, 7.0, 7.1, 7.2, Default, or Latest
- SECURITY -
/delaysign[+|-] Delay-sign the assembly using only the public
@@ -5048,6 +5048,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
Feature '{0}' is not available in C# 7.1. Please use language version {1} or greater.
+
+ Feature '{0}' is not available in C# 7.2. Please use language version {1} or greater.
+
Specified language version '{0}' cannot have leading zeroes
diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
index 92bb41d818f46..8e1f8e08dfafc 100644
--- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
+++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
@@ -1488,5 +1488,9 @@ internal enum ErrorCode
ERR_PatternWrongGenericTypeInVersion = 8314,
#endregion diagnostics introduced for C# 7.1
+
+ #region diagnostics introduced for C# 7.2
+ ERR_FeatureNotAvailableInVersion7_2 = 8320,
+ #endregion diagnostics introduced for C# 7.2
}
}
diff --git a/src/Compilers/CSharp/Portable/LanguageVersion.cs b/src/Compilers/CSharp/Portable/LanguageVersion.cs
index 9bfa1c447eb21..d7290e2922d6b 100644
--- a/src/Compilers/CSharp/Portable/LanguageVersion.cs
+++ b/src/Compilers/CSharp/Portable/LanguageVersion.cs
@@ -74,6 +74,11 @@ public enum LanguageVersion
///
CSharp7_1 = 701,
+ ///
+ /// C# language version 7.2
+ ///
+ CSharp7_2 = 702,
+
///
/// The latest version of the language supported.
///
@@ -94,6 +99,7 @@ internal static bool IsValid(this LanguageVersion value)
case LanguageVersion.CSharp6:
case LanguageVersion.CSharp7:
case LanguageVersion.CSharp7_1:
+ case LanguageVersion.CSharp7_2:
return true;
}
@@ -120,6 +126,8 @@ internal static ErrorCode GetErrorCode(this LanguageVersion version)
return ErrorCode.ERR_FeatureNotAvailableInVersion7;
case LanguageVersion.CSharp7_1:
return ErrorCode.ERR_FeatureNotAvailableInVersion7_1;
+ case LanguageVersion.CSharp7_2:
+ return ErrorCode.ERR_FeatureNotAvailableInVersion7_2;
default:
throw ExceptionUtilities.UnexpectedValue(version);
}
@@ -164,6 +172,8 @@ public static string ToDisplayString(this LanguageVersion version)
return "7.0";
case LanguageVersion.CSharp7_1:
return "7.1";
+ case LanguageVersion.CSharp7_2:
+ return "7.2";
case LanguageVersion.Default:
return "default";
case LanguageVersion.Latest:
@@ -235,6 +245,10 @@ public static bool TryParse(this string version, out LanguageVersion result)
result = LanguageVersion.CSharp7_1;
return true;
+ case "7.2":
+ result = LanguageVersion.CSharp7_2;
+ return true;
+
default:
result = LanguageVersion.Default;
return false;
@@ -249,7 +263,7 @@ public static LanguageVersion MapSpecifiedToEffectiveVersion(this LanguageVersio
switch (version)
{
case LanguageVersion.Latest:
- return LanguageVersion.CSharp7_1;
+ return LanguageVersion.CSharp7_2;
case LanguageVersion.Default:
return LanguageVersion.CSharp7;
default:
diff --git a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
index 74993f0e4e468..1dac384a597f6 100644
--- a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
+++ b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
@@ -1,4 +1,5 @@
Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp7_1 = 701 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion
+Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp7_2 = 702 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion
Microsoft.CodeAnalysis.CSharp.LanguageVersionFacts
Microsoft.CodeAnalysis.CSharp.SyntaxKind.ConflictMarkerTrivia = 8564 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind
Microsoft.CodeAnalysis.CSharp.SyntaxKind.DefaultLiteralExpression = 8755 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind
diff --git a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
index a3fe030f6d351..8764f4d7e3e6d 100644
--- a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
+++ b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
@@ -1304,7 +1304,7 @@ public void LanguageVersionAdded_Canary()
// - update the IDE drop-down for selecting Language Version
// - update all the tests that call this canary
// - update the command-line documentation (CommandLine.md)
- AssertEx.SetEqual(new[] { "default", "1", "2", "3", "4", "5", "6", "7.0", "7.1", "latest" },
+ AssertEx.SetEqual(new[] { "default", "1", "2", "3", "4", "5", "6", "7.0", "7.1", "7.2", "latest" },
Enum.GetValues(typeof(LanguageVersion)).Cast().Select(v => v.ToDisplayString()));
// For minor versions, the format should be "x.y", such as "7.1"
}
@@ -1325,7 +1325,8 @@ public void LanguageVersion_GetErrorCode()
ErrorCode.ERR_FeatureNotAvailableInVersion5,
ErrorCode.ERR_FeatureNotAvailableInVersion6,
ErrorCode.ERR_FeatureNotAvailableInVersion7,
- ErrorCode.ERR_FeatureNotAvailableInVersion7_1
+ ErrorCode.ERR_FeatureNotAvailableInVersion7_1,
+ ErrorCode.ERR_FeatureNotAvailableInVersion7_2
};
AssertEx.SetEqual(versions, errorCodes);
@@ -1345,9 +1346,10 @@ public void LanguageVersion_MapSpecifiedToEffectiveVersion()
Assert.Equal(LanguageVersion.CSharp6, LanguageVersion.CSharp6.MapSpecifiedToEffectiveVersion());
Assert.Equal(LanguageVersion.CSharp7, LanguageVersion.CSharp7.MapSpecifiedToEffectiveVersion());
Assert.Equal(LanguageVersion.CSharp7_1, LanguageVersion.CSharp7_1.MapSpecifiedToEffectiveVersion());
+ Assert.Equal(LanguageVersion.CSharp7_2, LanguageVersion.CSharp7_2.MapSpecifiedToEffectiveVersion());
Assert.Equal(LanguageVersion.CSharp7, LanguageVersion.Default.MapSpecifiedToEffectiveVersion());
- Assert.Equal(LanguageVersion.CSharp7_1, LanguageVersion.Latest.MapSpecifiedToEffectiveVersion());
+ Assert.Equal(LanguageVersion.CSharp7_2, LanguageVersion.Latest.MapSpecifiedToEffectiveVersion());
// The canary check is a reminder that this test needs to be updated when a language version is added
LanguageVersionAdded_Canary();
@@ -1374,6 +1376,7 @@ public void LanguageVersion_MapSpecifiedToEffectiveVersion()
InlineData("7.0", true, LanguageVersion.CSharp7),
InlineData("07", false, LanguageVersion.Default),
InlineData("7.1", true, LanguageVersion.CSharp7_1),
+ InlineData("7.2", true, LanguageVersion.CSharp7_2),
InlineData("07.1", false, LanguageVersion.Default),
InlineData("default", true, LanguageVersion.Default),
InlineData("latest", true, LanguageVersion.Latest),
diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs
index cfddcaff1ab91..891ff5acf2e20 100644
--- a/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs
+++ b/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs
@@ -11,6 +11,7 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.Async
{
+ [Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
public partial class UpgradeProjectTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
@@ -38,7 +39,7 @@ private async Task TestLanguageVersionUpgradedAsync(
await TestAsync(initialMarkup, initialMarkup, parseOptions); // no change to markup
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeProjectFromCSharp6ToDefault()
{
await TestLanguageVersionUpgradedAsync(
@@ -54,7 +55,7 @@ void A()
new CSharpParseOptions(LanguageVersion.CSharp6));
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeProjectFromCSharp6ToCSharp7()
{
await TestLanguageVersionUpgradedAsync(
@@ -71,7 +72,7 @@ void A()
index: 1);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeProjectFromCSharp5ToCSharp6()
{
await TestLanguageVersionUpgradedAsync(
@@ -88,7 +89,7 @@ void A()
index: 1);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeProjectFromCSharp4ToCSharp5()
{
await TestLanguageVersionUpgradedAsync(
@@ -105,7 +106,7 @@ void A()
index: 1);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeProjectFromCSharp7ToLatest()
{
await TestLanguageVersionUpgradedAsync(
@@ -118,7 +119,7 @@ class Program
new CSharpParseOptions(LanguageVersion.CSharp7));
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeProjectFromCSharp7ToLatest_TriggeredByInferredTupleNames()
{
await TestLanguageVersionUpgradedAsync(
@@ -152,7 +153,7 @@ public ValueTuple(T1 item1, T2 item2)
new CSharpParseOptions(LanguageVersion.CSharp7));
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeProjectFromCSharp7_1ToLatest()
{
await TestLanguageVersionUpgradedAsync(
@@ -165,7 +166,20 @@ class Program
new CSharpParseOptions(LanguageVersion.CSharp7_1));
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
+ public async Task UpgradeProjectFromCSharp7_2ToLatest()
+ {
+ await TestLanguageVersionUpgradedAsync(
+@"
+class Program
+{
+#error version:[|7.2|]
+}",
+ LanguageVersion.Latest,
+ new CSharpParseOptions(LanguageVersion.CSharp7_2));
+ }
+
+ [Fact]
public async Task UpgradeProjectFromCSharp7ToCSharp7_1()
{
await TestLanguageVersionUpgradedAsync(
@@ -179,7 +193,7 @@ class Program
index: 1);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeProjectFromCSharp7ToCSharp7_1_B()
{
await TestLanguageVersionUpgradedAsync(
@@ -198,7 +212,7 @@ public static void M(T x) where T: Base
index: 1);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeAllProjectsToDefault()
{
await TestLanguageVersionUpgradedAsync(
@@ -229,7 +243,7 @@ void A()
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task UpgradeAllProjectsToCSharp7()
{
await TestLanguageVersionUpgradedAsync(
@@ -259,7 +273,7 @@ void A()
index: 2);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task ListAllSuggestions()
{
await TestExactActionSetOfferedAsync(
@@ -289,7 +303,7 @@ void A()
});
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task FixAllProjectsNotOffered()
{
await TestExactActionSetOfferedAsync(
@@ -315,7 +329,7 @@ void A()
});
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task OnlyOfferFixAllProjectsToCSharp7WhenApplicable()
{
await TestExactActionSetOfferedAsync(
@@ -344,7 +358,7 @@ void A()
});
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUpgradeProject)]
+ [Fact]
public async Task OnlyOfferFixAllProjectsToDefaultWhenApplicable()
{
await TestExactActionSetOfferedAsync(
diff --git a/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs b/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs
index a97e9870acdcd..fcc7e191b29f6 100644
--- a/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs
+++ b/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs
@@ -26,9 +26,10 @@ internal class CSharpUpgradeProjectCodeFixProvider : AbstractUpgradeProjectCodeF
private const string CS8302 = nameof(CS8302); // error CS8302: Feature is not available in C# 7.1. Please use language version X or greater.
private const string CS8306 = nameof(CS8306); // error CS8306: ... Please use language version 7.1 or greater to access a un-named element by its inferred name.
private const string CS8314 = nameof(CS8314); // error CS9003: An expression of type '{0}' cannot be handled by a pattern of type '{1}' in C# {2}. Please use language version {3} or greater.
+ private const string CS8320 = nameof(CS8320); // error CS8320: Feature is not available in C# 7.2. Please use language version X or greater.
public override ImmutableArray FixableDiagnosticIds { get; } =
- ImmutableArray.Create(CS8022, CS8023, CS8024, CS8025, CS8026, CS8059, CS8107, CS8302, CS8306, CS8314);
+ ImmutableArray.Create(CS8022, CS8023, CS8024, CS8025, CS8026, CS8059, CS8107, CS8302, CS8306, CS8314, CS8320);
public override string UpgradeThisProjectResource => CSharpFeaturesResources.Upgrade_this_project_to_csharp_language_version_0;
public override string UpgradeAllProjectsResource => CSharpFeaturesResources.Upgrade_all_csharp_projects_to_language_version_0;