From c6544c28b42c41c8c40e60b6175962024c86f4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20F=C4=B1st=C4=B1k?= Date: Thu, 15 Jan 2026 12:32:08 +0100 Subject: [PATCH 1/5] Adding C#, F#, VB to StringSyntaxAttribute Adding 3 constants that represent C#, F#, and Visual Basic to the StringSyntaxAttribute Fix #122604 --- .../Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs | 9 +++++++++ .../CodeAnalysis/StringSyntaxAttributeTests.cs | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs index 26fcf5ca096408..3728c5e5cf400f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs @@ -70,5 +70,14 @@ public StringSyntaxAttribute(string syntax, params object?[] arguments) /// The syntax identifier for strings containing XML. public const string Xml = nameof(Xml); + + /// The syntax identifier for strings containing CSharp code. + public const string CSharp = "C#"; + + /// The syntax identifier for strings containing FSharp code. + public const string FSharp = "F#"; + + /// The syntax identifier for strings containing VisualBasic code. + public const string VisualBasic = "VB.NET"; } } diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Diagnostics/CodeAnalysis/StringSyntaxAttributeTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Diagnostics/CodeAnalysis/StringSyntaxAttributeTests.cs index ba53ab2c0f3bbe..990e9bd363b182 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Diagnostics/CodeAnalysis/StringSyntaxAttributeTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Diagnostics/CodeAnalysis/StringSyntaxAttributeTests.cs @@ -11,6 +11,9 @@ public sealed class StringSyntaxAttributeTests [InlineData(StringSyntaxAttribute.DateTimeFormat)] [InlineData(StringSyntaxAttribute.Json)] [InlineData(StringSyntaxAttribute.Regex)] + [InlineData(StringSyntaxAttribute.CSharp)] + [InlineData(StringSyntaxAttribute.FSharp)] + [InlineData(StringSyntaxAttribute.VisualBasic)] public void Ctor_Roundtrips(string syntax) { var attribute = new StringSyntaxAttribute(syntax); From 0a2ca89cc44773e0bc5e47817e16083c2bdf0351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20F=C4=B1st=C4=B1k?= Date: Thu, 15 Jan 2026 13:29:10 +0100 Subject: [PATCH 2/5] Adding C#, F#, VB to StringSyntaxAttribute Update the ref source, as requested by this comment on the PR: https://github.com/dotnet/runtime/pull/123211#issuecomment-3754408212 --- src/libraries/System.Runtime/ref/System.Runtime.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index ce6380fc645bf2..2a2bfd22886402 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -9107,6 +9107,9 @@ public sealed partial class StringSyntaxAttribute : System.Attribute public const string TimeSpanFormat = "TimeSpanFormat"; public const string Uri = "Uri"; public const string Xml = "Xml"; + public const string CSharp = "C#"; + public const string FSharp = "F#"; + public const string VisualBasic = "VB.NET"; public StringSyntaxAttribute(string syntax) { } public StringSyntaxAttribute(string syntax, params object?[] arguments) { } public object?[] Arguments { get { throw null; } } From 21e712d5ae029b69970cbda76dac656fd4220090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20F=C4=B1st=C4=B1k?= Date: Thu, 15 Jan 2026 15:53:21 +0100 Subject: [PATCH 3/5] Adding C#, F#, VB to StringSyntaxAttribute Order the constant names alphabetically --- src/libraries/System.Runtime/ref/System.Runtime.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 2a2bfd22886402..1b7efb78c07ec3 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -9096,9 +9096,11 @@ public SetsRequiredMembersAttribute() { } public sealed partial class StringSyntaxAttribute : System.Attribute { public const string CompositeFormat = "CompositeFormat"; + public const string CSharp = "C#"; public const string DateOnlyFormat = "DateOnlyFormat"; public const string DateTimeFormat = "DateTimeFormat"; public const string EnumFormat = "EnumFormat"; + public const string FSharp = "F#"; public const string GuidFormat = "GuidFormat"; public const string Json = "Json"; public const string NumericFormat = "NumericFormat"; @@ -9106,10 +9108,8 @@ public sealed partial class StringSyntaxAttribute : System.Attribute public const string TimeOnlyFormat = "TimeOnlyFormat"; public const string TimeSpanFormat = "TimeSpanFormat"; public const string Uri = "Uri"; - public const string Xml = "Xml"; - public const string CSharp = "C#"; - public const string FSharp = "F#"; public const string VisualBasic = "VB.NET"; + public const string Xml = "Xml"; public StringSyntaxAttribute(string syntax) { } public StringSyntaxAttribute(string syntax, params object?[] arguments) { } public object?[] Arguments { get { throw null; } } From e8b10ac91ea722e491c7358466b87d226bc21013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20F=C4=B1st=C4=B1k?= Date: Thu, 15 Jan 2026 16:09:00 +0100 Subject: [PATCH 4/5] Adding C#, F#, VB to StringSyntaxAttribute Order the constant names alphabetically in UnitTest and StringSyntaxAttribute --- .../CodeAnalysis/StringSyntaxAttribute.cs | 18 +++++++++--------- .../CodeAnalysis/StringSyntaxAttributeTests.cs | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs index 3728c5e5cf400f..b4dbebf2b50be8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs @@ -38,6 +38,9 @@ public StringSyntaxAttribute(string syntax, params object?[] arguments) /// The syntax identifier for strings containing composite formats for string formatting. public const string CompositeFormat = nameof(CompositeFormat); + /// The syntax identifier for strings containing CSharp code. + public const string CSharp = "C#"; + /// The syntax identifier for strings containing date format specifiers. public const string DateOnlyFormat = nameof(DateOnlyFormat); @@ -47,6 +50,9 @@ public StringSyntaxAttribute(string syntax, params object?[] arguments) /// The syntax identifier for strings containing format specifiers. public const string EnumFormat = nameof(EnumFormat); + /// The syntax identifier for strings containing FSharp code. + public const string FSharp = "F#"; + /// The syntax identifier for strings containing format specifiers. public const string GuidFormat = nameof(GuidFormat); @@ -68,16 +74,10 @@ public StringSyntaxAttribute(string syntax, params object?[] arguments) /// The syntax identifier for strings containing URIs. public const string Uri = nameof(Uri); - /// The syntax identifier for strings containing XML. - public const string Xml = nameof(Xml); - - /// The syntax identifier for strings containing CSharp code. - public const string CSharp = "C#"; - - /// The syntax identifier for strings containing FSharp code. - public const string FSharp = "F#"; - /// The syntax identifier for strings containing VisualBasic code. public const string VisualBasic = "VB.NET"; + + /// The syntax identifier for strings containing XML. + public const string Xml = nameof(Xml); } } diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Diagnostics/CodeAnalysis/StringSyntaxAttributeTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Diagnostics/CodeAnalysis/StringSyntaxAttributeTests.cs index 990e9bd363b182..251156cf037986 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Diagnostics/CodeAnalysis/StringSyntaxAttributeTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Diagnostics/CodeAnalysis/StringSyntaxAttributeTests.cs @@ -8,11 +8,11 @@ namespace System.Diagnostics.CodeAnalysis.Tests public sealed class StringSyntaxAttributeTests { [Theory] + [InlineData(StringSyntaxAttribute.CSharp)] [InlineData(StringSyntaxAttribute.DateTimeFormat)] + [InlineData(StringSyntaxAttribute.FSharp)] [InlineData(StringSyntaxAttribute.Json)] [InlineData(StringSyntaxAttribute.Regex)] - [InlineData(StringSyntaxAttribute.CSharp)] - [InlineData(StringSyntaxAttribute.FSharp)] [InlineData(StringSyntaxAttribute.VisualBasic)] public void Ctor_Roundtrips(string syntax) { From 5f4287cb0db47e3f6fad6c7bef832daa5593e621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20F=C4=B1st=C4=B1k?= Date: Fri, 16 Jan 2026 09:31:55 +0100 Subject: [PATCH 5/5] Adding C#, F#, VB to StringSyntaxAttribute Change 'VB.NET' to 'Visual Basic' Fix Comments --- .../Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs | 8 ++++---- src/libraries/System.Runtime/ref/System.Runtime.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs index b4dbebf2b50be8..66c5f9b3fc4f24 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs @@ -38,7 +38,7 @@ public StringSyntaxAttribute(string syntax, params object?[] arguments) /// The syntax identifier for strings containing composite formats for string formatting. public const string CompositeFormat = nameof(CompositeFormat); - /// The syntax identifier for strings containing CSharp code. + /// The syntax identifier for strings containing C# code. public const string CSharp = "C#"; /// The syntax identifier for strings containing date format specifiers. @@ -50,7 +50,7 @@ public StringSyntaxAttribute(string syntax, params object?[] arguments) /// The syntax identifier for strings containing format specifiers. public const string EnumFormat = nameof(EnumFormat); - /// The syntax identifier for strings containing FSharp code. + /// The syntax identifier for strings containing F# code. public const string FSharp = "F#"; /// The syntax identifier for strings containing format specifiers. @@ -74,8 +74,8 @@ public StringSyntaxAttribute(string syntax, params object?[] arguments) /// The syntax identifier for strings containing URIs. public const string Uri = nameof(Uri); - /// The syntax identifier for strings containing VisualBasic code. - public const string VisualBasic = "VB.NET"; + /// The syntax identifier for strings containing Visual Basic code. + public const string VisualBasic = "Visual Basic"; /// The syntax identifier for strings containing XML. public const string Xml = nameof(Xml); diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 1b7efb78c07ec3..16fcc5f730823d 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -9108,7 +9108,7 @@ public sealed partial class StringSyntaxAttribute : System.Attribute public const string TimeOnlyFormat = "TimeOnlyFormat"; public const string TimeSpanFormat = "TimeSpanFormat"; public const string Uri = "Uri"; - public const string VisualBasic = "VB.NET"; + public const string VisualBasic = "Visual Basic"; public const string Xml = "Xml"; public StringSyntaxAttribute(string syntax) { } public StringSyntaxAttribute(string syntax, params object?[] arguments) { }