-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Initial page of CS8802 error #43728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
BillWagner
merged 5 commits into
dotnet:main
from
BartoszKlonowski:feature/38811/cs8802-initial-page
Nov 26, 2024
Merged
Initial page of CS8802 error #43728
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fc45011
Create initial page of CS8802
BartoszKlonowski 25650f3
Link CS8803 and top-level statements to the page
BartoszKlonowski 2feb89d
Correct the ms.date in CS8802 page metadata
BartoszKlonowski a9f5610
Remove CS8802 from list of missing pages
BartoszKlonowski 9d7cb83
Remove solution from single compilation unit explanation
BartoszKlonowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
docs/csharp/language-reference/compiler-messages/cs8802.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| --- | ||
| description: "Compiler Error CS8802" | ||
| title: "Compiler Error CS8802" | ||
| ms.date: 7/01/2024 | ||
| f1_keywords: | ||
| - "CS8802" | ||
| helpviewer_keywords: | ||
| - "CS8802" | ||
| --- | ||
| # Compiler Error CS8802 | ||
|
|
||
| Only one compilation unit can have top-level statements. | ||
|
|
||
| This error indicates that there are two or more [top-level statements](../../fundamentals/program-structure/top-level-statements.md) in a single compilation unit (single solution, project or a single group of files compiled into a single binary file). | ||
BartoszKlonowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Example | ||
|
|
||
| The following sample of single compilation unit generates CS8802: | ||
|
|
||
| ```xml | ||
| <!-- SingleCompilationUnit.csproj --> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| </PropertyGroup> | ||
| </Project> | ||
| ``` | ||
|
|
||
| ```csharp | ||
| // EntryFile.cs | ||
|
|
||
| int a = 0; | ||
| ``` | ||
|
|
||
| ```csharp | ||
| // SecondaryEntryFile.cs | ||
|
|
||
| int b = 1; // CS8802: The top level statement already exists in EntryFile.cs | ||
| ``` | ||
|
|
||
| ## To correct this error | ||
|
|
||
| Use only one top-level statement in the project. | ||
| <br/>Top-level statements acts as an entry point to the program, so only one file may have top-level statement. All other statements must be defined as members of classes or structs. | ||
|
|
||
| ## See also | ||
|
|
||
| - [Top-level statements](../../fundamentals/program-structure/top-level-statements.md) | ||
| - [CS8803](./cs8803.md) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.