diff --git a/docs/core/deploying/trimming/trim-warnings/il2042.md b/docs/core/deploying/trimming/trim-warnings/il2042.md index 432594f08a5b6..d061d199ac7b9 100644 --- a/docs/core/deploying/trimming/trim-warnings/il2042.md +++ b/docs/core/deploying/trimming/trim-warnings/il2042.md @@ -29,7 +29,7 @@ public Type MyProperty // To fix this annotate the accessors manually: public Type MyProperty { - [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberType.PublicMethods)] + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberType.PublicMethods)] get { return GetTheValue(); } [param: DynamicallyAccessedMembers(DynamicallyAccessedMemberType.PublicMethods)] diff --git a/docs/core/deploying/trimming/trim-warnings/il2055.md b/docs/core/deploying/trimming/trim-warnings/il2055.md index 9aef098962e7f..ec05dae4acd99 100644 --- a/docs/core/deploying/trimming/trim-warnings/il2055.md +++ b/docs/core/deploying/trimming/trim-warnings/il2055.md @@ -24,7 +24,7 @@ the trimmer currently cannot validate that the requirements are fulfilled by the ## Example ```C# -class Lazy<[DynamicallyAccessedMembers(DynamicallyAccessedMemberType.PublicParameterlessConstructor)] T> +class Lazy<[DynamicallyAccessedMembers(DynamicallyAccessedMemberType.PublicParameterlessConstructor)] T> { // ... } diff --git a/docs/core/deploying/trimming/trim-warnings/il2056.md b/docs/core/deploying/trimming/trim-warnings/il2056.md index 971a38d09e195..d9bf061979fc2 100644 --- a/docs/core/deploying/trimming/trim-warnings/il2056.md +++ b/docs/core/deploying/trimming/trim-warnings/il2056.md @@ -30,7 +30,7 @@ explicitly annotated with enable` node. For more information, see [Setting the nullable context](../../csharp/language-reference/builtin-types/nullable-reference-types.md#setting-the-nullable-context). + ## Create the service Add a new class to the project named *JokeService.cs*, and replace its contents with the following C# code: @@ -106,7 +114,14 @@ For more information on registering services, see [Dependency injection in .NET] ## Publish the app -To create the .NET Worker Service app as a Windows Service, it will need to be published as a single file executable. +To create the .NET Worker Service app as a Windows Service, it's recommended that you publish the app as a single file executable. It's less error-prone to have a self-contained executable, as there aren't any dependent files lying around the file system. But you may choose a different publishing modality, which is perfectly acceptable, so long as you create an _*.exe_ file that can be targeted by the Windows Service Control Manager. + +> [!IMPORTANT] +> An alternative publishing approach is to build the _*.dll_ (instead of an _*.exe_), and when you install the published app using the Windows Service Control Manager you delegate to the .NET CLI and pass the DLL. For more information, see [.NET CLI: dotnet command](../tools/dotnet.md). +> +> ```powershell +> sc.exe create ".NET Joke Service" binpath="C:\Path\To\dotnet.exe C:\Path\To\App.WindowsService.dll" +> ``` :::code language="xml" source="snippets/workers/windows-service/App.WindowsService.csproj" highlight="7-10"::: diff --git a/docs/core/tools/dotnet-new-list.md b/docs/core/tools/dotnet-new-list.md index 31bdefd344d98..7f9aabf560f28 100644 --- a/docs/core/tools/dotnet-new-list.md +++ b/docs/core/tools/dotnet-new-list.md @@ -86,7 +86,7 @@ The `dotnet new --list` option lists available templates to use with `dotnet new - before .NET SDK 6.0.100 ```dotnetcli - dotnet new spa --list + dotnet new spa --list ``` - List all templates matching the *we* substring. @@ -99,7 +99,7 @@ The `dotnet new --list` option lists available templates to use with `dotnet new - before .NET SDK 6.0.100 ```dotnetcli - dotnet new we --list + dotnet new we --list ``` - List all templates matching the *we* substring that support the F# language. diff --git a/docs/core/tools/dotnet-new-search.md b/docs/core/tools/dotnet-new-search.md index f5b2198648131..e2ff8c0820471 100644 --- a/docs/core/tools/dotnet-new-search.md +++ b/docs/core/tools/dotnet-new-search.md @@ -90,7 +90,7 @@ The `dotnet new --search` option searches for templates supported by `dotnet new - before .NET SDK 6.0.100 ```dotnetcli - dotnet new spa --search + dotnet new spa --search ``` - Search for all templates available on NuGet.org matching the *we* substring and supporting the F# language. diff --git a/docs/core/tutorials/cli-templates-create-template-package.md b/docs/core/tutorials/cli-templates-create-template-package.md index 0ac20200dcc3d..a93791b99acb5 100644 --- a/docs/core/tutorials/cli-templates-create-template-package.md +++ b/docs/core/tutorials/cli-templates-create-template-package.md @@ -154,7 +154,7 @@ If you uploaded the NuGet package to a NuGet feed, you can use the `dotnet new - No matter how you installed the template package, either with the _.nupkg_ file directly or by NuGet feed, removing a template package is the same. Use the `` of the template you want to uninstall. You can get a list of templates that are installed by running the `dotnet new --uninstall` command. ```dotnetcli -C:\working> dotnet new --uninstall +C:\working> dotnet new --uninstall Template Instantiation Commands for .NET CLI diff --git a/docs/core/tutorials/top-level-templates.md b/docs/core/tutorials/top-level-templates.md index 2d682e6b069d6..21743f4896a15 100644 --- a/docs/core/tutorials/top-level-templates.md +++ b/docs/core/tutorials/top-level-templates.md @@ -99,13 +99,13 @@ While a .NET 6 console app template will generate the new style of top-level sta ```diff - + Exe - net5.0 + net6.0 - + ``` @@ -113,14 +113,14 @@ While a .NET 6 console app template will generate the new style of top-level sta ```diff - + Exe net6.0 + enable + enable - + ``` @@ -138,13 +138,13 @@ When you create a new console project in Visual Studio, you're prompted with a d ```diff - + Exe - net5.0 + net6.0 - + ``` @@ -156,14 +156,14 @@ When you create a new console project in Visual Studio, you're prompted with a d ```diff - + Exe net6.0 + enable + enable - + ``` diff --git a/docs/csharp/misc/cs0169.md b/docs/csharp/misc/cs0169.md index 2ce01a5cc6705..aa96107e1c198 100644 --- a/docs/csharp/misc/cs0169.md +++ b/docs/csharp/misc/cs0169.md @@ -24,13 +24,13 @@ public class ClassX int i; // CS0169, i is not used anywhere // Remove the above variable declaration or uncomment TestMethod to clear warning CS0169 /* - public void TestMethod() + public void TestMethod() { i = 5; System.Console.WriteLine(i); } */ - + public static void Main() { } diff --git a/docs/csharp/misc/cs0815.md b/docs/csharp/misc/cs0815.md index 9a1191a35e0b4..f6eef6be73722 100644 --- a/docs/csharp/misc/cs0815.md +++ b/docs/csharp/misc/cs0815.md @@ -31,7 +31,7 @@ class Test public static int Main() { var d = s => -1; // CS0815 - var e = (string s) => 0; // CS0815 for C# versions before 10 + var e = (string s) => 0; // CS0815 for C# versions before 10 var p = null; // CS0815 var del = delegate(string a) { return -1; }; // CS0815 return -1; diff --git a/docs/csharp/programming-guide/file-system/how-to-read-a-text-file-one-line-at-a-time.md b/docs/csharp/programming-guide/file-system/how-to-read-a-text-file-one-line-at-a-time.md index 808c674d1b566..8a53da10d9b5f 100644 --- a/docs/csharp/programming-guide/file-system/how-to-read-a-text-file-one-line-at-a-time.md +++ b/docs/csharp/programming-guide/file-system/how-to-read-a-text-file-one-line-at-a-time.md @@ -19,7 +19,7 @@ This example reads the contents of a text file, one line at a time, into a strin int counter = 0; // Read the file and display it line by line. -foreach (string line in System.IO.File.ReadLines(@"c:\test.txt")) +foreach (string line in System.IO.File.ReadLines(@"c:\test.txt")) { System.Console.WriteLine(line); counter++; diff --git a/docs/fsharp/language-reference/computation-expressions.md b/docs/fsharp/language-reference/computation-expressions.md index c87204bd42231..7e4d779dd4e36 100644 --- a/docs/fsharp/language-reference/computation-expressions.md +++ b/docs/fsharp/language-reference/computation-expressions.md @@ -299,7 +299,7 @@ module Eventually = | Done value -> func value | NotYetDone work -> NotYetDone (fun () -> bind func (work())) - /// Return the final value + /// Return the final value let result value = Done value /// The catch for the computations. Stitch try/with throughout @@ -386,7 +386,7 @@ let comp = printfn $" x = %d{x}" return 3 + 4 } - + /// Try the remaining lines in F# interactive to see how this /// computation expression works in practice. let step x = Eventually.step x diff --git a/docs/fsharp/language-reference/functions/entry-point.md b/docs/fsharp/language-reference/functions/entry-point.md index 67cdea1580d9d..dbb3c371677b2 100644 --- a/docs/fsharp/language-reference/functions/entry-point.md +++ b/docs/fsharp/language-reference/functions/entry-point.md @@ -21,7 +21,7 @@ let printSomeText() = let showCommandLineArgs() = for arg in Environment.GetCommandLineArgs() do printfn $"arg = {arg}" - + printSomeText() showCommandLineArgs() exit 100 diff --git a/docs/fsharp/language-reference/task-expressions.md b/docs/fsharp/language-reference/task-expressions.md index 986f5adc05adc..c0d87ee5a301a 100644 --- a/docs/fsharp/language-reference/task-expressions.md +++ b/docs/fsharp/language-reference/task-expressions.md @@ -91,7 +91,7 @@ By default, .NET tasks are scheduled using when you want to capture the expression used for an argument. Diagnostic libraries may want to provide more details about the *expressions* passed as an arguments. By providing the expression that triggered the diagnostic, in addition to the parameter name, developers have more details about the condition that triggered the diagnostic. That extra information makes it easier to fix. The following method uses the to display the condition that must be `True`: ```vb -Public Shared Sub ValidateArgument(ByVal parameterName As String, +Public Shared Sub ValidateArgument(ByVal parameterName As String, ByVal condition As Boolean, ByVal Optional message As String? = Nothing) If Not condition Then