From e1338c50da70b580bae1af77a3ecd59c7d5ac6a8 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 9 Oct 2025 14:08:20 -0400 Subject: [PATCH 1/6] Incorporate existing content Consolidate existing errors and warnings into the consolidated file. --- .github/prompts/error-consolidation.md | 16 ++- .openpublishing.redirection.csharp.json | 135 ++++++++++-------- .../compiler-messages/cs1009.md | 68 --------- .../compiler-messages/string-literal.md | 128 ++++++++++++++++- docs/csharp/language-reference/toc.yml | 10 +- docs/csharp/misc/cs1011.md | 25 ---- docs/csharp/misc/cs1012.md | 39 ----- docs/csharp/misc/cs1039.md | 30 ---- ...n-t-have-specifics-on-this-csharp-error.md | 2 - 9 files changed, 214 insertions(+), 239 deletions(-) delete mode 100644 docs/csharp/language-reference/compiler-messages/cs1009.md delete mode 100644 docs/csharp/misc/cs1011.md delete mode 100644 docs/csharp/misc/cs1012.md delete mode 100644 docs/csharp/misc/cs1039.md diff --git a/.github/prompts/error-consolidation.md b/.github/prompts/error-consolidation.md index 1705f493ff0ee..8ffb7baadb315 100644 --- a/.github/prompts/error-consolidation.md +++ b/.github/prompts/error-consolidation.md @@ -1,8 +1,22 @@ # Copilot prompts to consolidate error codes. +We're going to edit this file, string-literal.md, to contain information about all errors and warnings related to string and character literal declarations. I'll write prompts for specific tasks. Don't make any edits yet. In future prompts, the destination for new error and warning content is always this file. + + ## Add a single existing file into the new consolidated article. -Add the contents of cs1027.md to the preprocessor-errors.md file, sort that file by 'source_path_from_root'. Add a redirection for cs1027.md to point to preprocessor-errors.md, add "cs1027: to the list of display names in the TOC for preprocessor-errors.md. Finally, delete cs1027.md +Start with CS1009.md as the source file. +For each source file: + +- Add the contents of the source file to the destination.md file. + - Include the source error code in the YML header for `f1_keywords` and `helpviewer_keywords`. + - Add an entry with an anchor for the error error code and its corresponding error message. + - Add the contents of the source file as a new H2 in the destination file. +- Add a redirection for the source file in the file `.openpublishing.redirection.csharp.json`. Make the destination point to destination file. Place the new entry in sorted order based on 'source_path_from_root'. +- Update the TOC file: + - Add the error code to the list of display names in the TOC for the destination file, sorted by numeric error code. + - Remove the TOC entry for the source file. +- Finally, delete the source markdown file. ## Search for other related articles that may be missed. diff --git a/.openpublishing.redirection.csharp.json b/.openpublishing.redirection.csharp.json index 976f2961e1071..a33f7459c71e8 100644 --- a/.openpublishing.redirection.csharp.json +++ b/.openpublishing.redirection.csharp.json @@ -355,18 +355,6 @@ "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs0260.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/partial-declarations" }, - { - "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1112.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/extension-declarations" - }, - { - "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1683.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/assembly-references" - }, - { - "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1691.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" - }, { "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs0270.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/array-declaration-errors" @@ -403,23 +391,46 @@ "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs0854.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/expression-tree-restrictions" }, + { + "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1009.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/string-literal" + }, { "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1019.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" }, + { + "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1029.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, { "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1063.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/array-declaration-errors" - }, { "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1067.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/partial-types" }, + { + "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1112.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/extension-declarations" + }, { "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1501.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" }, + { + "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1502.md", + "redirect_url": "/dotnet/csharp/misc/cs1503" + }, + { + "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1683.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/assembly-references" + }, + { + "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1691.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, { "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1704.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/assembly-references" @@ -1622,10 +1633,6 @@ "source_path_from_root": "/docs/csharp/misc/cs0282.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/partial-declarations" }, - { - "source_path_from_root": "/docs/csharp/misc/cs0501.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/partial-declarations" - }, { "source_path_from_root": "/docs/csharp/misc/cs0400.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/assembly-references" @@ -1650,6 +1657,10 @@ "source_path_from_root": "/docs/csharp/misc/cs0466.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/params-arrays" }, + { + "source_path_from_root": "/docs/csharp/misc/cs0501.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/partial-declarations" + }, { "source_path_from_root": "/docs/csharp/misc/cs0514.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/constructor-errors#static-constructors" @@ -1830,6 +1841,18 @@ "source_path_from_root": "/docs/csharp/misc/cs0839.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/parameter-argument-mismatch" }, + { + "source_path_from_root": "/docs/csharp/misc/cs1007.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1011.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/string-literal" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1012.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/string-literal" + }, { "source_path_from_root": "/docs/csharp/misc/cs1016.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/parameter-argument-mismatch" @@ -1854,10 +1877,6 @@ "source_path_from_root": "/docs/csharp/misc/cs1028.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" }, - { - "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1029.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" - }, { "source_path_from_root": "/docs/csharp/misc/cs1030.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" @@ -1871,35 +1890,11 @@ "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" }, { - "source_path_from_root": "/docs/csharp/misc/cs1040.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" - }, - { - "source_path_from_root": "/docs/csharp/misc/cs1517.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" - }, - { - "source_path_from_root": "/docs/csharp/misc/cs1560.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" - }, - { - "source_path_from_root": "/docs/csharp/misc/cs1576.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" - }, - { - "source_path_from_root": "/docs/csharp/misc/cs1578.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" - }, - { - "source_path_from_root": "/docs/csharp/misc/cs1633.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" - }, - { - "source_path_from_root": "/docs/csharp/misc/cs1634.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + "source_path_from_root": "/docs/csharp/misc/cs1039.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/string-literal" }, { - "source_path_from_root": "/docs/csharp/misc/cs1635.md", + "source_path_from_root": "/docs/csharp/misc/cs1040.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" }, { @@ -1930,10 +1925,6 @@ "source_path_from_root": "/docs/csharp/misc/cs1106.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/extension-declarations" }, - { - "source_path_from_root": "/docs/csharp/misc/cs1007.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" - }, { "source_path_from_root": "/docs/csharp/misc/cs1109.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/extension-declarations" @@ -1946,18 +1937,26 @@ "source_path_from_root": "/docs/csharp/misc/cs1113.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/extension-declarations" }, - { - "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1502.md", - "redirect_url": "/dotnet/csharp/misc/cs1503" - }, { "source_path_from_root": "/docs/csharp/misc/cs1510.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/ref-modifiers-errors" }, + { + "source_path_from_root": "/docs/csharp/misc/cs1517.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, { "source_path_from_root": "/docs/csharp/misc/cs1529.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/using-directive-errors" }, + { + "source_path_from_root": "/docs/csharp/misc/cs1534.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1535.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" + }, { "source_path_from_root": "/docs/csharp/misc/cs1537.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/using-directive-errors" @@ -1966,6 +1965,18 @@ "source_path_from_root": "/docs/csharp/misc/cs1552.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/array-declaration-errors" }, + { + "source_path_from_root": "/docs/csharp/misc/cs1560.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1576.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1578.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, { "source_path_from_root": "/docs/csharp/misc/cs1586.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/array-declaration-errors" @@ -2023,12 +2034,16 @@ "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/lambda-expression-errors#syntax-limitations-in-lambda-expressions" }, { - "source_path_from_root": "/docs/csharp/misc/cs1534.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" + "source_path_from_root": "/docs/csharp/misc/cs1633.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" }, { - "source_path_from_root": "/docs/csharp/misc/cs1535.md", - "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" + "source_path_from_root": "/docs/csharp/misc/cs1634.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1635.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" }, { "source_path_from_root": "/docs/csharp/misc/cs1637.md", diff --git a/docs/csharp/language-reference/compiler-messages/cs1009.md b/docs/csharp/language-reference/compiler-messages/cs1009.md deleted file mode 100644 index 6d120b58ceb23..0000000000000 --- a/docs/csharp/language-reference/compiler-messages/cs1009.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -description: "Compiler Error CS1009" -title: "Compiler Error CS1009" -ms.date: 07/20/2015 -f1_keywords: - - "CS1009" -helpviewer_keywords: - - "CS1009" -ms.assetid: 348f500c-0e4f-44d7-95a8-e215ac49940a ---- -# Compiler Error CS1009 - -Unrecognized escape sequence - - An unexpected character follows a backslash (\\) in a [string](../builtin-types/reference-types.md#the-string-type) of an [escape sequence](../../programming-guide/strings/index.md#string-escape-sequences) or character literal. The compiler expects one of the valid escape characters. For more information, see [Character Escapes](../../../standard/base-types/character-escapes-in-regular-expressions.md). - - The following sample generates CS1009. - -```csharp -// CS1009-a.cs -class MyClass -{ - static void Main() - { - // The following escape sequence causes CS1009: - string a = "\m"; - // Try the following line instead. - // string a = "\t"; - - // The following character literals causes CS1009: - // CS1009; a lowercase \u-style Unicode escape sequence must have exactly 4 hex digits - string unicodeEscapeSequence = '\u061'; - // CS1009; a hex escape sequence must start with lowercase \x - string hexEscapeSequence = '\X061'; - // CS1009; an uppercase \U-style Unicode escape sequence must have exactly 8 hex digits - string uppercaseUnicodeEscape = '\U0061'; - // CS1009; Unicode code points above U+10FFFF are invalid (well-formed but out of range) - string outOfRangeUnicode = "\U00110000"; - } -} -``` - - A common cause of this error is using the backslash character in a file name, as the following example shows. - -```csharp -string filename = "c:\myFolder\myFile.txt"; -``` - - To resolve this error, use "\\\\" or the @-quoted string literal, as the following example shows. - -```csharp -// CS1009-b.cs -class MyClass -{ - static void Main() - { - // The following line causes CS1009. - string filename = "c:\myFolder\myFile.txt"; - // Try one of the following lines instead. - // string filename = "c:\\myFolder\\myFile.txt"; - // string filename = @"c:\myFolder\myFile.txt"; - } -} -``` - -## See also - -- [string](../builtin-types/reference-types.md#the-string-type) diff --git a/docs/csharp/language-reference/compiler-messages/string-literal.md b/docs/csharp/language-reference/compiler-messages/string-literal.md index be7f5e5466a0d..4f8fc6f3629e2 100644 --- a/docs/csharp/language-reference/compiler-messages/string-literal.md +++ b/docs/csharp/language-reference/compiler-messages/string-literal.md @@ -2,10 +2,21 @@ title: Errors and warnings for string literal declarations description: This article helps you diagnose and correct compiler errors and warnings when you declare string literals as constants or variables. f1_keywords: + - "CS1009" + - "CS1011" + - "CS1012" + - "CS1039" - "CS9274" + - "CS9315" helpviewer_keywords: + - "CS1009" + - "CS1011" + - "CS1012" + - "CS1039" - "CS9274" -ms.date: 05/23/2025 + - "CS9315" +ms.date: 10/09/2025 +ai-usage: ai-assisted --- # Errors and warnings for string literal declarations @@ -14,10 +25,117 @@ There are a few *errors* related to declaring string constants or string literal -- [**CS9274**](#constant-declarations): *Cannot emit this string literal into the data section because it has XXHash128 collision with another string literal.* +- [**CS9274**](#literal-strings-in-data-sections): *Cannot emit this string literal into the data section because it has XXHash128 collision with another string literal.* +- [**CS9315**](#literal-strings-in-data-sections): *Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.* + - [**CS1009**](#cs1009-unrecognized-escape-sequence): *Unrecognized escape sequence.* + - [**CS1011**](#cs1011-empty-character-literal): *Empty character literal.* + - [**CS1012**](#cs1012-too-many-characters-in-character-literal): *Too many characters in character literal.* + - [**CS1039**](#cs1039-unterminated-string-literal): *Unterminated string literal.* -## Constant declarations +## Literal strings in data sections -- [**CS9274**](#constant-declarations): *Cannot emit this string literal into the data section because it has XXHash128 collision with another string literal.* +- **CS9274**: *Cannot emit this string literal into the data section because it has XXHash128 collision with another string literal.* +- **CS9315**: *Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.* -These errors indicate that your declaration can't be emitted in the data section. Turn this feature off for your application. +**CS9274** indicate that your declaration can't be emitted in the data section. Turn this feature off for your application. Debugging tools emit **CS9315** when the you've changed string data in the data section and your app must be restarted. + +## CS1009 - Unrecognized escape sequence + +**CS1009**: *Unrecognized escape sequence.* + +An unexpected character follows a backslash (\\) in a [string](../builtin-types/reference-types.md#the-string-type) or character literal. The compiler expects one of the valid escape characters (for example `\\n`, `\\t`, `\\uXXXX`, `\\xX`). + +Common causes: + +- Typing an invalid escape such as `"\\m"`. +- Using a Windows file path without escaping backslashes (for example `"c:\\myFolder\\myFile.txt"`). +- Malformed Unicode or hex escapes (wrong number of hex digits, wrong case for `\\x`). + +How to fix: + +- Use a valid escape sequence (`"\\t"`, `"\\n"`, etc.). +- Escape the backslash (`"c:\\myFolder\\myFile.txt"`) or use a verbatim string literal (`@"c:\myFolder\myFile.txt"`). +- Make sure `\\u` uses exactly 4 hex digits and `\\U` uses exactly 8 hex digits when used in character literals or string literals. + +Examples + +```csharp +// CS1009 examples +string a = "\m"; // CS1009 - invalid escape \m +string filename = "c:\\myFolder\\myFile.txt"; // correct: escaped backslashes +string filenameVerbatim = @"c:\myFolder\myFile.txt"; // correct: verbatim string +char unicodeChar = '\u0061'; // correct: \u must have exactly 4 hex digits +char badUnicode = '\u061'; // CS1009 - too few hex digits +``` + +## CS1011 - Empty character literal + + +## CS1039 - Unterminated string literal + +**CS1039**: *Unterminated string literal.* + +The compiler detected an ill-formed string literal that does not have a terminating quotation mark. This commonly happens with verbatim string literals (`@"..."`) when the closing quote is missing. + +How to fix: + +- Add the missing closing quotation mark for the string literal. +- For verbatim strings, ensure the final `"` is present; for regular strings, ensure any escaped quotes are properly balanced. + +Example + +```csharp +// CS1039.cs +public class MyClass +{ + public static void Main() + { + string b = @"hello, world; // CS1039 - missing closing quote + } +} +``` +**CS1011**: *Empty character literal.* + +A `char` value was declared and initialized with an empty character literal. Character literals in C# must contain exactly one character; an empty pair of single quotes (`''`) is invalid. + +Example + +```csharp +// CS1011.cs +class Sample +{ + public char CharField = ''; // CS1011 +} +``` + +## CS1012 - Too many characters in character literal + +**CS1012**: *Too many characters in character literal.* + +An attempt was made to initialize a [char](../builtin-types/char.md) with more than one character. Character literals must represent a single UTF-16 code unit. Common causes: + +- Initializing a `char` with multiple characters, e.g. `char a = 'xx';`. +- Using Unicode escape sequences representing code points above the UTF-16 range (greater than 0xFFFF) in a single character literal, e.g. `char b = '\U00010000';`. + +How to fix: + +- Use a single character in the character literal: `char c = 'x';`. +- For characters outside the BMP (above 0xFFFF), use a string with surrogate pair handling or use `System.Text.Rune` in modern APIs instead of a single `char` literal. + +Example + +```csharp +// CS1012.cs +class Sample +{ + static void Main() + { + char a = 'xx'; // CS1012 - too many characters + char b = '\U00010000'; // CS1012 - exceeds UTF-16 range (> 0xFFFF) + + char c = 'x'; // OK + char d = '\u0061'; // OK - represents 'a' within UTF-16 range + System.Console.WriteLine($"{c}, {d}"); + } +} +``` diff --git a/docs/csharp/language-reference/toc.yml b/docs/csharp/language-reference/toc.yml index a36c3d6996e81..9a3829e07ae8a 100644 --- a/docs/csharp/language-reference/toc.yml +++ b/docs/csharp/language-reference/toc.yml @@ -539,7 +539,7 @@ items: displayName: CS8509, CS9134, CS9135 - name: String literal declarations href: ./compiler-messages/string-literal.md - displayName: CS9274 + displayName: CS1009, CS1011, CS1012, CS1039, CS9274, CS9315 - name: Array declarations href: ./compiler-messages/array-declaration-errors.md displayName: > @@ -1407,14 +1407,8 @@ items: href: ../misc/cs1004.md - name: CS1008 href: ../misc/cs1008.md - - name: CS1009 - href: ./compiler-messages/cs1009.md - name: CS1010 href: ../misc/cs1010.md - - name: CS1011 - href: ../misc/cs1011.md - - name: CS1012 - href: ../misc/cs1012.md - name: CS1013 href: ../misc/cs1013.md - name: CS1014 @@ -1459,8 +1453,6 @@ items: href: ../misc/cs1037.md - name: CS1038 href: ../misc/cs1038.md - - name: CS1039 - href: ../misc/cs1039.md - name: CS1040 href: ../misc/cs1040.md - name: CS1041 diff --git a/docs/csharp/misc/cs1011.md b/docs/csharp/misc/cs1011.md deleted file mode 100644 index ef5e590c60dae..0000000000000 --- a/docs/csharp/misc/cs1011.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -description: "Compiler Error CS1011" -title: "Compiler Error CS1011" -ms.date: 07/20/2015 -f1_keywords: - - "CS1011" -helpviewer_keywords: - - "CS1011" -ms.assetid: d4568471-b0f8-4c24-89f3-9c543521d1d8 ---- -# Compiler Error CS1011 - -Empty character literal - - A [char](../language-reference/builtin-types/char.md) was declared and initialized to a null. The initialization of a `char` must specify a character. - - The following sample generates CS1011: - -```csharp -// CS1011.cs -class Sample -{ - public char CharField = ''; // CS1011 -} -``` diff --git a/docs/csharp/misc/cs1012.md b/docs/csharp/misc/cs1012.md deleted file mode 100644 index 088fcb1847e0e..0000000000000 --- a/docs/csharp/misc/cs1012.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -description: "Compiler Error CS1012" -title: "Compiler Error CS1012" -ms.date: 07/20/2015 -f1_keywords: - - "CS1012" -helpviewer_keywords: - - "CS1012" -ms.assetid: 4acc5fe0-da47-4882-b7d8-557767d7cf03 ---- -# Compiler Error CS1012 - -Too many characters in character literal - - An attempt was made to initialize a [char](../language-reference/builtin-types/char.md) constant with more than one character. CS1012 can occur when doing data binding. CS1012 can also occur when using Unicode escape sequences that exceed the UTF-16 range. A character literal represents a single character as a UTF-16 code unit, so Unicode values greater than 0xFFFF (65535) aren't valid in character literals. For example, the following code gives an error: - - `<%# DataBinder.Eval(Container.DataItem, 'doctitle') %>` - - Try the following line instead: - - `<%# DataBinder.Eval(Container.DataItem, "doctitle") %>` - - The following sample generates CS1012: - -```csharp -// CS1012.cs -class Sample -{ - static void Main() - { - char a = 'xx'; // CS1012 - too many characters - char b = '\U00010000'; // CS1012 - exceeds UTF-16 range (> 0xFFFF) - - char c = 'x'; // OK - char d = '\u0061'; // OK - represents 'a' within UTF-16 range - System.Console.WriteLine($"{c}, {d}"); - } -} -``` diff --git a/docs/csharp/misc/cs1039.md b/docs/csharp/misc/cs1039.md deleted file mode 100644 index a01758177323e..0000000000000 --- a/docs/csharp/misc/cs1039.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -description: "Compiler Error CS1039" -title: "Compiler Error CS1039" -ms.date: 07/20/2015 -f1_keywords: - - "CS1039" -helpviewer_keywords: - - "CS1039" -ms.assetid: 266e9f7f-fe17-445a-aefd-6b7795167d68 ---- -# Compiler Error CS1039 - -Unterminated string literal - - The compiler detected an ill-formed [string](../language-reference/builtin-types/reference-types.md) literal. - -## Example - - The following sample generates CS1039. To resolve the error, add the terminating quotation mark. - -```csharp -// CS1039.cs -public class MyClass -{ - public static void Main() - { - string b = @"hello, world; // CS1039 - } -} -``` diff --git a/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md b/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md index 3259c0f899a1f..9062939bb2032 100644 --- a/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md +++ b/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md @@ -618,8 +618,6 @@ f1_keywords: - "CS9311" - "CS9312" - "CS9313" -## Strings in the data section: - - "CS9315" ## More extension errors - "CS9316" - "CS9317" From 33c29f4a59929608b62270ac483b96e5f7643585 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 9 Oct 2025 15:35:20 -0400 Subject: [PATCH 2/6] Additional consolidation Search the roslyn source for related error codes. --- .github/prompts/error-consolidation.md | 13 +- .../compiler-messages/string-literal.md | 216 ++++++++++++++++++ docs/csharp/language-reference/toc.yml | 4 +- ...n-t-have-specifics-on-this-csharp-error.md | 14 -- 4 files changed, 230 insertions(+), 17 deletions(-) diff --git a/.github/prompts/error-consolidation.md b/.github/prompts/error-consolidation.md index 8ffb7baadb315..def73de772f75 100644 --- a/.github/prompts/error-consolidation.md +++ b/.github/prompts/error-consolidation.md @@ -20,11 +20,20 @@ For each source file: ## Search for other related articles that may be missed. -Search all files in the docs/csharp/language-reference/compiler-messages and the docs/csharp/misc folder for any other errors and warnings that involve preprocessor tokens. Give me a list to review for possible additional consolidation. +Search all files in the docs/csharp/language-reference/compiler-messages and the docs/csharp/misc folder for any other errors and warnings that involve string literals or constants. Give me a list to review for possible additional consolidation. ## Final search in roslyn source -To make sure you've found all related errors, we'll check the source. Look in `CSharpResources.resx` for any elements where the `` element is a message related to preprocessor tokens. The symbolic constant for that value is in the `name` attribute on the parent `data` element. Find that value in `ErrorCodes.cs`. It will map to the compiler error code, where the code is "CS" followed by the number as a four digit number. Build a list of any not already added to preprocessor-errors.md +To make sure you've found all related errors, we'll check the source. Look in `CSharpResources.resx` for any elements where the `` element is a message related to preprocessor tokens. The symbolic constant for that value is in the `name` attribute on the parent `data` element. Find that value in `ErrorCodes.cs`. It will map to the compiler error code, where the code is "CS" followed by the number as a four digit number. Build a list of any related errors, but don't make any edits yet. + +For each new file: + +- Add the new error code to the front matter of the consolidated article, for both the `f1_keywords` and `helpview_keywords` table. +- Add the new error code and error message to the table at the top of the destination article. +- Add the new error code to the list of `displaName` elements in the TOC file. +- Remove the new error code from the front matter in the file `csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-errors.md` file. + +Note that no redirections need to be added for these error codes. ## Build consolidated sections diff --git a/docs/csharp/language-reference/compiler-messages/string-literal.md b/docs/csharp/language-reference/compiler-messages/string-literal.md index 4f8fc6f3629e2..e1184b685a9dd 100644 --- a/docs/csharp/language-reference/compiler-messages/string-literal.md +++ b/docs/csharp/language-reference/compiler-messages/string-literal.md @@ -6,6 +6,20 @@ f1_keywords: - "CS1011" - "CS1012" - "CS1039" + - "CS8997" + - "CS8998" + - "CS8999" + - "CS9000" + - "CS9001" + - "CS9002" + - "CS9003" + - "CS9004" + - "CS9005" + - "CS9006" + - "CS9007" + - "CS9008" + - "CS9009" + - "CS1010" - "CS9274" - "CS9315" helpviewer_keywords: @@ -13,6 +27,20 @@ helpviewer_keywords: - "CS1011" - "CS1012" - "CS1039" + - "CS8997" + - "CS8998" + - "CS8999" + - "CS9000" + - "CS9001" + - "CS9002" + - "CS9003" + - "CS9004" + - "CS9005" + - "CS9006" + - "CS9007" + - "CS9008" + - "CS9009" + - "CS1010" - "CS9274" - "CS9315" ms.date: 10/09/2025 @@ -31,6 +59,20 @@ That's by design. The text closely matches the text of the compiler error / warn - [**CS1011**](#cs1011-empty-character-literal): *Empty character literal.* - [**CS1012**](#cs1012-too-many-characters-in-character-literal): *Too many characters in character literal.* - [**CS1039**](#cs1039-unterminated-string-literal): *Unterminated string literal.* + - [**CS8997**](#cs8997-unterminated-raw-string-literal): *Unterminated raw string literal.* + - [**CS9000**](#cs9000-raw-string-delimiter-placement): *Raw string literal delimiter must be on its own line.* + - [**CS8998**](#cs8998-too-many-quotes-for-raw-string): *Not enough starting quotes for this raw string content.* + - [**CS8999**](#cs8999-line-whitespace-mismatch): *Line does not start with the same whitespace as the closing line of the raw string literal.* + - [**CS9001**](#cs9001-rawstring-in-verbatim-interpolated-strings): *Multi-line raw string literals are only allowed in verbatim interpolated strings.* + - [**CS9002**](#cs9002-rawstring-must-contain-content): *Multi-line raw string literals must contain at least one line of content.* + - [**CS9003**](#cs9003-line-contains-different-whitespace): *Line contains different whitespace than expected.* + - [**CS9004**](#cs9004-not-enough-quotes-for-raw-string): *Not enough quotes for raw string literal.* + - [**CS9005**](#cs9005-not-enough-close-braces-for-raw-string): *Not enough closing braces for interpolated raw string literal.* + - [**CS9006**](#cs9006-too-many-open-braces-for-raw-string): *Too many opening braces for interpolated raw string literal.* + - [**CS9007**](#cs9007-too-many-close-braces-for-raw-string): *Too many closing braces for interpolated raw string literal.* + - [**CS9008**](#cs9008-illegal-at-sequence): *Sequence of '@' characters is not allowed.* + - [**CS9009**](#cs9009-string-must-start-with-quote): *String must start with quote character.* + - [**CS1010**](#cs1010-newline-in-constant): *Newline in constant.* ## Literal strings in data sections @@ -139,3 +181,177 @@ class Sample } } ``` + +## CS8997 - Unterminated raw string literal + +**CS8997**: *Unterminated raw string literal.* + +The compiler detected a raw string literal that does not have a terminating delimiter sequence. Raw string literals in C# begin and end with a sequence of three or more double-quote characters (`"""`). Multi-line raw string literals require the opening and closing delimiter sequences to be on their own lines. + +How to fix: + +- Make sure the raw string literal has a matching closing delimiter sequence using the same number of consecutive `"` characters as the opening delimiter. +- For multi-line raw string literals, place the closing delimiter on its own line and outdent the content appropriately. + +See the language reference on [raw string literals](../tokens/raw-string.md) for syntax and examples. + +Example + +```csharp +// CS8997.cs +class Sample +{ + void M() + { + var s = """This is a raw string literal +that never ends... // CS8997 - unterminated raw string literal + } +} +``` + +## CS9000 - Raw string literal delimiter must be on its own line + +**CS9000**: *Raw string literal delimiter must be on its own line.* + +This error occurs when the compiler finds an opening or closing raw string literal delimiter that isn't placed according to the multi-line raw string literal rules. In a multi-line raw string literal the opening and closing delimiter sequences must appear on lines by themselves; extra content on those lines can make the literal ill-formed. + +How to fix: + +- Move the opening or closing delimiter so it appears on a line by itself. +- Ensure that the number of quotes in the closing delimiter matches the number of quotes in the opening delimiter. + +See the language reference on [raw string literals](../tokens/raw-string.md) for syntax and examples. + +Example + +```csharp +// CS9000.cs +class Sample +{ + void M() + { + var s = """Start of raw string"""More text"""; // CS9000 - delimiter must be on its own line + } +} +``` + + +## CS8998 - Not enough starting quotes for this raw string content + +**CS8998**: *The raw string literal does not start with enough quote characters to allow this many consecutive quote characters as content.* + +Raw string literals start with a sequence of three or more double-quote characters. If the content begins with additional consecutive quotes, the compiler requires you to use more starting quotes than the minimum so the ending delimiter can be distinguished from content. + +How to fix: + +- Increase the number of starting and ending quote characters so the delimiter sequence is longer than any same-length quote run in the content. For an example and detailed guidance, see the raw string literal reference: `../tokens/raw-string.md`. + +## CS8999 - Line whitespace mismatch in raw string + +**CS8999**: *Line does not start with the same whitespace as the closing line of the raw string literal.* + +Multiline raw string literals determine the final content's indentation from the closing quote sequence. Every content line must align with that indentation rules; otherwise the compiler reports this diagnostic. + +How to fix: + +- Ensure every line of the raw string is indented so that the closing delimiter's leftmost column defines the indentation. See `../tokens/raw-string.md` for examples. + +## CS9001 - Raw string literals only in verbatim interpolated strings + +**CS9001**: *Multi-line raw string literals are only allowed in verbatim interpolated strings.* + +This diagnostic appears when a multi-line raw string is used incorrectly with interpolation or verbatim markers. + +How to fix: + +- Use a verbatim interpolated form when combining raw multiline content with interpolation, or adjust your formatting to follow the raw string literal rules in `../tokens/raw-string.md`. + +## CS9002 - Raw string must contain content + +**CS9002**: *Multi-line raw string literals must contain at least one line of content.* + +An empty raw string with only opening and closing delimiters on separate lines is not valid. Add at least one content line between the delimiters. + +How to fix: + +- Add content lines or use a single-line raw string format where applicable. See `../tokens/raw-string.md`. + +## CS9003 - Line contains different whitespace + +**CS9003**: *Line contains different whitespace than expected.* + +This is a variant of indentation/whitespace mismatch errors for raw string literals. + +How to fix: + +- Align the whitespace of all lines in the literal with the closing delimiter's indentation. + +## CS9004 - Not enough quotes for raw string literal + +**CS9004**: *Not enough quotes for raw string literal.* + +This message indicates the opening delimiter doesn't provide enough quote characters for the content; choose a longer opening delimiter. + +How to fix: + +- Increase the number of `"` characters in the opening and closing delimiters. + +## CS9005 - Not enough closing braces for interpolated raw string + +**CS9005**: *The interpolation must end with the same number of closing braces as the number of '$' characters that the raw string literal started with.* + +When using interpolated raw strings, you prefix the literal with `$` characters to indicate interpolation nesting; the same number of closing braces is required to terminate each interpolation expression. + +How to fix: + +- Use the same number of closing braces as `$` characters used to start the interpolated raw string. + +## CS9006 - Too many opening braces for interpolated raw string + +**CS9006**: *The interpolated raw string literal does not start with enough '$' characters to allow this many consecutive opening braces as content.* + +If your content contains many consecutive opening braces, the interpolated raw string must start with enough `$` characters to disambiguate them from interpolation delimiters. + +How to fix: + +- Increase the number of leading `$` characters on the raw string literal to match the maximum brace run in the content. + +## CS9007 - Too many closing braces for interpolated raw string + +**CS9007**: *The interpolated raw string literal does not start with enough '$' characters to allow this many consecutive closing braces as content.* + +Similar to CS9006 but for consecutive closing braces. + +How to fix: + +- Increase the count of leading `$` characters to allow the content's closing-brace runs. + +## CS9008 - Illegal '@' sequence + +**CS9008**: *Sequence of '@' characters is not allowed. A verbatim string or identifier can only have one '@' character and a raw string cannot have any.* + +The '@' character has special meaning for verbatim strings and identifiers; multiple '@' characters or '@' in raw strings are not valid. + +How to fix: + +- Remove extra '@' characters or use an alternative literal form. + +## CS9009 - String must start with quote character + +**CS9009**: *String must start with quote character: "* + +This diagnostic appears when a string-like token does not begin with a quote character. + +How to fix: + +- Ensure string literals begin with `"` (or the appropriate raw/verbatim delimiter). + +## CS1010 - Newline in constant + +**CS1010**: *Newline in constant.* + +This diagnostic appears when a constant literal contains an unescaped newline (for example, trying to put an actual newline inside a non-verbatim string constant). + +How to fix: + +- Use verbatim or raw string literals for multi-line content, or escape newline sequences (`\n`) in normal string literals. See `../tokens/raw-string.md` and `../tokens/verbatim.md` for guidance. diff --git a/docs/csharp/language-reference/toc.yml b/docs/csharp/language-reference/toc.yml index 9a3829e07ae8a..4b72b1a75500f 100644 --- a/docs/csharp/language-reference/toc.yml +++ b/docs/csharp/language-reference/toc.yml @@ -539,7 +539,9 @@ items: displayName: CS8509, CS9134, CS9135 - name: String literal declarations href: ./compiler-messages/string-literal.md - displayName: CS1009, CS1011, CS1012, CS1039, CS9274, CS9315 + displayName: > + CS1009, CS1010, CS1011, CS1012, CS1039, CS8997, CS8998, CS8999, CS9000, CS9001. CS9002, CS9003, CS9004, CS9005, CS9006, + CS9007, CS9008, CS9009, CS1010, CS927, CS9315 - name: Array declarations href: ./compiler-messages/array-declaration-errors.md displayName: > diff --git a/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md b/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md index 9062939bb2032..78ddbf37eee9d 100644 --- a/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md +++ b/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md @@ -505,20 +505,6 @@ f1_keywords: - "CS8986" - "CS8987" - "CS8989" - - "CS8997" - - "CS8998" - - "CS8999" - - "CS9000" - - "CS9001" - - "CS9002" - - "CS9003" - - "CS9004" - - "CS9005" - - "CS9006" - - "CS9007" - - "CS9008" - - "CS9009" - - "CS9010" - "CS9011" - "CS9012" - "CS9013" From 87d6499eaf491d731ee13433ca9b28ccebf2015e Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 9 Oct 2025 16:27:20 -0400 Subject: [PATCH 3/6] Create combined sections. Combine existing content into themes. --- .github/prompts/error-consolidation.md | 4 +- .../compiler-messages/string-literal.md | 336 ++++-------------- 2 files changed, 72 insertions(+), 268 deletions(-) diff --git a/.github/prompts/error-consolidation.md b/.github/prompts/error-consolidation.md index def73de772f75..0d6f3ea3ce497 100644 --- a/.github/prompts/error-consolidation.md +++ b/.github/prompts/error-consolidation.md @@ -37,10 +37,10 @@ Note that no redirections need to be added for these error codes. ## Build consolidated sections -Examine the highlighted section. Other H2s with similar themes should be combined in a similar format. The recommendations to fix the errors should point to language reference articles that explain the impacted syntax. +For all remaining work, all edits will be in the `string-literal.md` file. The final format should mirror the structure of the `preprocessor-errors.md` file. To do that, make a new H2 section for the theme. Remove all the H2s for the individual error codes that are part of that theme. Where applicable, the new H2 can include text or examples from the H2s you remove. The list of errors at the top of the file should remain in numerical order, so it's easy for readers to scan. Each impacted error code should now have a link to the anchor tag for the new section. Repeat the list in the new section, but without the anchors, as shown in the highlighted text. -Start with CS1024 and other errors that indicate "Not a valid preprocessor directive" \ No newline at end of file +Start with the section for all errors related to raw string literals. diff --git a/docs/csharp/language-reference/compiler-messages/string-literal.md b/docs/csharp/language-reference/compiler-messages/string-literal.md index e1184b685a9dd..6c1a57ce78a63 100644 --- a/docs/csharp/language-reference/compiler-messages/string-literal.md +++ b/docs/csharp/language-reference/compiler-messages/string-literal.md @@ -53,26 +53,26 @@ There are a few *errors* related to declaring string constants or string literal +- [**CS1009**](#string-literal-errors): *Unrecognized escape sequence.* +- [**CS1010**](#string-literal-errors): *Newline in constant.* +- [**CS1011**](#string-literal-errors): *Empty character literal.* +- [**CS1012**](#string-literal-errors): *Too many characters in character literal.* +- [**CS1039**](#string-literal-errors): *Unterminated string literal.* +- [**CS8997**](#raw-string-literal-errors): *Unterminated raw string literal.* +- [**CS8998**](#raw-string-literal-errors): *Not enough starting quotes for this raw string content.* +- [**CS8999**](#raw-string-literal-errors): *Line does not start with the same whitespace as the closing line of the raw string literal.* +- [**CS9000**](#raw-string-literal-errors): *Raw string literal delimiter must be on its own line.* +- [**CS9001**](#raw-string-literal-errors): *Multi-line raw string literals are only allowed in verbatim interpolated strings.* +- [**CS9002**](#raw-string-literal-errors): *Multi-line raw string literals must contain at least one line of content.* +- [**CS9003**](#raw-string-literal-errors): *Line contains different whitespace than expected.* +- [**CS9004**](#raw-string-literal-errors): *Not enough quotes for raw string literal.* +- [**CS9005**](#raw-string-literal-errors): *Not enough closing braces for interpolated raw string literal.* +- [**CS9006**](#raw-string-literal-errors): *Too many opening braces for interpolated raw string literal.* +- [**CS9007**](#raw-string-literal-errors): *Too many closing braces for interpolated raw string literal.* +- [**CS9008**](#raw-string-literal-errors): *Sequence of '@' characters is not allowed.* +- [**CS9009**](#raw-string-literal-errors): *String must start with quote character.* - [**CS9274**](#literal-strings-in-data-sections): *Cannot emit this string literal into the data section because it has XXHash128 collision with another string literal.* - [**CS9315**](#literal-strings-in-data-sections): *Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.* - - [**CS1009**](#cs1009-unrecognized-escape-sequence): *Unrecognized escape sequence.* - - [**CS1011**](#cs1011-empty-character-literal): *Empty character literal.* - - [**CS1012**](#cs1012-too-many-characters-in-character-literal): *Too many characters in character literal.* - - [**CS1039**](#cs1039-unterminated-string-literal): *Unterminated string literal.* - - [**CS8997**](#cs8997-unterminated-raw-string-literal): *Unterminated raw string literal.* - - [**CS9000**](#cs9000-raw-string-delimiter-placement): *Raw string literal delimiter must be on its own line.* - - [**CS8998**](#cs8998-too-many-quotes-for-raw-string): *Not enough starting quotes for this raw string content.* - - [**CS8999**](#cs8999-line-whitespace-mismatch): *Line does not start with the same whitespace as the closing line of the raw string literal.* - - [**CS9001**](#cs9001-rawstring-in-verbatim-interpolated-strings): *Multi-line raw string literals are only allowed in verbatim interpolated strings.* - - [**CS9002**](#cs9002-rawstring-must-contain-content): *Multi-line raw string literals must contain at least one line of content.* - - [**CS9003**](#cs9003-line-contains-different-whitespace): *Line contains different whitespace than expected.* - - [**CS9004**](#cs9004-not-enough-quotes-for-raw-string): *Not enough quotes for raw string literal.* - - [**CS9005**](#cs9005-not-enough-close-braces-for-raw-string): *Not enough closing braces for interpolated raw string literal.* - - [**CS9006**](#cs9006-too-many-open-braces-for-raw-string): *Too many opening braces for interpolated raw string literal.* - - [**CS9007**](#cs9007-too-many-close-braces-for-raw-string): *Too many closing braces for interpolated raw string literal.* - - [**CS9008**](#cs9008-illegal-at-sequence): *Sequence of '@' characters is not allowed.* - - [**CS9009**](#cs9009-string-must-start-with-quote): *String must start with quote character.* - - [**CS1010**](#cs1010-newline-in-constant): *Newline in constant.* ## Literal strings in data sections @@ -81,277 +81,81 @@ That's by design. The text closely matches the text of the compiler error / warn **CS9274** indicate that your declaration can't be emitted in the data section. Turn this feature off for your application. Debugging tools emit **CS9315** when the you've changed string data in the data section and your app must be restarted. -## CS1009 - Unrecognized escape sequence +## String literal errors -**CS1009**: *Unrecognized escape sequence.* +The following errors concern string and character literal syntax and common mistakes when declaring literal values. They are grouped here so you can review related diagnostics together. -An unexpected character follows a backslash (\\) in a [string](../builtin-types/reference-types.md#the-string-type) or character literal. The compiler expects one of the valid escape characters (for example `\\n`, `\\t`, `\\uXXXX`, `\\xX`). +- **CS1009** - *Unrecognized escape sequence.* +- **CS1010** - *Newline in constant.* +- **CS1011** - *Empty character literal.* +- **CS1012** - *Too many characters in character literal.* +- **CS1039** - *Unterminated string literal.* -Common causes: +Common causes and fixes: -- Typing an invalid escape such as `"\\m"`. -- Using a Windows file path without escaping backslashes (for example `"c:\\myFolder\\myFile.txt"`). -- Malformed Unicode or hex escapes (wrong number of hex digits, wrong case for `\\x`). - -How to fix: - -- Use a valid escape sequence (`"\\t"`, `"\\n"`, etc.). -- Escape the backslash (`"c:\\myFolder\\myFile.txt"`) or use a verbatim string literal (`@"c:\myFolder\myFile.txt"`). -- Make sure `\\u` uses exactly 4 hex digits and `\\U` uses exactly 8 hex digits when used in character literals or string literals. +- Invalid escape sequences: An unexpected character follows a backslash (`\\`). Use valid escapes (`\\n`, `\\t`, `\\uXXXX`, `\\xX`) or use verbatim (`@"..."`) or raw string literals for content that includes backslashes. +- Empty or multi-character char literals: Character literals must contain exactly one UTF-16 code unit. Use a single character like `'x'` or a string / `System.Text.Rune` for characters outside the BMP. +- Unterminated strings: Ensure every string or verbatim string has a matching closing quote. For verbatim strings, the final `"` must be present; for normal strings ensure escaped quotes are balanced. +- A string literal spans multiple lines of C# source. Examples ```csharp -// CS1009 examples -string a = "\m"; // CS1009 - invalid escape \m -string filename = "c:\\myFolder\\myFile.txt"; // correct: escaped backslashes -string filenameVerbatim = @"c:\myFolder\myFile.txt"; // correct: verbatim string -char unicodeChar = '\u0061'; // correct: \u must have exactly 4 hex digits -char badUnicode = '\u061'; // CS1009 - too few hex digits -``` - -## CS1011 - Empty character literal - - -## CS1039 - Unterminated string literal +// CS1009 - invalid escape +string a = "\\m"; // CS1009 - invalid escape \m -**CS1039**: *Unterminated string literal.* - -The compiler detected an ill-formed string literal that does not have a terminating quotation mark. This commonly happens with verbatim string literals (`@"..."`) when the closing quote is missing. - -How to fix: - -- Add the missing closing quotation mark for the string literal. -- For verbatim strings, ensure the final `"` is present; for regular strings, ensure any escaped quotes are properly balanced. - -Example - -```csharp -// CS1039.cs -public class MyClass -{ - public static void Main() - { - string b = @"hello, world; // CS1039 - missing closing quote - } -} -``` -**CS1011**: *Empty character literal.* +// Use verbatim strings or escape backslashes +string filename = "c:\\myFolder\\myFile.txt"; // escaped backslashes +string filenameVerbatim = @"c:\myFolder\myFile.txt"; // verbatim string -A `char` value was declared and initialized with an empty character literal. Character literals in C# must contain exactly one character; an empty pair of single quotes (`''`) is invalid. +// CS1011 - empty character literal +// public char CharField = ''; // CS1011 - invalid: empty character literal -Example +// CS1012 - too many characters in char literal +char a = 'xx'; // CS1012 - too many characters -```csharp -// CS1011.cs -class Sample -{ - public char CharField = ''; // CS1011 -} +// CS1039 - unterminated verbatim string +// string b = @"hello, world; // CS1039 - missing closing quote ``` -## CS1012 - Too many characters in character literal +See the articles on [verbatim strings](../tokens/verbatim.md) and [raw strings](../tokens/raw-string.md) for more guidance on literal strings and escape sequences. -**CS1012**: *Too many characters in character literal.* +## Raw string literal errors -An attempt was made to initialize a [char](../builtin-types/char.md) with more than one character. Character literals must represent a single UTF-16 code unit. Common causes: +The following errors are related to raw string literal syntax and usage. They are listed here so readers can see the family of diagnostics together and learn about common causes and fixes. -- Initializing a `char` with multiple characters, e.g. `char a = 'xx';`. -- Using Unicode escape sequences representing code points above the UTF-16 range (greater than 0xFFFF) in a single character literal, e.g. `char b = '\U00010000';`. +- **CS8997** - *Unterminated raw string literal.* +- **CS8998** - *Not enough starting quotes for this raw string content.* +- **CS8999** - *Line does not start with the same whitespace as the closing line of the raw string literal.* +- **CS9000** - *Raw string literal delimiter must be on its own line.* +- **CS9001** - *Multi-line raw string literals are only allowed in verbatim interpolated strings.* +- **CS9002** - *Multi-line raw string literals must contain at least one line of content.* +- **CS9003** - *Line contains different whitespace than expected.* +- **CS9004** - *Not enough quotes for raw string literal.* +- **CS9005** - *Not enough closing braces for interpolated raw string literal.* +- **CS9006** - *Too many opening braces for interpolated raw string literal.* +- **CS9007** - *Too many closing braces for interpolated raw string literal.* +- **CS9008** - *Sequence of '`@`' characters is not allowed.* +- **CS9009** - *String must start with quote character.* -How to fix: +Check these common causes and fixes: -- Use a single character in the character literal: `char c = 'x';`. -- For characters outside the BMP (above 0xFFFF), use a string with surrogate pair handling or use `System.Text.Rune` in modern APIs instead of a single `char` literal. +- Unterminated or mismatched delimiters: Ensure your raw string starts and ends with the same number of consecutive double quotes (`"`). For multi-line raw strings, the opening and closing delimiter lines must appear on their own lines. +- Indentation and whitespace mismatch: The indentation of the closing delimiter defines the trimming of common leading whitespace for content lines. Make sure content lines align with that indentation. +- Insufficient quote or `$` counts for content: If the content begins with runs of quote characters or brace characters, increase the length of the delimiter (more `"`) or the number of leading `$` characters for interpolated raw strings so content can't be confused with delimiters or interpolation. +- Illegal characters or sequences: Avoid multiple `@` characters for verbatim/raw combinations and ensure you use verbatim interpolated forms when combining interpolation with multi-line raw strings. -Example +The following shows a few examples of incorrectly formed raw string literals. ```csharp -// CS1012.cs -class Sample -{ - static void Main() - { - char a = 'xx'; // CS1012 - too many characters - char b = '\U00010000'; // CS1012 - exceeds UTF-16 range (> 0xFFFF) - - char c = 'x'; // OK - char d = '\u0061'; // OK - represents 'a' within UTF-16 range - System.Console.WriteLine($"{c}, {d}"); - } -} -``` - -## CS8997 - Unterminated raw string literal - -**CS8997**: *Unterminated raw string literal.* +// Unterminated raw string (CS8997) +var s = """This raw string never ends... -The compiler detected a raw string literal that does not have a terminating delimiter sequence. Raw string literals in C# begin and end with a sequence of three or more double-quote characters (`"""`). Multi-line raw string literals require the opening and closing delimiter sequences to be on their own lines. +// Delimiter must be on its own line (CS9000) +var t = """First line"""More text"""; -How to fix: - -- Make sure the raw string literal has a matching closing delimiter sequence using the same number of consecutive `"` characters as the opening delimiter. -- For multi-line raw string literals, place the closing delimiter on its own line and outdent the content appropriately. - -See the language reference on [raw string literals](../tokens/raw-string.md) for syntax and examples. - -Example - -```csharp -// CS8997.cs -class Sample -{ - void M() - { - var s = """This is a raw string literal -that never ends... // CS8997 - unterminated raw string literal - } -} +// Use more quotes when content contains quote runs (CS8998 / CS9004) +var u = """""content with """ quotes"""""; // use 5 quotes to allow 3 consecutive quotes in content ``` -## CS9000 - Raw string literal delimiter must be on its own line - -**CS9000**: *Raw string literal delimiter must be on its own line.* - -This error occurs when the compiler finds an opening or closing raw string literal delimiter that isn't placed according to the multi-line raw string literal rules. In a multi-line raw string literal the opening and closing delimiter sequences must appear on lines by themselves; extra content on those lines can make the literal ill-formed. - -How to fix: - -- Move the opening or closing delimiter so it appears on a line by itself. -- Ensure that the number of quotes in the closing delimiter matches the number of quotes in the opening delimiter. - -See the language reference on [raw string literals](../tokens/raw-string.md) for syntax and examples. - -Example - -```csharp -// CS9000.cs -class Sample -{ - void M() - { - var s = """Start of raw string"""More text"""; // CS9000 - delimiter must be on its own line - } -} -``` - - -## CS8998 - Not enough starting quotes for this raw string content - -**CS8998**: *The raw string literal does not start with enough quote characters to allow this many consecutive quote characters as content.* - -Raw string literals start with a sequence of three or more double-quote characters. If the content begins with additional consecutive quotes, the compiler requires you to use more starting quotes than the minimum so the ending delimiter can be distinguished from content. - -How to fix: - -- Increase the number of starting and ending quote characters so the delimiter sequence is longer than any same-length quote run in the content. For an example and detailed guidance, see the raw string literal reference: `../tokens/raw-string.md`. - -## CS8999 - Line whitespace mismatch in raw string - -**CS8999**: *Line does not start with the same whitespace as the closing line of the raw string literal.* - -Multiline raw string literals determine the final content's indentation from the closing quote sequence. Every content line must align with that indentation rules; otherwise the compiler reports this diagnostic. - -How to fix: - -- Ensure every line of the raw string is indented so that the closing delimiter's leftmost column defines the indentation. See `../tokens/raw-string.md` for examples. - -## CS9001 - Raw string literals only in verbatim interpolated strings - -**CS9001**: *Multi-line raw string literals are only allowed in verbatim interpolated strings.* - -This diagnostic appears when a multi-line raw string is used incorrectly with interpolation or verbatim markers. - -How to fix: - -- Use a verbatim interpolated form when combining raw multiline content with interpolation, or adjust your formatting to follow the raw string literal rules in `../tokens/raw-string.md`. - -## CS9002 - Raw string must contain content - -**CS9002**: *Multi-line raw string literals must contain at least one line of content.* - -An empty raw string with only opening and closing delimiters on separate lines is not valid. Add at least one content line between the delimiters. - -How to fix: - -- Add content lines or use a single-line raw string format where applicable. See `../tokens/raw-string.md`. - -## CS9003 - Line contains different whitespace - -**CS9003**: *Line contains different whitespace than expected.* - -This is a variant of indentation/whitespace mismatch errors for raw string literals. - -How to fix: - -- Align the whitespace of all lines in the literal with the closing delimiter's indentation. - -## CS9004 - Not enough quotes for raw string literal - -**CS9004**: *Not enough quotes for raw string literal.* - -This message indicates the opening delimiter doesn't provide enough quote characters for the content; choose a longer opening delimiter. - -How to fix: - -- Increase the number of `"` characters in the opening and closing delimiters. - -## CS9005 - Not enough closing braces for interpolated raw string - -**CS9005**: *The interpolation must end with the same number of closing braces as the number of '$' characters that the raw string literal started with.* - -When using interpolated raw strings, you prefix the literal with `$` characters to indicate interpolation nesting; the same number of closing braces is required to terminate each interpolation expression. - -How to fix: - -- Use the same number of closing braces as `$` characters used to start the interpolated raw string. - -## CS9006 - Too many opening braces for interpolated raw string - -**CS9006**: *The interpolated raw string literal does not start with enough '$' characters to allow this many consecutive opening braces as content.* - -If your content contains many consecutive opening braces, the interpolated raw string must start with enough `$` characters to disambiguate them from interpolation delimiters. - -How to fix: - -- Increase the number of leading `$` characters on the raw string literal to match the maximum brace run in the content. - -## CS9007 - Too many closing braces for interpolated raw string - -**CS9007**: *The interpolated raw string literal does not start with enough '$' characters to allow this many consecutive closing braces as content.* - -Similar to CS9006 but for consecutive closing braces. - -How to fix: - -- Increase the count of leading `$` characters to allow the content's closing-brace runs. - -## CS9008 - Illegal '@' sequence - -**CS9008**: *Sequence of '@' characters is not allowed. A verbatim string or identifier can only have one '@' character and a raw string cannot have any.* - -The '@' character has special meaning for verbatim strings and identifiers; multiple '@' characters or '@' in raw strings are not valid. - -How to fix: - -- Remove extra '@' characters or use an alternative literal form. - -## CS9009 - String must start with quote character - -**CS9009**: *String must start with quote character: "* - -This diagnostic appears when a string-like token does not begin with a quote character. - -How to fix: - -- Ensure string literals begin with `"` (or the appropriate raw/verbatim delimiter). - -## CS1010 - Newline in constant - -**CS1010**: *Newline in constant.* - -This diagnostic appears when a constant literal contains an unescaped newline (for example, trying to put an actual newline inside a non-verbatim string constant). - -How to fix: - -- Use verbatim or raw string literals for multi-line content, or escape newline sequences (`\n`) in normal string literals. See `../tokens/raw-string.md` and `../tokens/verbatim.md` for guidance. +For full syntax and more examples, see the [language reference on raw string literals](../tokens/raw-string.md). From 587359aa08bbddc64334d73f304819b1ed1b66a6 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 9 Oct 2025 16:37:00 -0400 Subject: [PATCH 4/6] I hate YAML --- docs/csharp/language-reference/toc.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/csharp/language-reference/toc.yml b/docs/csharp/language-reference/toc.yml index 4b72b1a75500f..8ec3069f47b5b 100644 --- a/docs/csharp/language-reference/toc.yml +++ b/docs/csharp/language-reference/toc.yml @@ -539,9 +539,9 @@ items: displayName: CS8509, CS9134, CS9135 - name: String literal declarations href: ./compiler-messages/string-literal.md - displayName: > - CS1009, CS1010, CS1011, CS1012, CS1039, CS8997, CS8998, CS8999, CS9000, CS9001. CS9002, CS9003, CS9004, CS9005, CS9006, - CS9007, CS9008, CS9009, CS1010, CS927, CS9315 + displayName: > + CS1009, CS1010, CS1011, CS1012, CS1039, CS8997, CS8998, CS8999, CS9000, CS9001. CS9002, CS9003, CS9004, CS9005, CS9006, + CS9007, CS9008, CS9009, CS1010, CS927, CS9315 - name: Array declarations href: ./compiler-messages/array-declaration-errors.md displayName: > From 4099726c76ef8dc9e99df9a2bcb97ea6198e63a3 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 9 Oct 2025 17:02:34 -0400 Subject: [PATCH 5/6] Final proofread and update prompts. --- .github/prompts/error-consolidation.md | 4 +- .../compiler-messages/string-literal.md | 71 ++++++++++--------- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/.github/prompts/error-consolidation.md b/.github/prompts/error-consolidation.md index 0d6f3ea3ce497..1660f67f1bd7e 100644 --- a/.github/prompts/error-consolidation.md +++ b/.github/prompts/error-consolidation.md @@ -37,9 +37,9 @@ Note that no redirections need to be added for these error codes. ## Build consolidated sections -For all remaining work, all edits will be in the `string-literal.md` file. The final format should mirror the structure of the `preprocessor-errors.md` file. +For all remaining work, all edits will be in the `string-literal.md` file. The final format should mirror the structure of the `preprocessor-errors.md` file. Every H2 is a theme, all anchors are for the theme, not an individual error code. -To do that, make a new H2 section for the theme. Remove all the H2s for the individual error codes that are part of that theme. Where applicable, the new H2 can include text or examples from the H2s you remove. +To do that, make a new H2 section for the theme. Remove all the H2s for the individual error codes that are part of that theme. Where applicable, the new H2 can include text or examples from the H2s you remove. The new section should include links to language reference articles that discuss the feature or theme. The list of errors at the top of the file should remain in numerical order, so it's easy for readers to scan. Each impacted error code should now have a link to the anchor tag for the new section. Repeat the list in the new section, but without the anchors, as shown in the highlighted text. diff --git a/docs/csharp/language-reference/compiler-messages/string-literal.md b/docs/csharp/language-reference/compiler-messages/string-literal.md index 6c1a57ce78a63..0fb2f9ec076d9 100644 --- a/docs/csharp/language-reference/compiler-messages/string-literal.md +++ b/docs/csharp/language-reference/compiler-messages/string-literal.md @@ -48,42 +48,37 @@ ai-usage: ai-assisted --- # Errors and warnings for string literal declarations -There are a few *errors* related to declaring string constants or string literals. +There are several errors related to declaring string constants or string literals. -- [**CS1009**](#string-literal-errors): *Unrecognized escape sequence.* -- [**CS1010**](#string-literal-errors): *Newline in constant.* -- [**CS1011**](#string-literal-errors): *Empty character literal.* -- [**CS1012**](#string-literal-errors): *Too many characters in character literal.* -- [**CS1039**](#string-literal-errors): *Unterminated string literal.* -- [**CS8997**](#raw-string-literal-errors): *Unterminated raw string literal.* -- [**CS8998**](#raw-string-literal-errors): *Not enough starting quotes for this raw string content.* -- [**CS8999**](#raw-string-literal-errors): *Line does not start with the same whitespace as the closing line of the raw string literal.* -- [**CS9000**](#raw-string-literal-errors): *Raw string literal delimiter must be on its own line.* -- [**CS9001**](#raw-string-literal-errors): *Multi-line raw string literals are only allowed in verbatim interpolated strings.* -- [**CS9002**](#raw-string-literal-errors): *Multi-line raw string literals must contain at least one line of content.* -- [**CS9003**](#raw-string-literal-errors): *Line contains different whitespace than expected.* -- [**CS9004**](#raw-string-literal-errors): *Not enough quotes for raw string literal.* -- [**CS9005**](#raw-string-literal-errors): *Not enough closing braces for interpolated raw string literal.* -- [**CS9006**](#raw-string-literal-errors): *Too many opening braces for interpolated raw string literal.* -- [**CS9007**](#raw-string-literal-errors): *Too many closing braces for interpolated raw string literal.* -- [**CS9008**](#raw-string-literal-errors): *Sequence of '@' characters is not allowed.* -- [**CS9009**](#raw-string-literal-errors): *String must start with quote character.* +- [**CS1009**](#incorrectly-formed-string-literals): *Unrecognized escape sequence.* +- [**CS1010**](#incorrectly-formed-string-literals): *Newline in constant.* +- [**CS1011**](#incorrectly-formed-string-literals): *Empty character literal.* +- [**CS1012**](#incorrectly-formed-string-literals): *Too many characters in character literal.* +- [**CS1039**](#incorrectly-formed-string-literals): *Unterminated string literal.* +- [**CS8997**](#incorrectly-formed-raw-string-literals): *Unterminated raw string literal.* +- [**CS8998**](#incorrectly-formed-raw-string-literals): *Not enough starting quotes for this raw string content.* +- [**CS8999**](#incorrectly-formed-raw-string-literals): *Line does not start with the same whitespace as the closing line of the raw string literal.* +- [**CS9000**](#incorrectly-formed-raw-string-literals): *Raw string literal delimiter must be on its own line.* +- [**CS9001**](#incorrectly-formed-raw-string-literals): *Multi-line raw string literals are only allowed in verbatim interpolated strings.* +- [**CS9002**](#incorrectly-formed-raw-string-literals): *Multi-line raw string literals must contain at least one line of content.* +- [**CS9003**](#incorrectly-formed-raw-string-literals): *Line contains different whitespace than expected.* +- [**CS9004**](#incorrectly-formed-raw-string-literals): *Not enough quotes for raw string literal.* +- [**CS9005**](#incorrectly-formed-raw-string-literals): *Not enough closing braces for interpolated raw string literal.* +- [**CS9006**](#incorrectly-formed-raw-string-literals): *Too many opening braces for interpolated raw string literal.* +- [**CS9007**](#incorrectly-formed-raw-string-literals): *Too many closing braces for interpolated raw string literal.* +- [**CS9008**](#incorrectly-formed-raw-string-literals): *Sequence of '@' characters is not allowed.* +- [**CS9009**](#incorrectly-formed-raw-string-literals): *String must start with quote character.* - [**CS9274**](#literal-strings-in-data-sections): *Cannot emit this string literal into the data section because it has XXHash128 collision with another string literal.* - [**CS9315**](#literal-strings-in-data-sections): *Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.* -## Literal strings in data sections - -- **CS9274**: *Cannot emit this string literal into the data section because it has XXHash128 collision with another string literal.* -- **CS9315**: *Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.* - -**CS9274** indicate that your declaration can't be emitted in the data section. Turn this feature off for your application. Debugging tools emit **CS9315** when the you've changed string data in the data section and your app must be restarted. +The following sections provide examples of common issues and how to fix them. -## String literal errors +## Incorrectly formed string literals -The following errors concern string and character literal syntax and common mistakes when declaring literal values. They are grouped here so you can review related diagnostics together. +The following errors concern string and character literal syntax and common mistakes when declaring literal values. - **CS1009** - *Unrecognized escape sequence.* - **CS1010** - *Newline in constant.* @@ -118,11 +113,11 @@ char a = 'xx'; // CS1012 - too many characters // string b = @"hello, world; // CS1039 - missing closing quote ``` -See the articles on [verbatim strings](../tokens/verbatim.md) and [raw strings](../tokens/raw-string.md) for more guidance on literal strings and escape sequences. +For more information on literal strings and escape sequences, see the articles on [verbatim strings](../tokens/verbatim.md) and [raw strings](../tokens/raw-string.md). -## Raw string literal errors +## Incorrectly formed raw string literals -The following errors are related to raw string literal syntax and usage. They are listed here so readers can see the family of diagnostics together and learn about common causes and fixes. +The following errors are related to raw string literal syntax and usage. - **CS8997** - *Unterminated raw string literal.* - **CS8998** - *Not enough starting quotes for this raw string content.* @@ -145,17 +140,23 @@ Check these common causes and fixes: - Insufficient quote or `$` counts for content: If the content begins with runs of quote characters or brace characters, increase the length of the delimiter (more `"`) or the number of leading `$` characters for interpolated raw strings so content can't be confused with delimiters or interpolation. - Illegal characters or sequences: Avoid multiple `@` characters for verbatim/raw combinations and ensure you use verbatim interpolated forms when combining interpolation with multi-line raw strings. -The following shows a few examples of incorrectly formed raw string literals. +The following code shows a few examples of incorrectly formed raw string literals. ```csharp // Unterminated raw string (CS8997) var s = """This raw string never ends... // Delimiter must be on its own line (CS9000) -var t = """First line"""More text"""; - -// Use more quotes when content contains quote runs (CS8998 / CS9004) -var u = """""content with """ quotes"""""; // use 5 quotes to allow 3 consecutive quotes in content +var t = """First line + More text + """; ``` For full syntax and more examples, see the [language reference on raw string literals](../tokens/raw-string.md). + +## Literal strings in data sections + +- **CS9274**: *Cannot emit this string literal into the data section because it has XXHash128 collision with another string literal.* +- **CS9315**: *Combined length of user strings used by the program exceeds allowed limit. Adding a string literal requires restarting the application.* + +**CS9274** indicate that your declaration can't be emitted in the data section. Disable this feature for your application. Debugging tools emit **CS9315** after you changed string data in the data section while debugging and your app must be restarted. From e1ffa36133bc9ebcff39361912a9cfba63626849 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 9 Oct 2025 17:05:14 -0400 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../language-reference/compiler-messages/string-literal.md | 2 +- docs/csharp/language-reference/toc.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/csharp/language-reference/compiler-messages/string-literal.md b/docs/csharp/language-reference/compiler-messages/string-literal.md index 0fb2f9ec076d9..396966581ceb0 100644 --- a/docs/csharp/language-reference/compiler-messages/string-literal.md +++ b/docs/csharp/language-reference/compiler-messages/string-literal.md @@ -130,7 +130,7 @@ The following errors are related to raw string literal syntax and usage. - **CS9005** - *Not enough closing braces for interpolated raw string literal.* - **CS9006** - *Too many opening braces for interpolated raw string literal.* - **CS9007** - *Too many closing braces for interpolated raw string literal.* -- **CS9008** - *Sequence of '`@`' characters is not allowed.* +- **CS9008** - *Sequence of '@' characters is not allowed.* - **CS9009** - *String must start with quote character.* Check these common causes and fixes: diff --git a/docs/csharp/language-reference/toc.yml b/docs/csharp/language-reference/toc.yml index 8ec3069f47b5b..7e3f7d8b51acd 100644 --- a/docs/csharp/language-reference/toc.yml +++ b/docs/csharp/language-reference/toc.yml @@ -540,8 +540,8 @@ items: - name: String literal declarations href: ./compiler-messages/string-literal.md displayName: > - CS1009, CS1010, CS1011, CS1012, CS1039, CS8997, CS8998, CS8999, CS9000, CS9001. CS9002, CS9003, CS9004, CS9005, CS9006, - CS9007, CS9008, CS9009, CS1010, CS927, CS9315 + CS1009, CS1010, CS1011, CS1012, CS1039, CS8997, CS8998, CS8999, CS9000, CS9001, CS9002, CS9003, CS9004, CS9005, CS9006, + CS9007, CS9008, CS9009, CS9274, CS9315 - name: Array declarations href: ./compiler-messages/array-declaration-errors.md displayName: >