diff --git a/docs/core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md b/docs/core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md index 5d300df35e400..00afabb9530e0 100644 --- a/docs/core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md +++ b/docs/core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md @@ -6,7 +6,7 @@ ms.author: ygerges ms.date: 10/08/2025 --- -# Mirate from Microsoft.Testing.Platform v1 to v2 +# Migrate from Microsoft.Testing.Platform v1 to v2 The stable version Microsoft.Testing.Platform v2 is now available. This migration guide explores what's changed in Microsoft.Testing.Platform v2 and how you can migrate to this version. diff --git a/docs/csharp/language-reference/operators/patterns.md b/docs/csharp/language-reference/operators/patterns.md index 2299ac2518eff..0a9016daa7cc6 100644 --- a/docs/csharp/language-reference/operators/patterns.md +++ b/docs/csharp/language-reference/operators/patterns.md @@ -182,6 +182,10 @@ You can also add a run-time type check and a variable declaration to a property :::code language="csharp" source="snippets/patterns/PropertyPattern.cs" id="WithTypeCheck"::: +This specifically means that the *empty* property pattern `is { }` matches everything non-null, and can be used instead of the `is not null` to create a variable: `somethingPossiblyNull is { } somethingDefinitelyNotNull`. + +:::code language="csharp" source="snippets/patterns/PropertyPattern.cs" id="EmptyPropertyPattern"::: + A property pattern is a recursive pattern. You can use any pattern as a nested pattern. Use a property pattern to match parts of data against nested patterns, as the following example shows: :::code language="csharp" source="snippets/patterns/PropertyPattern.cs" id="RecursivePropertyPattern"::: diff --git a/docs/csharp/language-reference/operators/snippets/patterns/PropertyPattern.cs b/docs/csharp/language-reference/operators/snippets/patterns/PropertyPattern.cs index 1c1be24b28836..c6ec2e031b1be 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/PropertyPattern.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/PropertyPattern.cs @@ -5,8 +5,27 @@ public static class PropertyPattern public static void Examples() { WithTypeCheck(); + + // + if (GetSomeNullableStringValue() is { } nonNullValue) // Empty property pattern with variable creation + { + Console.WriteLine("NotNull:" + nonNullValue); + } + else + { + nonNullValue = "NullFallback"; // we can access the variable here. + Console.WriteLine("it was null, here's the fallback: " + nonNullValue); + } + // + } + private static string? GetSomeNullableStringValue() + { + // Simulate getting a nullable string value. + return DateTime.Now.Ticks % 2 == 0 ? "Hello, World!" : null; + } + // static bool IsConferenceDay(DateTime date) => date is { Year: 2020, Month: 5, Day: 19 or 20 or 21 }; // diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1806.md b/docs/fundamentals/code-analysis/quality-rules/ca1806.md index cb34fc9d91d65..91163cad653d8 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1806.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1806.md @@ -1,7 +1,7 @@ --- title: "CA1806: Do not ignore method results (code analysis)" description: "Learn about code analysis rule CA1806: Do not ignore method results" -ms.date: 06/08/2022 +ms.date: 10/30/2025 f1_keywords: - CA1806 - DoNotIgnoreMethodResults @@ -32,6 +32,7 @@ There are several possible reasons for this warning: - A method that creates and returns a new string is called and the new string is never used. - A COM or P/Invoke method returns a `HRESULT` or error code that's never used. - A language-integrated query (LINQ) method returns a result that's never used. +- A `[Pure]` method is called and the return value is never used. ## Rule description @@ -41,7 +42,7 @@ Strings are immutable and methods such as are known to not have side effects, and the result should not be ignored. ## How to fix violations @@ -57,7 +58,7 @@ If method A calls method B but does not use the `HRESULT` or error code that the -or- -If a LINQ method A calls method B but does not use the result, use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method. +If method A calls a LINQ or pure method B but does not use the result, use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method. ## When to suppress warnings @@ -122,7 +123,7 @@ The following example fixes the violation by assigning the result of [!NOTE] -> This violation cannot be reproduced in Visual Basic. +> This violation can't be reproduced in Visual Basic. :::code language="csharp" source="snippets/csharp/all-rules/ca1806.cs" id="snippet3"::: diff --git a/docs/visual-basic/reference/command-line-compiler/how-to-invoke-the-command-line-compiler.md b/docs/visual-basic/reference/command-line-compiler/how-to-invoke-the-command-line-compiler.md index 679dce09b79aa..94789b287f87b 100644 --- a/docs/visual-basic/reference/command-line-compiler/how-to-invoke-the-command-line-compiler.md +++ b/docs/visual-basic/reference/command-line-compiler/how-to-invoke-the-command-line-compiler.md @@ -9,23 +9,32 @@ helpviewer_keywords: - "command line [Visual Basic], arguments" ms.assetid: 0fd9a8f6-f34e-4c35-a49d-9b9bbd8da4a9 --- -# How to: Invoke the Command-Line Compiler (Visual Basic) +# How to Invoke the Command-Line Compiler You can invoke the command-line compiler by typing the name of its executable file into the command line, also known as the MS-DOS prompt. If you compile from the default Windows Command Prompt, you must type the fully qualified path to the executable file. To override this default behavior, you can either use the Developer Command Prompt for Visual Studio, or modify the PATH environment variable. Both allow you to compile from any directory by simply typing the compiler name. +[!TIP] +For modern .NET projects, use the [`dotnet build`](../../../core/tools/dotnet-build.md) command to compile Visual Basic source files. +The `vbc.exe` command-line compiler is only used for older .NET Framework projects. + [!INCLUDE[note_settings_general](~/includes/note-settings-general-md.md)] ## To invoke the compiler using the Developer Command Prompt for Visual Studio 1. Open the Visual Studio Tools program folder within the Microsoft Visual Studio program group. -2. You can use the Developer Command Prompt for Visual Studio to access the compiler from any directory on your machine, if Visual Studio is installed. +1. You can use the **Developer Command Prompt for Visual Studio** to access the compiler from any directory on your machine, if Visual Studio is installed. + +1. Open the **Developer Command Prompt for Visual Studio**. -3. Invoke the Developer Command Prompt for Visual Studio. +1. At the command line, type `vbc.exe ` and then press **Enter**. -4. At the command line, type `vbc.exe` *sourceFileName* and then press ENTER. +For example, if you stored your source code in a directory called `SourceFiles`, you would open the Command Prompt and type: - For example, if you stored your source code in a directory called `SourceFiles`, you would open the Command Prompt and type `cd SourceFiles` to change to that directory. If the directory contained a source file named `Source.vb`, you could compile it by typing `vbc.exe Source.vb`. +```cmd +cd SourceFiles +vbc.exe Source.vb +``` ## To set the PATH environment variable to the compiler for the Windows Command Prompt @@ -33,27 +42,33 @@ You can invoke the command-line compiler by typing the name of its executable fi The exact name of the directory where the compiler is located depends on the location of the Windows directory and the version of the ".NET Framework" installed. If you have more than one version of the ".NET Framework" installed, you must determine which version to use (typically the latest version). -2. From your **Start** Menu, right-click **My Computer**, and then click **Properties** from the shortcut menu. +1. From your **Start** Menu, right-click **My Computer**, and then click **Properties** from the shortcut menu. -3. Click the **Advanced** tab, and then click **Environment Variables**. +1. Click the **Advanced** tab, and then click **Environment Variables**. -4. In the **System** variables pane, select **Path** from the list and click **Edit**. +1. In the **System** variables pane, select **Path** from the list and click **Edit**. -5. In the **Edit System** Variable dialog box, move the insertion point to the end of the string in the **Variable Value** field and type a semicolon (;) followed by the full directory name found in Step 1. +1. In the **Edit System** Variable dialog box, move the insertion point to the end of the string in the **Variable Value** field and type a semicolon (;) followed by the full directory name found in Step 1. -6. Click **OK** to confirm your edits and close the dialog boxes. +1. Click **OK** to confirm your edits and close the dialog boxes. - After you change the PATH environment variable, you can run the Visual Basic compiler at the Windows Command Prompt from any directory on the computer. + After you change the PATH environment variable, you can run the Visual Basic compiler at the Windows Command Prompt from any directory on the computer. ## To invoke the compiler using the Windows Command Prompt 1. From the **Start** menu, click on the **Accessories** folder, and then open the **Windows Command Prompt**. -2. At the command line, type `vbc.exe`*sourceFileName* and then press ENTER. +1. At the command line, type `vbc.exe ` and then press **Enter**. + +For example, if you stored your source code in a directory called `SourceFiles`, you would open the Command Prompt and type: - For example, if you stored your source code in a directory called `SourceFiles`, you would open the Command Prompt and type `cd SourceFiles` to change to that directory. If the directory contained a source file named `Source.vb`, you could compile it by typing `vbc.exe Source.vb`. +```cmd +cd SourceFiles +vbc.exe Source.vb +``` ## See also - [Visual Basic Command-Line Compiler](index.md) - [Conditional Compilation](../../programming-guide/program-structure/conditional-compilation.md) +- [dotnet build](../../../core/tools/dotnet-build.md) — for modern .NET SDK usage