diff --git a/.github/prompts/error-consolidation.md b/.github/prompts/error-consolidation.md new file mode 100644 index 0000000000000..1705f493ff0ee --- /dev/null +++ b/.github/prompts/error-consolidation.md @@ -0,0 +1,23 @@ +# Copilot prompts to consolidate error codes. + +## 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 + +## 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. + +## 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 + +## 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. + +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 diff --git a/.openpublishing.redirection.csharp.json b/.openpublishing.redirection.csharp.json index b98367dfd9bed..976f2961e1071 100644 --- a/.openpublishing.redirection.csharp.json +++ b/.openpublishing.redirection.csharp.json @@ -363,6 +363,10 @@ "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" @@ -1834,6 +1838,70 @@ "source_path_from_root": "/docs/csharp/misc/cs1020.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" }, + { + "source_path_from_root": "/docs/csharp/misc/cs1024.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1025.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1027.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "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" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1032.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1038.md", + "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/cs1635.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, { "source_path_from_root": "/docs/csharp/misc/cs1100.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/extension-declarations" @@ -1994,10 +2062,30 @@ "source_path_from_root": "/docs/csharp/misc/cs1686.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/lambda-expression-errors#syntax-limitations-in-lambda-expressions" }, + { + "source_path_from_root": "/docs/csharp/misc/cs1692.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1694.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1695.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, + { + "source_path_from_root": "/docs/csharp/misc/cs1696.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, { "source_path_from_root": "/docs/csharp/misc/cs1706.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/lambda-expression-errors#syntax-limitations-in-lambda-expressions" }, + { + "source_path_from_root": "/docs/csharp/misc/cs1709.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/preprocessor-errors" + }, { "source_path_from_root": "/docs/csharp/misc/cs1714.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/assembly-references" diff --git a/docs/csharp/language-reference/compiler-messages/cs1029.md b/docs/csharp/language-reference/compiler-messages/cs1029.md deleted file mode 100644 index 1c07e0e7c66a6..0000000000000 --- a/docs/csharp/language-reference/compiler-messages/cs1029.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: "Compiler Error CS1029" -title: "Compiler Error CS1029" -ms.date: 07/20/2015 -f1_keywords: - - "CS1029" -helpviewer_keywords: - - "CS1029" -ms.assetid: 61bd4d44-9bfc-42bb-a9f0-a0683da53640 ---- -# Compiler Error CS1029 - -\#error: 'text' - -Displays the text of an error defined with the [#error](../preprocessor-directives.md#error-and-warning-information) directive. - -The following sample shows how to create a user-defined error: - -```csharp -// CS1029.cs -class Sample -{ - static void Main() - { - #error Let's give an error here // CS1029 - } -} -``` - -Compilation produces the following output: - -```console -example.cs(9,8): error CS1029: #error: 'Let's give an error here // CS1029 ' -``` diff --git a/docs/csharp/language-reference/compiler-messages/cs1691.md b/docs/csharp/language-reference/compiler-messages/cs1691.md deleted file mode 100644 index 22d63b48b3136..0000000000000 --- a/docs/csharp/language-reference/compiler-messages/cs1691.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -description: "Compiler Warning (level 1) CS1691" -title: "Compiler Warning (level 1) CS1691" -ms.date: 07/20/2015 -f1_keywords: - - "CS1691" -helpviewer_keywords: - - "CS1691" -ms.assetid: 7f0fea4d-4215-446c-a249-57daa7e967d2 ---- -# Compiler Warning (level 1) CS1691 - -'number' is not a valid warning number - - A number that was passed to the [#pragma warning](../preprocessor-directives.md#pragma-warning) preprocessor directive was not a valid warning number. Verify that the number represents a warning, not an error or another sequence of characters. - -## Example - - The following example generates CS1691. - -```csharp -// CS1691.cs -public class C -{ - int i = 1; - public static void Main() - { - C myC = new C(); -#pragma warning disable 151 // CS1691 -// Try the following line instead: -// #pragma warning disable 1645 - myC.i++; -#pragma warning restore 151 // CS1691 -// Try the following line instead: -// #pragma warning restore 1645 - } -} -``` diff --git a/docs/csharp/language-reference/compiler-messages/nullable-warnings.md b/docs/csharp/language-reference/compiler-messages/nullable-warnings.md index 0d35943a6ce72..759115dea1396 100644 --- a/docs/csharp/language-reference/compiler-messages/nullable-warnings.md +++ b/docs/csharp/language-reference/compiler-messages/nullable-warnings.md @@ -98,6 +98,7 @@ helpviewer_keywords: - "CS8634" - "CS8636" - "CS8637" + - "CS8668" - "CS8639" - "CS8643" - "CS8644" @@ -214,6 +215,7 @@ The following warnings indicate that you haven't set the nullable context correc - **CS8632** - *The annotation for nullable reference types should only be used in code within a `#nullable` annotations context.* - **CS8636** - *Invalid option for `/nullable`; must be `disable`, `enable`, `warnings` or `annotations`* - **CS8637** - *Expected `enable`, `disable`, or `restore`* +- **CS8668** - *Expected `warnings`, `annotations`, or end of directive* To set the nullable context correctly, you have two options: diff --git a/docs/csharp/language-reference/compiler-messages/preprocessor-errors.md b/docs/csharp/language-reference/compiler-messages/preprocessor-errors.md new file mode 100644 index 0000000000000..8b8d03f377a41 --- /dev/null +++ b/docs/csharp/language-reference/compiler-messages/preprocessor-errors.md @@ -0,0 +1,442 @@ +--- +title: Errors and warnings generated by the C# preprocessor +description: Learn how to diagnose and fix errors related to preprocessor tokens how they're used in C# source files. +f1_keywords: + - "CS1024" + - "CS1025" + - "CS1027" + - "CS1028" + - "CS1029" + - "CS1030" + - "CS1032" + - "CS1038" + - "CS1040" + - "CS1517" + - "CS1560" + - "CS1576" + - "CS1578" + - "CS1633" + - "CS1634" + - "CS1635" + - "CS1691" + - "CS1692" + - "CS1694" + - "CS1695" + - "CS1696" + - "CS1709" + - "CS7009" + - "CS7010" + - "CS7011" + - "CS8097" + - "CS8098" + - "CS8938" + - "CS8939" + - "CS8996" + - "CS9028" + - "CS9297" + - "CS9298" + - "CS9299" + - "CS9314" +helpviewer_keywords: + - "CS1024" + - "CS1025" + - "CS1027" + - "CS1028" + - "CS1029" + - "CS1030" + - "CS1032" + - "CS1038" + - "CS1040" + - "CS1517" + - "CS1560" + - "CS1576" + - "CS1578" + - "CS1633" + - "CS1634" + - "CS1635" + - "CS1691" + - "CS1692" + - "CS1694" + - "CS1695" + - "CS1696" + - "CS1709" + - "CS7009" + - "CS7010" + - "CS7011" + - "CS8097" + - "CS8098" + - "CS8938" + - "CS8939" + - "CS8996" + - "CS9028" + - "CS9297" + - "CS9298" + - "CS9299" + - "CS9314" +ms.date: 10/07/2025 +ai-usage: ai-assisted +--- +# Preprocessor errors and warnings + +The compiler generates the following errors for incorrect use of preprocessor directives: + +- [**CS1024**](#invalid-preprocessor-directive-syntax): *Preprocessor directive expected* +- [**CS1025**](#invalid-preprocessor-directive-syntax): *Single-line comment or end-of-line expected* +- [**CS1027**](#invalid-preprocessor-directive-syntax): *#endif directive expected* +- [**CS1028**](#invalid-preprocessor-directive-syntax): *Unexpected preprocessor directive* +- [**CS1029**](#error-and-warning-directive-errors): *#error: 'text'* +- [**CS1030**](#error-and-warning-directive-errors): *#warning: 'text'* +- [**CS1032**](#invalid-preprocessor-directive-syntax): *Cannot define/undefine preprocessor symbols after first token in file* +- [**CS1038**](#invalid-preprocessor-directive-syntax): *#endregion directive expected* +- [**CS1040**](#invalid-preprocessor-directive-syntax): *Preprocessor directives must appear as the first non-white-space character on a line* +- [**CS1517**](#invalid-preprocessor-directive-syntax): *Invalid preprocessor expression* +- [**CS1560**](#line-and-file-directive-errors): *Invalid filename specified for preprocessor directive. Filename is too long or not a valid filename* +- [**CS1576**](#line-and-file-directive-errors): *The line number specified for #line directive is missing or invalid* +- [**CS1578**](#line-and-file-directive-errors): *Filename, single-line comment or end-of-line expected* +- [**CS1633**](#invalid-preprocessor-directive-syntax): *Unrecognized #pragma directive* +- [**CS1634**](#error-and-warning-directive-errors): *Expected disable or restore* +- [**CS1635**](#error-and-warning-directive-errors): *Cannot restore warning 'warning code' because it was disabled globally* +- [**CS1691**](#error-and-warning-directive-errors): *'number' is not a valid warning number* +- [**CS1692**](#error-and-warning-directive-errors): *Invalid number* +- [**CS1694**](#line-and-file-directive-errors): *Invalid filename specified for preprocessor directive. Filename is too long or not a valid filename* +- [**CS1695**](#line-and-file-directive-errors): *Invalid #pragma checksum syntax; should be #pragma checksum "filename" "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" "XXXX..."* +- [**CS1696**](#invalid-preprocessor-directive-syntax): *Single-line comment or end-of-line expected* +- [**CS1709**](#line-and-file-directive-errors): *Filename specified for preprocessor directive is empty* +- [**CS7009**](#file-contains-scriptcs-directives): *Cannot use #r after first token in file* +- [**CS7010**](#file-contains-scriptcs-directives): *Quoted file name expected* +- [**CS7011**](#file-contains-scriptcs-directives): *#r is only allowed in scripts* +- [**CS8097**](#file-contains-scriptcs-directives): *#load is only allowed in scripts* +- [**CS8098**](#file-contains-scriptcs-directives): *Cannot use #load after first token in file* +- [**CS8938**](#line-and-file-directive-errors): *The #line directive value is missing or out of range* +- [**CS8939**](#line-and-file-directive-errors): *The #line directive end position must be greater than or equal to the start position* +- [**CS8996**](#invalid-preprocessor-directive-syntax): *Raw string literals are not allowed in preprocessor directives* +- [**CS9028**](#line-and-file-directive-errors): *The #line span directive requires space before the first parenthesis, before the character offset, and before the file name* +- [**CS9297**](#incorrect-use-of-file-based-apps-directives): *`#:` directives cannot be after first token in file* +- [**CS9298**](#incorrect-use-of-file-based-apps-directives): *`#:` directives can be only used in file-based programs (`-features:FileBasedProgram`)* +- [**CS9299**](#incorrect-use-of-file-based-apps-directives): *`#:` directives cannot be after `#if` directive* +- [**CS9314**](#incorrect-use-of-file-based-apps-directives): *`#!` directives can be only used in scripts or file-based programs* + +## Invalid preprocessor directive syntax + +- **CS1024**: *Preprocessor directive expected* +- **CS1025**: *Single-line comment or end-of-line expected* +- **CS1027**: *#endif directive expected* +- **CS1028**: *Unexpected preprocessor directive* +- **CS1038**: *#endregion directive expected* +- **CS1040**: *Preprocessor directives must appear as the first non-white-space character on a line* +- **CS1517**: *Invalid preprocessor expression* +- **CS1633**: *Unrecognized #pragma directive* +- **CS1696**: *Single-line comment or end-of-line expected* +- **CS8996**: *Raw string literals are not allowed in preprocessor directives* + +These errors indicate that you used invalid syntax for [preprocessor directives](../preprocessor-directives.md). Common causes include: + +- Using an unrecognized directive after `#` (CS1024, CS1633). +- Including multiline comments on directive lines (CS1025, CS1696). +- Using directives in unexpected locations (CS1028). +- Missing required matching directives (CS1027, CS1038). +- Not defining or undefining symbols as the first token in the file (CS1032) +- Not placing the directive as the first token on a line (CS1040). +- Using invalid expressions in conditional compilation (CS1517). +- Using raw string literals in preprocessor directives (CS8996). + +**CS1024 example - Preprocessor directive expected:** + +```csharp +#import System // CS1024 - "import" is not a valid directive +``` + +**CS1025 example - Single-line comment or end-of-line expected:** + +```csharp +#if true /* hello +*/ // CS1025 - multiline comment not allowed +#endif +``` + +**CS1027 example - #endif directive expected:** + +```csharp +#if true // CS1027 - missing #endif +class Test { } +``` + +**CS1028 example - Unexpected preprocessor directive:** + +```csharp +#endif // CS1028 - no matching #if +``` + +**CS1032 example - `#define` and `#undef` preprocessor directives must appear before other tokens:** + +```csharp +/* Comment */ +#define X // CS1032 - directive not first token in file +``` + +**CS1038 example - #endregion directive expected:** + +```csharp +#region testing +class Test { } +// CS1038 - missing #endregion +``` + +**CS1040 example - Preprocessor directives must appear as the first non-white-space character:** + +```csharp +/* Comment */ #define X // CS1040 - directive not first on line +``` + +**CS1517 example - Invalid preprocessor expression:** + +```csharp +#if 1 // CS1517 - numeric literals not allowed +#endif +#if ~symbol // CS1517 - bitwise operators not allowed +#endif +``` + +**CS1633 example - Unrecognized #pragma directive:** + +```csharp +#pragma unknown // CS1633 - "unknown" is not a valid pragma +``` + +**CS8996 example - Raw string literals are not allowed in preprocessor directives:** + +```csharp +// CS8996.cs +#pragma checksum """raw_string""" "{406EA660-64CF-4C82-B6F0-42D48172A799}" "hash" // CS8996 +class Test { } +``` + +To fix this error, use a regular string literal: + +```csharp +#pragma checksum "filename.cs" "{406EA660-64CF-4C82-B6F0-42D48172A799}" "hash" // OK +class Test { } +``` + +To fix these errors, ensure your preprocessor directives follow the correct syntax rules described in the [preprocessor directives documentation](../preprocessor-directives.md). + +## #error and #warning directive errors + +- **CS1029**: *#error: 'text'* +- **CS1030**: *#warning: 'text'* +- **CS1634**: *Expected disable or restore* +- **CS1635**: *Cannot restore warning 'warning code' because it was disabled globally* +- **CS1691**: *'number' is not a valid warning number* +- **CS1692**: *Invalid number* + +These errors occur when the compiler processes [`#error`](../preprocessor-directives.md#error-and-warning-information), [`#warning`](../preprocessor-directives.md#error-and-warning-information), and [`#pragma warning`](../preprocessor-directives.md#pragma-warning) directives. These directives allow you to generate custom error and warning messages during compilation and control warning behavior. + +**CS1029** displays the text of an error defined with the `#error` directive: + +```csharp +// CS1029.cs +class Sample +{ + static void Main() + { + #error Let's give an error here // CS1029 + } +} +``` + +Compilation produces the following output: + +```console +example.cs(9,8): error CS1029: #error: 'Let's give an error here // CS1029 ' +``` + +**CS1030** displays the text of a warning defined with the `#warning` directive: + +```csharp +// CS1030.cs +class Sample +{ + static void Main() + { + #warning Let's give a warning here + } +} +``` + +Compilation produces the following output: + +```console +example.cs(6,16): warning CS1030: #warning: 'Let's give a warning here' +``` + +**CS1634** occurs when a `#pragma warning` clause is badly formed, such as when disable or restore is omitted: + +```csharp +// CS1634.cs +// compile with: /W:1 + +#pragma warning // CS1634 +// Try this instead: +// #pragma warning disable 0219 + +class MyClass +{ + public static void Main() + { + } +} +``` + +**CS1635** occurs when you use the `/nowarn` command line option or project setting to disable a warning globally, but use `#pragma warning restore` to attempt to restore that warning: + +```csharp +// CS1635.cs +// compile with: /w:1 /nowarn:162 + +enum MyEnum {one=1,two=2,three=3}; + +class MyClass +{ + public static void Main() + { +#pragma warning disable 162 + + if (MyEnum.three == MyEnum.two) + System.Console.WriteLine("Duplicate"); + +#pragma warning restore 162 // CS1635 + } +} +``` + +**CS1691** occurs when a number passed to the `#pragma warning` directive is not a valid warning number: + +```csharp +// CS1691.cs +public class C +{ + int i = 1; + public static void Main() + { + C myC = new C(); +#pragma warning disable 151 // CS1691 +// Try the following line instead: +// #pragma warning disable 1645 + myC.i++; +#pragma warning restore 151 // CS1691 +// Try the following line instead: +// #pragma warning restore 1645 + } +} +``` + +**CS1692** occurs when a number in preprocessor directives like `#pragma` and `#line` is invalid because it's too large, in the wrong format, or contains illegal characters: + +```csharp +// CS1692.cs + +#pragma warning disable a // CS1692 +// Try this instead: +// #pragma warning disable 1691 + +class A +{ + static void Main() + { + } +} +``` + +These directives are useful for conditional compilation scenarios where you want to alert developers about specific conditions in the code, or control which warnings are displayed during compilation. For more information about using these directives, see the [preprocessor directives documentation](../preprocessor-directives.md#error-and-warning-information) and [#pragma warning](../preprocessor-directives.md#pragma-warning). + +## `#line` and file directive errors + +- **CS1560**: *Invalid filename specified for preprocessor directive. Filename is too long or not a valid filename* +- **CS1576**: *The line number specified for #line directive is missing or invalid* +- **CS1578**: *Filename, single-line comment or end-of-line expected* +- **CS1694**: *Invalid filename specified for preprocessor directive. Filename is too long or not a valid filename* +- **CS1695**: *Invalid #pragma checksum syntax; should be #pragma checksum "filename" "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" "XXXX..."* +- **CS1709**: *Filename specified for preprocessor directive is empty* +- **CS8938**: *The #line directive value is missing or out of range* +- **CS8939**: *The #line directive end position must be greater than or equal to the start position* +- **CS9028**: *The #line span directive requires space before the first parenthesis, before the character offset, and before the file name* + +These errors indicate incorrect usage of the [`#line` directive](../preprocessor-directives.md#error-and-warning-information) or file-related preprocessor directives. Common causes include: + +- Invalid or missing filenames (CS1560, CS1694, CS1709). +- Incorrect line number format or values (CS1576, CS8938, CS8939). +- Missing proper syntax for filenames and comments (CS1578). +- Malformed `#pragma checksum` syntax (CS1695). +- Improper spacing in `#line` span directives (CS9028). + +**CS1560/CS1694 example - Invalid filename specified:** + +```csharp +#line 100 "MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890.txt" // CS1560/CS1694 - filename too long +``` + +**CS1576 example - Line number missing or invalid:** + +```csharp +#line "abc.sc" // CS1576 - missing line number +#line abc "file.cs" // CS1576 - invalid line number format +``` + +**CS1578 example - Filename, comment or end-of-line expected:** + +```csharp +#line 101 abc.cs // CS1578 - filename not quoted +``` + +**CS1695 example - Invalid #pragma checksum syntax:** + +```csharp +#pragma checksum "12345" // CS1695 - missing GUID and checksum +``` + +**CS1709 example - Empty filename:** + +```csharp +#pragma checksum "" "{406EA660-64CF-4C82-B6F0-42D48172A799}" "" // CS1709 - empty filename +``` + +**CS8938 example - #line directive value missing or out of range:** + +```csharp +#line // CS8938 - missing value +#line 0 // CS8938 - out of range (must be 1-16,707,566) +``` + +**CS8939 example - #line end position error:** + +```csharp +#line (1, 10) - (1, 5) "file.cs" // CS8939 - end column < start column +``` + +**CS9028 example - #line span directive spacing:** + +```csharp +#line(1, 1) - (1, 10)"file.cs" // CS9028 - missing spaces +``` + +To fix these errors, ensure your `#line` directives and file-related preprocessor directives follow the correct syntax as described in the [preprocessor directives documentation](../preprocessor-directives.md). + +## Incorrect use of file-based apps directives + +- **CS9297**: *`#:` directives cannot be after first token in file* +- **CS9298**: *`#:` directives can be only used in file-based programs (`-features:FileBasedProgram`)* +- **CS9299**: *`#:` directives cannot be after `#if` directive* +- **CS9314**: *`#!` directives can be only used in scripts or file-based programs* + +These errors indicate that you used the `#:` directives for a file-based app incorrectly. You can learn more about the syntax for these directives in the article on [preprocessor directives](../preprocessor-directives.md#file-based-apps) in the section on file-based apps. Or, you can explore file based apps by following the [tutorial](../../fundamentals/tutorials/file-based-programs.md) on file-based apps. + +## File contains script.cs directives + +The following errors indicate [script.cs](https://scriptcs.net) syntax in a compiled C# file: + +- **CS7009**: *Cannot use #r after first token in file* +- **CS7010**: *Quoted file name expected* +- **CS7011**: *#r is only allowed in scripts* +- **CS8097**: *#load is only allowed in scripts* + +These directives aren't supported in compiled C#. You must remove them, or use [script.cs](http://scriptcs.net/). diff --git a/docs/csharp/language-reference/preprocessor-directives.md b/docs/csharp/language-reference/preprocessor-directives.md index 46a9fc9cea794..6d6f0625fee15 100644 --- a/docs/csharp/language-reference/preprocessor-directives.md +++ b/docs/csharp/language-reference/preprocessor-directives.md @@ -299,7 +299,7 @@ You instruct the compiler to generate user-defined compiler errors and warnings, - `#warning`: Generate a compiler warning, with a specific message. - `#line`: Change the line number printed with compiler messages. -`#error` lets you generate a [CS1029](compiler-messages/cs1029.md) user-defined error from a specific location in your code. For example: +`#error` lets you generate a [CS1029](compiler-messages/preprocessor-errors.md) user-defined error from a specific location in your code. For example: ```csharp #error Deprecated code in this method. @@ -308,7 +308,7 @@ You instruct the compiler to generate user-defined compiler errors and warnings, > [!NOTE] > The compiler treats `#error version` in a special way and reports a compiler error, CS8304, with a message containing the used compiler and language versions. -`#warning` lets you generate a [CS1030](../misc/cs1030.md) level one compiler warning from a specific location in your code. For example: +`#warning` lets you generate a [CS1030](compiler-messages/preprocessor-errors.md) level one compiler warning from a specific location in your code. For example: ```csharp #warning Deprecated code in this method. diff --git a/docs/csharp/language-reference/toc.yml b/docs/csharp/language-reference/toc.yml index 4478184281dab..a36c3d6996e81 100644 --- a/docs/csharp/language-reference/toc.yml +++ b/docs/csharp/language-reference/toc.yml @@ -460,6 +460,11 @@ items: - name: C# compiler messages href: ./compiler-messages/index.md items: + - name: Preprocessor errors + href: ./compiler-messages/preprocessor-errors.md + displayName: > + CS1024, CS1025, CS1027, CS1028, CS1029, CS1030, CS1032, CS1038, CS1040, CS1517, CS1560, CS1576, CS1578, CS1633, CS1634, + CS1635, CS1691, CS1692, CS1694, CS1695, CS1696, CS1709, CS9297, CS9298, CS9299, CS9314 - name: Feature or version missing href: ./compiler-messages/feature-version-errors.md displayName: > diff --git a/docs/csharp/misc/cs1024.md b/docs/csharp/misc/cs1024.md deleted file mode 100644 index 8ebcdbc86cb3d..0000000000000 --- a/docs/csharp/misc/cs1024.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -description: "Compiler Error CS1024" -title: "Compiler Error CS1024" -ms.date: 07/20/2015 -f1_keywords: - - "CS1024" -helpviewer_keywords: - - "CS1024" -ms.assetid: 41f587cb-1958-4eb6-9f8d-c03500e55e21 ---- -# Compiler Error CS1024 - -Preprocessor directive expected - - A line began with the pound symbol (#), but the subsequent string was not a valid [preprocessor directive](../language-reference/preprocessor-directives.md). - - The following sample generates CS1024: - -```csharp -// CS1024.cs -#import System // CS1024 -``` diff --git a/docs/csharp/misc/cs1025.md b/docs/csharp/misc/cs1025.md deleted file mode 100644 index a3a0cdb1b6786..0000000000000 --- a/docs/csharp/misc/cs1025.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -description: "Compiler Error CS1025" -title: "Compiler Error CS1025" -ms.date: 07/20/2015 -f1_keywords: - - "CS1025" -helpviewer_keywords: - - "CS1025" -ms.assetid: 491c186f-cb40-47a9-9656-44fadfa18ae2 ---- -# Compiler Error CS1025 - -Single-line comment or end-of-line expected - - A line with a [preprocessor directive](../language-reference/preprocessor-directives.md) cannot have a multiline comment. - - The following sample generates CS1025: - -```csharp -#if true /* hello -*/ // CS1025 -#endif // this is a good comment -``` - - CS1025 could also occur if you attempt some invalid preprocessor directive, as follows: - -```csharp -// CS1025.cs -#define a - -class Sample -{ - static void Main() - { - #if a 1 // CS1025, invalid syntax - System.Console.WriteLine("Hello, World!"); - #endif - } -} -``` diff --git a/docs/csharp/misc/cs1027.md b/docs/csharp/misc/cs1027.md deleted file mode 100644 index 813590500c52b..0000000000000 --- a/docs/csharp/misc/cs1027.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -description: "Compiler Error CS1027" -title: "Compiler Error CS1027" -ms.date: 07/20/2015 -f1_keywords: - - "CS1027" -helpviewer_keywords: - - "CS1027" -ms.assetid: a6657f0f-5664-47a5-95cf-803f5a0e0c90 ---- -# Compiler Error CS1027 - -\#endif directive expected - - A matching `#endif` [preprocessor directive](../language-reference/preprocessor-directives.md#conditional-compilation) was not found for a specified `#if` directive. Or, the compiler may have found a `#endregion` directive when there was no matching `#region` directive inside a `#if` block. - - The following sample generates CS1027: - -```csharp -// CS1027.cs -#if true // CS1027, uncomment next line to resolve -// #endif - -namespace x -{ - public class clx - { - public static void Main() - { - } - } -} -``` diff --git a/docs/csharp/misc/cs1028.md b/docs/csharp/misc/cs1028.md deleted file mode 100644 index 091ca2dc55f10..0000000000000 --- a/docs/csharp/misc/cs1028.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -description: "Compiler Error CS1028" -title: "Compiler Error CS1028" -ms.date: 07/20/2015 -f1_keywords: - - "CS1028" -helpviewer_keywords: - - "CS1028" -ms.assetid: 9df07db3-256f-45e9-8323-26539c55a1d8 ---- -# Compiler Error CS1028 - -Unexpected preprocessor directive - - A [preprocessor directive](../language-reference/preprocessor-directives.md) was found but not expected. - - For example, a `#endif` was found with no preceding `#if`. - - The following sample generates CS1028: - -```csharp -// CS1028.cs -#endif // CS1028, no matching #if -namespace x -{ - public class clx - { - public static void Main() - { - } - } -} -``` diff --git a/docs/csharp/misc/cs1030.md b/docs/csharp/misc/cs1030.md deleted file mode 100644 index 1db7f8596988c..0000000000000 --- a/docs/csharp/misc/cs1030.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: "Compiler Warning (level 1) CS1030" -title: "Compiler Warning (level 1) CS1030" -ms.date: 08/20/2018 -f1_keywords: - - "CS1030" -helpviewer_keywords: - - "CS1030" -ms.assetid: 7c565abc-1366-4641-9383-ab8ba026ab96 ---- -# Compiler Warning (level 1) CS1030 - -\#warning: 'text' - - Displays the text of a warning defined with the [#warning](../language-reference/preprocessor-directives.md#error-and-warning-information) directive. - - The following sample shows how to create a user-defined warning: - -```csharp -// CS1030.cs -class Sample -{ - static void Main() - { - #warning Let's give a warning here - } -} -``` - -Compilation produces the following output: - -```console -example.cs(6,16): warning CS1030: #warning: 'Let's give a warning here' -``` diff --git a/docs/csharp/misc/cs1032.md b/docs/csharp/misc/cs1032.md deleted file mode 100644 index 5852c43c50242..0000000000000 --- a/docs/csharp/misc/cs1032.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -description: "Compiler Error CS1032" -title: "Compiler Error CS1032" -ms.date: 07/20/2015 -f1_keywords: - - "CS1032" -helpviewer_keywords: - - "CS1032" -ms.assetid: fe318a6c-4403-4b9b-b3d8-753ec31c00ff ---- -# Compiler Error CS1032 - -Cannot define/undefine preprocessor symbols after first token in file - - The `#define` and `#undef` [preprocessor directives](../language-reference/preprocessor-directives.md#defining-symbols) must be used at the beginning of a program, before any other keywords, such as those used in the namespace declaration. - - The following sample generates CS1032: - -```csharp -// CS1032.cs -namespace x -{ - public class clx - { - #define a // CS1032, put before namespace - public static void Main() - { - } - } -} -``` diff --git a/docs/csharp/misc/cs1038.md b/docs/csharp/misc/cs1038.md deleted file mode 100644 index b7068911b42ce..0000000000000 --- a/docs/csharp/misc/cs1038.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -description: "Compiler Error CS1038" -title: "Compiler Error CS1038" -ms.date: 07/20/2015 -f1_keywords: - - "CS1038" -helpviewer_keywords: - - "CS1038" -ms.assetid: 05c53ae9-2819-4771-aee8-3f2ff6bcf0b0 ---- -# Compiler Error CS1038 - -\#endregion directive expected - - A [#region](../language-reference/preprocessor-directives.md#defining-regions) directive did not have a matching [#endregion](../language-reference/preprocessor-directives.md#defining-regions) directive. - - The following sample generates CS1038: - -```csharp -// CS1038.cs -#region testing - -public class clx -{ - public static void Main() - { - } -} -// CS1038 -// uncomment the next line to resolve -// #endregion -``` diff --git a/docs/csharp/misc/cs1040.md b/docs/csharp/misc/cs1040.md deleted file mode 100644 index 9090b5c1c9506..0000000000000 --- a/docs/csharp/misc/cs1040.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -description: "Compiler Error CS1040" -title: "Compiler Error CS1040" -ms.date: 07/20/2015 -f1_keywords: - - "CS1040" -helpviewer_keywords: - - "CS1040" -ms.assetid: a988d665-ead5-489f-922d-ff2c4dd8a922 ---- -# Compiler Error CS1040 - -Preprocessor directives must appear as the first non-white-space character on a line - - A [preprocessor directive](../language-reference/preprocessor-directives.md) was found on a line and was not the first token on the line. A directive must be the first token on the line. - - The following sample generates CS1040: - -```csharp -// CS1040.cs -/* Define a symbol, X */ #define X // CS1040 - -// try the following two lines instead -// /* Define a symbol, X */ -// #define X - -public class MyClass -{ - public static void Main() - { - } -} -``` diff --git a/docs/csharp/misc/cs1517.md b/docs/csharp/misc/cs1517.md deleted file mode 100644 index fcd5549811416..0000000000000 --- a/docs/csharp/misc/cs1517.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -description: "Compiler Error CS1517" -title: "Compiler Error CS1517" -ms.date: 07/20/2015 -f1_keywords: - - "CS1517" -helpviewer_keywords: - - "CS1517" -ms.assetid: 3b0201fb-8fab-4e6a-9ad9-f04c0de89517 ---- -# Compiler Error CS1517 - -Invalid preprocessor expression - - The compiler encountered an invalid preprocessor expression. - - For more information, see [Preprocessor Directives](../language-reference/preprocessor-directives.md). - - The following sample shows some valid and invalid preprocessor expressions: - -```csharp -// CS1517.cs -#if symbol // OK -#endif -#if !symbol // OK -#endif -#if (symbol) // OK -#endif -#if true // OK -#endif -#if false // OK -#endif -#if 1 // CS1517 -#endif -#if ~symbol // CS1517 -#endif -#if * // CS1517 -#endif - -class x -{ - public static void Main() - { - } -} -``` diff --git a/docs/csharp/misc/cs1560.md b/docs/csharp/misc/cs1560.md deleted file mode 100644 index 1840ee0a2a226..0000000000000 --- a/docs/csharp/misc/cs1560.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -description: "Compiler Error CS1560" -title: "Compiler Error CS1560" -ms.date: 07/20/2015 -f1_keywords: - - "CS1560" -helpviewer_keywords: - - "CS1560" -ms.assetid: 772c4543-6c8d-453f-ae3f-d333528eb8b3 ---- -# Compiler Error CS1560 - -Invalid filename specified for preprocessor directive. Filename is too long or not a valid filename - - The file name that was specified with [#line](../language-reference/preprocessor-directives.md#error-and-warning-information) exceeded _MAX_PATH (256 characters) or the line on which `#line` was found exceeded 2000 characters. - -## Example - - The following sample generates CS1560. - -```csharp -// cs1560.cs -using System; -class MyClass -{ - public static void Main() - { - Console.WriteLine("Normal line #1."); - #line 21 "MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890.txt" // CS1560 - } -} -``` diff --git a/docs/csharp/misc/cs1576.md b/docs/csharp/misc/cs1576.md deleted file mode 100644 index 40f429e803592..0000000000000 --- a/docs/csharp/misc/cs1576.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -description: "Compiler Error CS1576" -title: "Compiler Error CS1576" -ms.date: 07/20/2015 -f1_keywords: - - "CS1576" -helpviewer_keywords: - - "CS1576" -ms.assetid: 3e39cb80-e7de-4c78-a22a-57e267121a96 ---- -# Compiler Error CS1576 - -The line number specified for #line directive is missing or invalid - - The compiler detected an error with the value passed to the [#line](../language-reference/preprocessor-directives.md#error-and-warning-information) directive. - - The following sample generates CS1576: - -```csharp -// CS1576.cs -public class MyClass -{ - static void Main() - { - #line "abc.sc" // CS1576 - // try the following line instead - //#line 101 "abc.sc" - intt i; // error will be reported on line 101 - } -} -``` diff --git a/docs/csharp/misc/cs1578.md b/docs/csharp/misc/cs1578.md deleted file mode 100644 index 5dd9cfdcf3be1..0000000000000 --- a/docs/csharp/misc/cs1578.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -description: "Compiler Error CS1578" -title: "Compiler Error CS1578" -ms.date: 07/20/2015 -f1_keywords: - - "CS1578" -helpviewer_keywords: - - "CS1578" -ms.assetid: 8356cd33-5acc-4db7-8bbd-2d25f9d7728e ---- -# Compiler Error CS1578 - -Filename, single-line comment or end-of-line expected - - After a [#line](../language-reference/preprocessor-directives.md#error-and-warning-information) directive, only a file name (in double quotation marks) or a single-line comment is allowed. - - The following sample generates CS1578: - -```csharp -// CS1578.cs -class MyClass -{ - static void Main() - { - #line 101 abc.cs // CS1578 - // try the following line instead - //#line 101 "abc.cs" - intt i; // error will be reported on line 101 - } -} -``` diff --git a/docs/csharp/misc/cs1633.md b/docs/csharp/misc/cs1633.md deleted file mode 100644 index c16397abd25fd..0000000000000 --- a/docs/csharp/misc/cs1633.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -description: "Compiler Warning (level 1) CS1633" -title: "Compiler Warning (level 1) CS1633" -ms.date: 07/20/2015 -f1_keywords: - - "CS1633" -helpviewer_keywords: - - "CS1633" -ms.assetid: f31db218-f880-4fc4-ab34-8bcdc49011da ---- -# Compiler Warning (level 1) CS1633 - -Unrecognized #pragma directive - - The pragma used was not one of the known pragmas supported by the C# compiler. To resolve this error, use only pragmas supported. - - The following sample generates CS1633: - -```csharp -// CS1633.cs -// compile with: /W:1 -#pragma unknown // CS1633 - -class C -{ - public static void Main() - { - } -} -``` diff --git a/docs/csharp/misc/cs1634.md b/docs/csharp/misc/cs1634.md deleted file mode 100644 index a55a1ddf22014..0000000000000 --- a/docs/csharp/misc/cs1634.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -description: "Compiler Warning (level 1) CS1634" -title: "Compiler Warning (level 1) CS1634" -ms.date: 07/20/2015 -f1_keywords: - - "CS1634" -helpviewer_keywords: - - "CS1634" -ms.assetid: 4fd00eeb-89e3-4c18-827d-9b00a4bd8c9a ---- -# Compiler Warning (level 1) CS1634 - -Expected disable or restore - - This error occurs if a #pragma warning clause is badly formed, such as if disable or restore was omitted. For more information, see the [#pragma warning](../language-reference/preprocessor-directives.md#pragma-warning) topic. - -## Example - - The following sample generates CS1634: - -```csharp -// CS1634.cs -// compile with: /W:1 - -#pragma warning // CS1634 -// Try this instead: -// #pragma warning disable 0219 - -class MyClass -{ - public static void Main() - { - } -} -``` diff --git a/docs/csharp/misc/cs1635.md b/docs/csharp/misc/cs1635.md deleted file mode 100644 index a277214040856..0000000000000 --- a/docs/csharp/misc/cs1635.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -description: "Compiler Warning (level 1) CS1635" -title: "Compiler Warning (level 1) CS1635" -ms.date: 07/20/2015 -f1_keywords: - - "CS1635" -helpviewer_keywords: - - "CS1635" -ms.assetid: e1795880-f7ea-4dca-b15b-4ba549d7ed78 ---- -# Compiler Warning (level 1) CS1635 - -Cannot restore warning 'warning code' because it was disabled globally - - This warning occurs if you use the **/nowarn** command line option or project setting to disable a warning for the entire compilation unit, but you use `#pragma warning restore` to attempt to restore that warning. To resolve this error, remove the /nowarn command line option or project setting, or remove the `#pragma warning restore` for any warnings you are disabling via the command line or project settings. For more information, see [#pragma warning](../language-reference/preprocessor-directives.md#pragma-warning). - - The following sample generates CS1635: - -```csharp -// CS1635.cs -// compile with: /w:1 /nowarn:162 - -enum MyEnum {one=1,two=2,three=3}; - -class MyClass -{ - public static void Main() - { -#pragma warning disable 162 - - if (MyEnum.three == MyEnum.two) - System.Console.WriteLine("Duplicate"); - -#pragma warning restore 162 - } -} -``` diff --git a/docs/csharp/misc/cs1692.md b/docs/csharp/misc/cs1692.md deleted file mode 100644 index 3ea26f947c4be..0000000000000 --- a/docs/csharp/misc/cs1692.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -description: "Learn more about: Compiler Warning (level 1) CS1692" -title: "Compiler Warning (level 1) CS1692" -ms.date: 07/20/2015 -f1_keywords: - - "CS1692" -helpviewer_keywords: - - "CS1692" -ms.assetid: 1a6d52e1-0ebb-4990-ac0b-36b05a884a19 ---- - -# Compiler Warning (level 1) CS1692 - -Invalid number - -A number of preprocessor directives, such as `#pragma` and `#line`, use numbers as parameters. One of these numbers is invalid because it is too big, in the wrong format, contains illegal characters, and so on. To correct this error, correct the number. - -## Example - -The following example generates CS1692. - -```csharp -// CS1692.cs - -#pragma warning disable a // CS1692 -// Try this instead: -// #pragma warning disable 1691 - -class A -{ - static void Main() - { - } -} -``` diff --git a/docs/csharp/misc/cs1694.md b/docs/csharp/misc/cs1694.md deleted file mode 100644 index d422c19c1f83a..0000000000000 --- a/docs/csharp/misc/cs1694.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -description: "Learn more about: Compiler Warning (level 1) CS1694" -title: "Compiler Warning (level 1) CS1694" -ms.date: 07/20/2015 -f1_keywords: - - "CS1694" -helpviewer_keywords: - - "CS1694" -ms.assetid: 9cb6b5d4-36a0-4b07-9690-14b5105da44b ---- -# Compiler Warning (level 1) CS1694 - -Invalid filename specified for preprocessor directive. Filename is too long or not a valid filename. - - This warning occurs when using the `#pragma checksum` preprocessor directive. The file name specified is longer than 256 characters. To resolve this warning, use a shorter file name. - -## Example - - The following sample generates CS1694. - -```csharp -// cs1694.cs -#pragma checksum "MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890MyFile1234567890.txt" {00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F} // CS1694 -class MyClass {} -``` diff --git a/docs/csharp/misc/cs1695.md b/docs/csharp/misc/cs1695.md deleted file mode 100644 index f091fb5dfc12d..0000000000000 --- a/docs/csharp/misc/cs1695.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: "Learn more about: Compiler Warning (level 1) CS1695" -title: "Compiler Warning (level 1) CS1695" -ms.date: 07/20/2015 -f1_keywords: - - "CS1695" -helpviewer_keywords: - - "CS1695" -ms.assetid: cc4e4d00-0618-400d-985b-90968e98772c ---- -# Compiler Warning (level 1) CS1695 - -Invalid #pragma checksum syntax; should be #pragma checksum "filename" "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" "XXXX..." - - You should rarely encounter this error since the checksum is generally inserted at run time if you are generating code by means of the Code Dom API. - - However, if you were to type in this `#pragma` statement and mistype either the GUID or checksum, you would get this error. The syntax checking by the compiler does not validate that you typed in a correct GUID, but it does check for the right number of digits and delimiters, and that the digits are hexadecimal. Likewise, it verifies that the checksum contains an even number of digits, and that the digits are hexadecimal. - -## Example - - The following example generates CS1695. - -```csharp -// CS1695.cs - -#pragma checksum "12345" // CS1695 - -public class Test -{ - static void Main() - { - } -} -``` diff --git a/docs/csharp/misc/cs1696.md b/docs/csharp/misc/cs1696.md deleted file mode 100644 index a47f40b5ebd26..0000000000000 --- a/docs/csharp/misc/cs1696.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -description: "Learn more about: Compiler Warning (level 1) CS1696" -title: "Compiler Warning (level 1) CS1696" -ms.date: 07/20/2015 -f1_keywords: - - "CS1696" -helpviewer_keywords: - - "CS1696" -ms.assetid: 69a45988-1aba-4a01-a84e-7ca59f8dde28 ---- -# Compiler Warning (level 1) CS1696 - -Single-line comment or end-of-line expected - - The compiler requires a preprocessor directive to be followed by an end-of-line terminator or by a single-line comment. The compiler has finished processing a valid preprocessor directive, and has encountered something that violates this syntax constraint. - -## Example - - The following sample generates CS1696. - -```csharp -// CS1696.cs -class Test -{ - public static void Main() - { - #pragma warning disable 1030;219 // CS1696 - #pragma warning disable 1030 // OK - } -} -``` diff --git a/docs/csharp/misc/cs1709.md b/docs/csharp/misc/cs1709.md deleted file mode 100644 index 87a9883e39347..0000000000000 --- a/docs/csharp/misc/cs1709.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -description: "Learn more about: Compiler Warning (level 1) CS1709" -title: "Compiler Warning (level 1) CS1709" -ms.date: 07/20/2015 -f1_keywords: - - "CS1709" -helpviewer_keywords: - - "CS1709" -ms.assetid: e2bb1d30-4f30-4e10-82da-df1d3418454c ---- -# Compiler Warning (level 1) CS1709 - -Filename specified for preprocessor directive is empty - - You have specified a preprocessor directive that includes a file name, but that file is empty. To resolve this warning, put the needed content into the file. - -## Example - - The following example generates CS1709. - -```csharp -// CS1709.cs -class Test -{ - static void Main() - { - #pragma checksum "" "{406EA660-64CF-4C82-B6F0-42D48172A799}" "" // CS1709 - } -} -``` 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 ceefdca01b4b5..3259c0f899a1f 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 @@ -105,9 +105,6 @@ f1_keywords: - "CS4036" - "CS7002" - "CS7006" - - "CS7009" - - "CS7010" - - "CS7011" - "CS7012" - "CS7013" - "CS7014" @@ -231,8 +228,6 @@ f1_keywords: - "CS8094" - "CS8095" - "CS8096" - - "CS8097" - - "CS8098" - "CS8099" - "CS8100" - "CS8101" @@ -378,7 +373,6 @@ f1_keywords: - "CS8664" - "CS8665" - "CS8666" - - "CS8668" - "CS8669" - "CS8700" - "CS8701" @@ -483,8 +477,6 @@ f1_keywords: - "CS8934" - "CS8935" - "CS8937" - - "CS8938" - - "CS8939" - "CS8940" - "CS8941" - "CS8942" @@ -513,7 +505,6 @@ f1_keywords: - "CS8986" - "CS8987" - "CS8989" - - "CS8996" - "CS8997" - "CS8998" - "CS8999" @@ -541,7 +532,6 @@ f1_keywords: - "CS9025" - "CS9026" - "CS9027" - - "CS9028" - "CS9029" - "CS9030" - "CS9031" @@ -620,10 +610,6 @@ f1_keywords: - "CS9235" - "CS9236" # C# 14 errors begin here -## Shebang - - "CS9297" - - "CS9298" - - "CS9299" ## using `extension` as type name. (valid identifiers). - "CS9306" ## User defined operators @@ -632,10 +618,22 @@ f1_keywords: - "CS9311" - "CS9312" - "CS9313" -## Shebang - - "CS9314" ## Strings in the data section: - "CS9315" +## More extension errors + - "CS9316" + - "CS9317" + - "CS9318" + - "CS9319" + - "CS9326" + - "CS9327" + - "CS9328" + - "CS9329" + - "CS9330" + - "CS9331" + - "CS9332" + - "CS9333" + - "CS9334" helpviewer_keywords: - "errors [C#], additional information" ---