Skip to content
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

Merge main into live #40853

Merged
merged 12 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions docs/ai/get-started-app-chat-template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Get started with the .NET enterprise chat app sample using RAG
description: Get started with .NET and search across your own data using a chat app sample implemented using Azure OpenAI Service and Retrieval Augmented Generation (RAG) in Azure AI Search. Easily deploy with Azure Developer CLI. This article uses the Azure AI Reference Template sample.
ms.date: 11/19/2023
ms.date: 05/10/2024
ms.topic: get-started
ms.custom: devx-track-dotnet, devx-track-dotnet-ai
# CustomerIntent: As a .NET developer new to Azure OpenAI, I want deploy and use sample code to interact with app infused with my own business data so that learn from the sample code.
Expand All @@ -13,9 +13,6 @@ This article shows you how to deploy and run the [Enterprise chat app sample for

* [Demo video](https://aka.ms/azai/net/video)

> [!div class="nextstepaction"]
> [Begin now](#open-development-environment)

By following the instructions in this article, you will:

- Deploy a chat app to Azure.
Expand Down Expand Up @@ -181,7 +178,7 @@ The sample repository contains all the code and configuration files you need to
The chat app is preloaded with employee benefits information from [PDF files](https://github.com/Azure-Samples/azure-search-openai-demo-csharp/tree/main/data). You can use the chat app to ask questions about the benefits. The following steps walk you through the process of using the chat app.

1. In the browser, navigate to the **Chat** page using the left navigation.
1. Select or enter "What is included in my Northwind Health Plus plan that is not in standard?" in the chat text box.
1. Select or enter "What is included in my Northwind Health Plus plan that is not in standard?" in the chat text box. Your response is _similar_ to the following image.

:::image type="content" source="./media/get-started-app-chat-template/browser-chat-initial-answer.png" lightbox="./media/get-started-app-chat-template/browser-chat-initial-answer.png" alt-text="Screenshot of chat app's first answer.":::

Expand Down Expand Up @@ -218,17 +215,13 @@ The intelligence of the chat is determined by the OpenAI model and the settings
The following steps walk you through the process of changing the settings.

1. In the browser, select the gear icon in the upper right of the page.
1. Check the **Suggest follow-up questions** checkbox and ask the same question again.
1. If not selected, select the **Suggest follow-up questions** checkbox and ask the same question again.

```Text
What is my deductible?
What is included in my Northwind Health Plus plan that is not in standard?
```

The chat returns follow-up question suggestions such as the following:

- "What is the cost sharing for out-of-network services?"
- "Are preventive care services subject to the deductible?"
- "How does the prescription drug deductible work?"
The chat might return with follow-up question suggestions.

1. In the **Settings** tab, deselect **Use semantic ranker for retrieval**.
1. Ask the same question again.
Expand All @@ -239,9 +232,7 @@ The following steps walk you through the process of changing the settings.

1. What is the difference in the answers?

The response which used the Semantic ranker provided a single answer: `The deductible for the Northwind Health Plus plan is $2,000 per year`.

The response without semantic ranking returned a less direct answer: `Based on the information provided, it is unclear what your specific deductible is. The Northwind Health Plus plan has different deductible amounts for in-network and out-of-network services, and there is also a separate prescription drug deductible. I would recommend checking with your provider or referring to the specific benefits details for your plan to determine your deductible amount`.
The response that used the Semantic ranker provided a single answer. The response without semantic ranking returned a less direct answer.

## Clean up resources

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 12 additions & 11 deletions docs/azure/includes/dotnet-all.md

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions docs/azure/includes/dotnet-new.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Breaking change: .NET 9 obsoletions with custom IDs"
titleSuffix: ""
description: Learn about the .NET 9 breaking change in core .NET libraries where some APIs have been marked as obsolete with a custom diagnostic ID.
ms.date: 04/05/2024
ms.date: 05/09/2024
---
# API obsoletions with non-default diagnostic IDs (.NET 9)

Expand All @@ -17,6 +17,8 @@ The following table lists the custom diagnostic IDs and their corresponding warn
| Diagnostic ID | Description | Severity |
| - | - |
| [SYSLIB0009](../../../../fundamentals/syslib-diagnostics/syslib0009.md) | <xref:System.Net.AuthenticationManager> is not supported. Methods will no-op or throw <xref:System.PlatformNotSupportedException>. | Warning |
| [SYSLIB0054](../../../../fundamentals/syslib-diagnostics/syslib0054.md) | <xref:System.Threading.Thread.VolatileRead%2A?displayProperty=nameWithType> and <xref:System.Threading.Thread.VolatileWrite%2A?displayProperty=nameWithType> are obsolete. Use <xref:System.Threading.Volatile.Read%2A?displayProperty=nameWithType> or <xref:System.Threading.Volatile.Write%2A?displayProperty=nameWithType> instead. | Warning |
| [SYSLIB0055](../../../../fundamentals/syslib-diagnostics/syslib0055.md) | `AdvSimd.ShiftRightLogicalRoundedNarrowingSaturate*` methods with signed parameters are obsolete. Use the unsigned overloads instead. | Warning |

## Version introduced

Expand All @@ -38,6 +40,23 @@ These obsoletions can affect [source compatibility](../../categories.md#source-c

- <xref:System.Net.AuthenticationManager?displayProperty=fullName>

### SYSLIB0054

- <xref:System.Threading.Thread.VolatileRead%2A?displayProperty=fullName>
- <xref:System.Threading.Thread.VolatileWrite%2A?displayProperty=fullName>

### SYSLIB0055

- <xref:System.Runtime.Intrinsics.Arm.AdvSimd.Arm64.ShiftRightLogicalRoundedNarrowingSaturateScalar(System.Runtime.Intrinsics.Vector64{System.Int64},System.Byte)?displayProperty=fullName>
- <xref:System.Runtime.Intrinsics.Arm.AdvSimd.Arm64.ShiftRightLogicalRoundedNarrowingSaturateScalar(System.Runtime.Intrinsics.Vector64{System.Int16},System.Byte)?displayProperty=fullName>
- <xref:System.Runtime.Intrinsics.Arm.AdvSimd.Arm64.ShiftRightLogicalRoundedNarrowingSaturateScalar(System.Runtime.Intrinsics.Vector64{System.Int32},System.Byte)?displayProperty=fullName>
- <xref:System.Runtime.Intrinsics.Arm.AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(System.Runtime.Intrinsics.Vector128{System.Int16},System.Byte)?displayProperty=fullName>
- <xref:System.Runtime.Intrinsics.Arm.AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(System.Runtime.Intrinsics.Vector128{System.Int64},System.Byte)?displayProperty=fullName>
- <xref:System.Runtime.Intrinsics.Arm.AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(System.Runtime.Intrinsics.Vector128{System.Int32},System.Byte)?displayProperty=fullName>
- <xref:System.Runtime.Intrinsics.Arm.AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateUpper(System.Runtime.Intrinsics.Vector64{System.SByte},System.Runtime.Intrinsics.Vector128{System.Int16},System.Byte)?displayProperty=fullName>
- <xref:System.Runtime.Intrinsics.Arm.AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateUpper(System.Runtime.Intrinsics.Vector64{System.Int16},System.Runtime.Intrinsics.Vector128{System.Int32},System.Byte)?displayProperty=fullName>
- <xref:System.Runtime.Intrinsics.Arm.AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateUpper(System.Runtime.Intrinsics.Vector64{System.Int32},System.Runtime.Intrinsics.Vector128{System.Int64},System.Byte)?displayProperty=fullName>

## See also

- [API obsoletions with non-default diagnostic IDs (.NET 8)](../8.0/obsolete-apis-with-custom-diagnostics.md)
Expand Down
46 changes: 46 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0025.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: "MSTEST0025: Use 'Assert.Fail' instead of an always-failing assert"
description: "Learn about code analysis rule MSTEST0025: Use 'Assert.Fail' instead of an always-failing assert"
ms.date: 05/07/2024
f1_keywords:
- MSTEST0025
- PreferAssertFailOverAlwaysFalseConditionsAnalyzer
helpviewer_keywords:
- PreferAssertFailOverAlwaysFalseConditionsAnalyzer
- MSTEST0025
author: Evangelink
ms.author: amauryleve
---
# MSTEST0025: Use 'Assert.Fail' instead of an always-failing assert

| Property | Value |
|-------------------------------------|-------------------------------------------------------|
| **Rule ID** | MSTEST0025 |
| **Title** | Use 'Assert.Fail' instead of an always-failing assert |
| **Category** | Design |
| **Fix is breaking or non-breaking** | Non-breaking |
| **Enabled by default** | Yes |
| **Default severity** | Info |
| **Introduced in version** | 3.4.0 |

## Cause

This rule raises a diagnostic when a call to an assertion produces an always-false condition.

## Rule description

Using `Assert.Fail` over an always-failing assertion call provides clearer intent and better documentation for the code.

When you encounter an assertion that always fails (for example, `Assert.IsTrue(false)`), it might not be immediately obvious to someone reading the code why the assertion is there or what condition it's trying to check. This can lead to confusion and wasted time for developers who come across the code later on.

In contrast, using `Assert.Fail` allows you to provide a custom failure message, making it clear why the assertion is failing and what specific condition or scenario it's addressing. This message serves as documentation for the intent behind the assertion, helping other developers understand the purpose of the assertion without needing to dive deep into the code.

Overall, using `Assert.Fail` promotes clarity, documentation, and maintainability in your codebase, making it a better choice over an always failing assertion call.

## How to fix violations

Ensure that calls to `Assert.IsTrue`, `Assert.IsFalse`, `Assert.AreEqual`, `Assert.AreNotEqual` or `Assert.IsNotNull` are not producing always-failing conditions.

## When to suppress warnings

We do not recommend suppressing warnings from this rule.
10 changes: 10 additions & 0 deletions docs/csharp/language-reference/builtin-types/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ The following example creates single-dimensional, multidimensional, and jagged a

:::code language="csharp" source="./snippets/shared/Arrays.cs" id="DeclareArrays":::

> [!IMPORTANT]
> Many of the examples in this article use [collection expressions](../operators/collection-expressions.md) (which use square brackets) to initialize the arrays. Collection expressions were first introduced in C# 12, which shipped with .NET 8. If you can't ugrade to C# 12 yet, use `{` and `}` to initialize the arrays instead.
>
> ```csharp
> // Collection expressions:
> int[] array = [1, 2, 3, 4, 5, 6];
> // Alternative syntax:
> int[] array2 = {1, 2, 3, 4, 5, 6};
> ```

## Single-dimensional arrays

A *single-dimensional array* is a sequence of like elements. You access an element via its *index*. The *index* is its ordinal position in the sequence. The first element in the array is at index `0`. You create a single-dimensional array using the [new](../operators/new-operator.md) operator specifying the array element type and the number of elements. The following example declares and initializes single-dimensional arrays:
Expand Down
4 changes: 2 additions & 2 deletions docs/csharp/language-reference/preprocessor-directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ The following code is compiled when `MYTEST` is **not** defined:

You can use the operators [`==` (equality)](operators/equality-operators.md#equality-operator-) and [`!=` (inequality)](operators/equality-operators.md#inequality-operator-) to test for the [`bool`](builtin-types/bool.md) values `true` or `false`. `true` means the symbol is defined. The statement `#if DEBUG` has the same meaning as `#if (DEBUG == true)`. You can use the [`&&` (and)](operators/boolean-logical-operators.md#conditional-logical-and-operator-), [`||` (or)](operators/boolean-logical-operators.md#conditional-logical-or-operator-), and [`!` (not)](operators/boolean-logical-operators.md#logical-negation-operator-) operators to evaluate whether multiple symbols have been defined. You can also group symbols and operators with parentheses.

The following is a complex directive that allows your code to take advantage of newer .NET features while remaining backward compatible. For example, imagine that you're using a NuGet package in your code, but the package only supports .NET 6 and up, as well as .NET Standard 2.0 and up:
The following is a complex directive that allows your code to take advantage of newer .NET features while remaining backward compatible. For example, imagine that you're using a NuGet package in your code, but the package only supports .NET 6 and up, as well as .NET Standard 2.0 and up:

```csharp
#if (NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER)
Console.WriteLine("Using .NET 6+ or .NET Standard 2+ code.");
#elif
#else
Console.WriteLine("Using older code that doesn't support the above .NET versions.");
#endif
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Object initializers can be used to set indexers in an object. The following exam

[!code-csharp[InitializerIndexerExample](../../../../samples/snippets/csharp/programming-guide/classes-and-structs/object-collection-initializers/HowToIndexInitializer.cs#HowToIndexInitializer)]

The next example shows the order of execution of constructor and member initializations using constructor with and without parameter:

[!code-csharp[ExecutionOrderExample](../../../../samples/snippets/csharp/programming-guide/classes-and-structs/object-collection-initializers/HowToIndexInitializer.cs#ObjectInitializersExecutionOrder)]

## See also

- [Object and Collection Initializers](object-and-collection-initializers.md)
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,31 @@ open type M.DU
printfn "%A" A
```

## Open from root path only with `global` specifier

Nested modules like

```fsharp
module A =
module B =
...
```

can be opened via

```fsharp
open A // opens A
open B // opens A.B
```

To open **only** fully qualified modules or namespaces prefix them with the `global` specifier:

```fsharp
open global.A // works
open global.B // this now fails
open global.A.B // works
```

## Namespaces That Are Open by Default

Some namespaces are so frequently used in F# code that they are opened implicitly without the need of an explicit import declaration. The following table shows the namespaces that are open by default.
Expand Down
4 changes: 2 additions & 2 deletions docs/fundamentals/networking/quic/quic-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ The sample usage of `QuicStream` in client scenario:

```csharp
// Consider connection from the connection example, open a bidirectional stream.
await using var stream = await connection.OpenStreamAsync(QuicStreamType.Bidirectional, cancellationToken);
await using var stream = await connection.OpenOutboundStreamAsync(QuicStreamType.Bidirectional, cancellationToken);

// Send some data.
await stream.WriteAsync(data, cancellationToken);
Expand All @@ -338,7 +338,7 @@ And the sample usage of `QuicStream` in server scenario:

```csharp
// Consider connection from the connection example, accept a stream.
await using var stream = await connection.AcceptStreamAsync(cancellationToken);
await using var stream = await connection.AcceptInboundStreamAsync(cancellationToken);

if (stream.Type != QuicStreamType.Bidirectional)
{
Expand Down
4 changes: 3 additions & 1 deletion docs/fundamentals/syslib-diagnostics/obsoletions-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Obsolete features in .NET 5+
titleSuffix: ""
description: Learn about APIs that are marked as obsolete in .NET 5 and later versions that produce SYSLIB compiler warnings.
ms.date: 06/08/2023
ms.date: 05/09/2024
---

# Obsolete features in .NET 5+
Expand Down Expand Up @@ -74,6 +74,8 @@ The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+
| [SYSLIB0051](syslib0051.md) | Warning | APIs that support obsolete formatter-based serialization are obsolete. They should not be called or extended by application code. |
| [SYSLIB0052](syslib0052.md) | Warning | APIs that support obsolete mechanisms for Regex extensibility are obsolete. |
| [SYSLIB0053](syslib0053.md) | Warning | <xref:System.Security.Cryptography.AesGcm> should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size. |
| [SYSLIB0054](syslib0054.md) | Warning | <xref:System.Threading.Thread.VolatileRead%2A?displayProperty=nameWithType> and <xref:System.Threading.Thread.VolatileWrite%2A?displayProperty=nameWithType> are obsolete. Use <xref:System.Threading.Volatile.Read%2A?displayProperty=nameWithType> or <xref:System.Threading.Volatile.Write%2A?displayProperty=nameWithType> instead. |
| [SYSLIB0055](syslib0055.md) | Warning | `AdvSimd.ShiftRightLogicalRoundedNarrowingSaturate*` methods with signed parameters are obsolete. Use the unsigned overloads instead. |

## Suppress warnings

Expand Down
4 changes: 2 additions & 2 deletions docs/fundamentals/syslib-diagnostics/syslib0048.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: SYSLIB0048 warning - RSA.EncryptValue and DecryptValue are obsolete
title: SYSLIB0048 warning - RSA.EncryptValue and RSA.DecryptValue are obsolete
description: Learn about the obsoletion of the RSA.EncryptValue and RSA.DecryptValue methods that generates compile-time warning SYSLIB0048.
ms.date: 04/08/2022
f1_keywords:
- syslib0048
---
# SYSLIB0048: RSA.EncryptValue and DecryptValue are obsolete
# SYSLIB0048: RSA.EncryptValue and RSA.DecryptValue are obsolete

The following methods are obsolete, starting in .NET 8. Calling them in code generates warning `SYSLIB0048` at compile time.

Expand Down
48 changes: 48 additions & 0 deletions docs/fundamentals/syslib-diagnostics/syslib0054.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: SYSLIB0054 warning - Thread.VolatileRead and Thread.VolatileWrite are obsolete
description: Learn about the obsoletion of Thread.VolatileRead and Thread.VolatileWrite that generates compile-time warning SYSLIB0054.
ms.date: 05/09/2024
f1_keywords:
- syslib0054
---
# SYSLIB0054: Thread.VolatileRead and Thread.VolatileWrite are obsolete

All overloads of the <xref:System.Threading.Thread.VolatileRead%2A?displayProperty=nameWithType> and <xref:System.Threading.Thread.VolatileWrite%2A?displayProperty=nameWithType> methods are obsolete, starting in .NET 9. Calling them in code generates warning `SYSLIB0054` at compile time.

## Reason for obsoletion

The .NET Framework implementation of the 64-bit overloads of the <xref:System.Threading.Thread.VolatileRead%2A?displayProperty=nameWithType> and <xref:System.Threading.Thread.VolatileWrite%2A?displayProperty=nameWithType> methods had incorrect atomicity. In .NET (Core), the implementation was changed to delegate to the <xref:System.Threading.Volatile.Read%2A?displayProperty=nameWithType> and <xref:System.Threading.Volatile.Write%2A?displayProperty=nameWithType>, respectively, which provide proper acquire/release semantics. In addition, the methods in the <xref:System.Threading.Thread> class don't include an overload that accepts a Boolean argument, whereas the <xref:System.Threading.Volatile> methods do. The methods were obsoleted to encourage use of the <xref:System.Threading.Volatile> methods.

## Workaround

Call <xref:System.Threading.Volatile.Read%2A?displayProperty=nameWithType> or <xref:System.Threading.Volatile.Write%2A?displayProperty=nameWithType> instead.

## Suppress a warning

If you must use the obsolete APIs, you can suppress the warning in code or in your project file.

To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.

```csharp
// Disable the warning.
#pragma warning disable SYSLIB0054

// Code that uses obsolete API.
// ...

// Re-enable the warning.
#pragma warning restore SYSLIB0054
```

To suppress all the `SYSLIB0054` warnings in your project, add a `<NoWarn>` property to your project file.

```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);SYSLIB0054</NoWarn>
</PropertyGroup>
</Project>
```

For more information, see [Suppress warnings](obsoletions-overview.md#suppress-warnings).
Loading
Loading