Skip to content

Commit 43a78fd

Browse files
CopilotBillWagner
andauthored
Fix incorrect C# compiler option names and broken links in documentation (#47734)
* Initial plan * Fix incorrect C# compiler option names in documentation Co-authored-by: BillWagner <[email protected]> * Fix broken links from TargetType to OutputType anchor Co-authored-by: BillWagner <[email protected]> * Fix broken link warnings - update anchor references for compiler options Co-authored-by: BillWagner <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: BillWagner <[email protected]>
1 parent bf02889 commit 43a78fd

File tree

25 files changed

+47
-52
lines changed

25 files changed

+47
-52
lines changed

docs/csharp/fundamentals/program-structure/main-command-line.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ helpviewer_keywords:
1616

1717
The `Main` method is the entry point of a C# application. When the application is started, the `Main` method is the first method that is invoked.
1818

19-
There can only be one entry point in a C# program. If you have more than one class that has a `Main` method, you must compile your program with the **StartupObject** compiler option to specify which `Main` method to use as the entry point. For more information, see [**StartupObject** (C# Compiler Options)](../../language-reference/compiler-options/advanced.md#mainentrypoint-or-startupobject). The following example displays the number of command line arguments as its first action:
19+
There can only be one entry point in a C# program. If you have more than one class that has a `Main` method, you must compile your program with the **StartupObject** compiler option to specify which `Main` method to use as the entry point. For more information, see [**StartupObject** (C# Compiler Options)](../../language-reference/compiler-options/advanced.md#startupobject). The following example displays the number of command line arguments as its first action:
2020

2121
:::code language="csharp" source="snippets/main-command-line/TestClass.cs":::
2222

docs/csharp/fundamentals/program-structure/top-level-statements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ You can write a `Main` method explicitly, but it can't function as an entry poin
3838

3939
> CS7022 The entry point of the program is global code; ignoring 'Main()' entry point.
4040
41-
In a project with top-level statements, you can't use the [-main](../../language-reference/compiler-options/advanced.md#mainentrypoint-or-startupobject) compiler option to select the entry point, even if the project has one or more `Main` methods.
41+
In a project with top-level statements, you can't use the [-main](../../language-reference/compiler-options/advanced.md#startupobject) compiler option to select the entry point, even if the project has one or more `Main` methods.
4242

4343
## `using` directives
4444

docs/csharp/language-reference/compiler-options/advanced.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ helpviewer_keywords:
99
- "ChecksumAlgorithm compiler option [C#]"
1010
- "CodePage compiler option [C#]"
1111
- "Utf8Output compiler option [C#]"
12-
- "MainEntryPoint compiler option [C#]"
12+
- "StartupObject compiler option [C#]"
1313
- "GenerateFullPaths compiler option [C#]"
1414
- "FileAlignment compiler option [C#]"
1515
- "PathMap compiler option [C#]"
@@ -27,7 +27,7 @@ helpviewer_keywords:
2727

2828
The following options support advanced scenarios. The new MSBuild syntax is shown in **Bold**. The older `csc.exe` syntax is shown in `code style`.
2929

30-
- **MainEntryPoint**, **StartupObject** / `-main`: Specify the type that contains the entry point.
30+
- **StartupObject** / `-main`: Specify the type that contains the entry point.
3131
- **PdbFile** / `-pdb`: Specify debug information file name.
3232
- **PathMap** / `-pathmap`: Specify a mapping for source path names output by the compiler.
3333
- **ApplicationConfiguration** / `-appconfig`: Specify an application configuration file containing assembly binding settings.
@@ -54,21 +54,15 @@ You add any of these options in a `<PropertyGroup>` element in your `*.csproj` f
5454
</PropertyGroup>
5555
``````
5656

57-
## MainEntryPoint or StartupObject
57+
## StartupObject
5858

5959
This option specifies the class that contains the entry point to the program, if more than one class contains a `Main` method.
6060

6161
```xml
6262
<StartupObject>MyNamespace.Program</StartupObject>
6363
```
6464

65-
or
66-
67-
```xml
68-
<MainEntryPoint>MyNamespace.Program</MainEntryPoint>
69-
```
70-
71-
Where `Program` is the type that contains the `Main` method. The provided class name must be fully qualified; it must include the full namespace containing the class, followed by the class name. For example, when the `Main` method is located inside the `Program` class in the `MyApplication.Core` namespace, the compiler option has to be `-main:MyApplication.Core.Program`. If your compilation includes more than one type with a [`Main`](../../fundamentals/program-structure/main-command-line.md) method, you can specify which type contains the `Main` method.
65+
Where `Program` is the type that contains the `Main` method. The class name can be either fully qualified (including the namespace) or just the class name if it's unambiguous. For example, when the `Main` method is located inside the `Program` class in the `MyApplication.Core` namespace, you can specify either `-main:MyApplication.Core.Program` or just `-main:Program` if there's no ambiguity. If your compilation includes more than one type with a [`Main`](../../fundamentals/program-structure/main-command-line.md) method, you can specify which type contains the `Main` method.
7266

7367
> [!NOTE]
7468
> This option can't be used for a project that includes [top-level statements](../../fundamentals/program-structure/top-level-statements.md), even if that project contains one or more `Main` methods.
@@ -245,7 +239,7 @@ Use this option if you want to define or create your own System namespace and ob
245239
Specifies the minimum version of the subsystem on which the executable file runs. Most commonly, this option ensures that the executable file can use security features that aren’t available with older versions of Windows.
246240

247241
> [!NOTE]
248-
> To specify the subsystem itself, use the [**TargetType**](./output.md#targettype) compiler option.
242+
> To specify the subsystem itself, use the [**OutputType**](./output.md#outputtype) compiler option.
249243
250244
```xml
251245
<SubsystemVersion>major.minor</SubsystemVersion>
@@ -266,9 +260,9 @@ The following table lists common subsystem versions of Windows.
266260
The default value of the **SubsystemVersion** compiler option depends on the conditions in the following list:
267261

268262
- The default value is 6.02 if any compiler option in the following list is set:
269-
- [-target:appcontainerexe](output.md)
270-
- [-target:winmdobj](output.md)
271-
- [-platform:arm](output.md)
263+
- [-target:appcontainerexe](output.md#outputtype)
264+
- [-target:winmdobj](output.md#outputtype)
265+
- [-platform:arm](output.md#platformtarget)
272266
- The default value is 6.00 if you're using MSBuild, you're targeting .NET Framework 4.5, and you haven't set any of the compiler options that were specified earlier in this list.
273267
- The default value is 4.00 if none of the previous conditions are true.
274268

@@ -286,7 +280,7 @@ Specifies the name of an assembly whose nonpublic types a *.netmodule* can acces
286280
- You know the name of the assembly into which the .netmodule will be built.
287281
- The existing assembly has granted friend assembly access to the assembly into which the .*netmodule* will be built.
288282

289-
For more information on building a .netmodule, see [**TargetType**](output.md#targettype) option of **module**. For more information on friend assemblies, see [Friend Assemblies](../../../standard/assembly/friend.md).
283+
For more information on building a .netmodule, see [**OutputType**](output.md#outputtype) option of **module**. For more information on friend assemblies, see [Friend Assemblies](../../../standard/assembly/friend.md).
290284

291285
## ReportIVTs
292286

docs/csharp/language-reference/compiler-options/inputs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ In the previous example, `LS` is the valid C# identifier that represents a root
4040
4141
## AddModules
4242

43-
This option adds a module that was created with the `<TargetType>module</TargetType>` switch to the current compilation:
43+
This option adds a module that was created with the `<OutputType>module</OutputType>` switch to the current compilation:
4444

4545
```xml
4646
<AddModule Include=file1 />
4747
<AddModule Include=file2 />
4848
```
4949

50-
Where `file`, `file2` are output files that contain metadata. The file can't contain an assembly manifest. To import more than one file, separate file names with either a comma or a semicolon. All modules added with **AddModules** must be in the same directory as the output file at run time. That is, you can specify a module in any directory at compile time but the module must be in the application directory at run time. If the module isn't in the application directory at run time, you'll get a <xref:System.TypeLoadException>. `file` can't contain an assembly. For example, if the output file was created with [**TargetType**](output.md#targettype) option of **module**, its metadata can be imported with **AddModules**.
50+
Where `file`, `file2` are output files that contain metadata. The file can't contain an assembly manifest. To import more than one file, separate file names with either a comma or a semicolon. All modules added with **AddModules** must be in the same directory as the output file at run time. That is, you can specify a module in any directory at compile time but the module must be in the application directory at run time. If the module isn't in the application directory at run time, you'll get a <xref:System.TypeLoadException>. `file` can't contain an assembly. For example, if the output file was created with [**OutputType**](output.md#outputtype) option of **module**, its metadata can be imported with **AddModules**.
5151

52-
If the output file was created with a [**TargetType**](output.md#targettype) option other than **module**, its metadata cannot be imported with **AddModules** but can be imported with the [**References**](#references) option.
52+
If the output file was created with a [**OutputType**](output.md#outputtype) option other than **module**, its metadata cannot be imported with **AddModules** but can be imported with the [**References**](#references) option.
5353

5454
## EmbedInteropTypes
5555

docs/csharp/language-reference/compiler-options/output.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ helpviewer_keywords:
99
- "OutputAssembly compiler option [C#]"
1010
- "PlatformTarget compiler option [C#]"
1111
- "ProduceReferenceAssembly compiler option [C#]"
12-
- "TargetType compiler option [C#]"
12+
- "OutputType compiler option [C#]"
1313
---
1414
# C# Compiler Options that control compiler output
1515

@@ -21,7 +21,7 @@ The following options control compiler output generation.
2121
| **OutputAssembly** | `-out:` | Specify the output assembly file. |
2222
| **PlatformTarget** | `-platform:` | Specify the target platform CPU. |
2323
| **ProduceReferenceAssembly** | `-refout:` | Generate a reference assembly. |
24-
| **TargetType** | `-target:` | Specify the type of the output assembly. |
24+
| **OutputType** | `-target:` | Specify the type of the output assembly. |
2525

2626
> [!NOTE]
2727
> Refer to [Compiler options](index.md#how-to-set-options) for more information on configuring these options for your project.
@@ -34,7 +34,7 @@ The **DocumentationFile** option allows you to place documentation comments in a
3434
<DocumentationFile>path/to/file.xml</DocumentationFile>
3535
```
3636

37-
The source code file that contains Main or top-level statements is output first into the XML. You'll often want to use the generated .xml file with [IntelliSense](/visualstudio/ide/using-intellisense). The *.xml* filename must be the same as the assembly name. The *.xml* file must be in the same directory as the assembly. When the assembly is referenced in a Visual Studio project, the *.xml* file is found as well. For more information about generating code comments, see [Supplying Code Comments](/visualstudio/ide/reference/generate-xml-documentation-comments). Unless you compile with [`<TargetType:Module>`](#targettype), `file` will contain `<assembly>` and `</assembly>` tags specifying the name of the file containing the assembly manifest for the output file. For examples, see [How to use the XML documentation features](../xmldoc/index.md).
37+
The source code file that contains Main or top-level statements is output first into the XML. You'll often want to use the generated .xml file with [IntelliSense](/visualstudio/ide/using-intellisense). The *.xml* filename must be the same as the assembly name. The *.xml* file must be in the same directory as the assembly. When the assembly is referenced in a Visual Studio project, the *.xml* file is found as well. For more information about generating code comments, see [Supplying Code Comments](/visualstudio/ide/reference/generate-xml-documentation-comments). Unless you compile with [`<OutputType:module>`](#outputtype), `file` will contain `<assembly>` and `</assembly>` tags specifying the name of the file containing the assembly manifest for the output file. For examples, see [How to use the XML documentation features](../xmldoc/index.md).
3838

3939
> [!NOTE]
4040
> The **DocumentationFile** option applies to all files in the project. To disable warnings related to documentation comments for a specific file or section of code, use [#pragma warning](../preprocessor-directives.md#pragma-warning).
@@ -43,13 +43,14 @@ This option can be used in any .NET SDK-style project. For more information, see
4343

4444
## OutputAssembly
4545

46-
The **OutputAssembly** option specifies the name of the output file. The output path specifies the folder where compiler output is placed.
46+
The **OutputAssembly** option specifies the name of the output file. This option corresponds to the combination of the `OutputPath` and `AssemblyName` MSBuild properties that control where the compiled assembly is placed and what it's named.
4747

4848
```xml
49-
<OutputAssembly>folder</OutputAssembly>
49+
<OutputPath>bin\Debug\</OutputPath>
50+
<AssemblyName>MyApplication</AssemblyName>
5051
```
5152

52-
Specify the full name and extension of the file you want to create. If you don't specify the name of the output file, MSBuild uses the name of the project to specify the name of the output assembly. Old style projects use the following rules:
53+
Specify the name and extension of the file you want to create. The path can be relative or absolute. If you don't specify the name of the output file, MSBuild uses the project name to specify the name of the output assembly. Old style projects use the following rules:
5354

5455
- An .exe will take its name from the source code file that contains the `Main` method or top-level statements.
5556
- A .dll or .netmodule will take its name from the first source code file.
@@ -103,9 +104,9 @@ You generally don't need to work directly with reference assembly files. By defa
103104

104105
.NET SDK 6.0.200 made a [change](../../../core/compatibility/sdk/6.0/write-reference-assemblies-to-obj.md) that moved reference assemblies from the output directory to the intermediate directory by default.
105106

106-
## TargetType
107+
## OutputType
107108

108-
The **TargetType** compiler option can be specified in one of the following forms:
109+
The **OutputType** compiler option can be specified in one of the following forms:
109110

110111
- **library**: to create a code library. **library** is the default value.
111112
- **exe**: to create an .exe file.
@@ -118,7 +119,7 @@ The **TargetType** compiler option can be specified in one of the following form
118119
> For .NET Framework targets, unless you specify **module**, this option causes a .NET Framework assembly manifest to be placed in an output file. For more information, see [Assemblies in .NET](../../../standard/assembly/index.md) and [Common Attributes](../attributes/global.md).
119120
120121
```xml
121-
<TargetType>library</TargetType>
122+
<OutputType>library</OutputType>
122123
```
123124

124125
The compiler creates only one assembly manifest per compilation. Information about all files in a compilation is placed in the assembly manifest. When producing multiple output files at the command line, only one assembly manifest can be created and it must go into the first output file specified on the command line.
@@ -131,15 +132,15 @@ The **library** option causes the compiler to create a dynamic-link library (DLL
131132

132133
### exe
133134

134-
The **exe** option causes the compiler to create an executable (EXE), console application. The executable file will be created with the .exe extension. Use **winexe** to create a Windows program executable. Unless otherwise specified with the [**OutputAssembly**](#outputassembly) option, the output file name takes the name of the input file that contains the entry point ([Main](../../fundamentals/program-structure/main-command-line.md) method or top-level statements). One and only one entry point is required in the source code files that are compiled into an .exe file. The [**StartupObject**](./advanced.md#mainentrypoint-or-startupobject) compiler option lets you specify which class contains the `Main` method, in cases where your code has more than one class with a `Main` method.
135+
The **exe** option causes the compiler to create an executable (EXE), console application. The executable file will be created with the .exe extension. Use **winexe** to create a Windows program executable. Unless otherwise specified with the [**OutputAssembly**](#outputassembly) option, the output file name takes the name of the input file that contains the entry point ([Main](../../fundamentals/program-structure/main-command-line.md) method or top-level statements). One and only one entry point is required in the source code files that are compiled into an .exe file. The [**StartupObject**](./advanced.md#startupobject) compiler option lets you specify which class contains the `Main` method, in cases where your code has more than one class with a `Main` method.
135136

136137
### module
137138

138139
This option causes the compiler to not generate an assembly manifest. By default, the output file created by compiling with this option will have an extension of *.netmodule*. A file that doesn't have an assembly manifest cannot be loaded by the .NET runtime. However, such a file can be incorporated into the assembly manifest of an assembly with [**AddModules**](inputs.md#addmodules). If more than one module is created in a single compilation, [internal](../keywords/internal.md) types in one module will be available to other modules in the compilation. When code in one module references `internal` types in another module, then both modules must be incorporated into an assembly manifest, with [**AddModules**](inputs.md#addmodules). Creating a module isn't supported in the Visual Studio development environment.
139140

140141
### winexe
141142

142-
The **winexe** option causes the compiler to create an executable (EXE), Windows program. The executable file will be created with the .exe extension. A Windows program is one that provides a user interface from either the .NET library or with the Windows APIs. Use **exe** to create a console application. Unless otherwise specified with the [**OutputAssembly**](#outputassembly) option, the output file name takes the name of the input file that contains the [`Main`](../../fundamentals/program-structure/main-command-line.md) method. One and only one `Main` method is required in the source code files that are compiled into an .exe file. The [**StartupObject**](./advanced.md#mainentrypoint-or-startupobject) option lets you specify which class contains the `Main` method, in cases where your code has more than one class with a `Main` method.
143+
The **winexe** option causes the compiler to create an executable (EXE), Windows program. The executable file will be created with the .exe extension. A Windows program is one that provides a user interface from either the .NET library or with the Windows APIs. Use **exe** to create a console application. Unless otherwise specified with the [**OutputAssembly**](#outputassembly) option, the output file name takes the name of the input file that contains the [`Main`](../../fundamentals/program-structure/main-command-line.md) method. One and only one `Main` method is required in the source code files that are compiled into an .exe file. The [**StartupObject**](./advanced.md#startupobject) option lets you specify which class contains the `Main` method, in cases where your code has more than one class with a `Main` method.
143144

144145
### winmdobj
145146

0 commit comments

Comments
 (0)