Skip to content

Commit 4ec5463

Browse files
Merge pull request #41640 from dotnet/main
Merge main into live
2 parents b1a1b8a + 4edc7ae commit 4ec5463

File tree

25 files changed

+237
-76
lines changed

25 files changed

+237
-76
lines changed

docfx.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@
491491
"_csharplang/proposals/csharp-10.0/*.md": "08/07/2021",
492492
"_csharplang/proposals/csharp-11.0/*.md": "09/30/2022",
493493
"_csharplang/proposals/csharp-12.0/*.md": "08/15/2023",
494-
"_csharplang/proposals/*.md": "05/15/2024",
494+
"_csharplang/proposals/*.md": "06/28/2024",
495495
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md": "11/08/2022",
496496
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 8.md": "09/26/2023",
497497
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md": "06/26/2024",
@@ -662,6 +662,7 @@
662662
"_csharplang/proposals/lock-object.md": "Obey lock object semantics for lock statements",
663663
"_csharplang/proposals/method-group-natural-type-improvements.md": "Method group natural type improvements",
664664
"_csharplang/proposals/params-collections.md": "Params collections",
665+
"_csharplang/proposals/ref-unsafe-in-terators-async.md": "Allow ref and unsafe in iterators and async methods",
665666
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md": "C# compiler breaking changes since C# 10",
666667
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 8.md": "C# compiler breaking changes since C# 11",
667668
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md": "C# compiler breaking changes since C# 12",
@@ -778,6 +779,7 @@
778779
"_csharplang/proposals/lock-object.md": "Special-case how `System.Threading.Lock` interacts with the `lock` keyword by calling its `EnterScope` method. Add static analysis warnings to prevent accidental misuse of the type where possible.",
779780
"_csharplang/proposals/method-group-natural-type-improvements.md": "This proposal refines the determination of the natural type of a method group by considering candidates scope-by-scope and pruning at each scope.",
780781
"_csharplang/proposals/params-collections.md": "Allow the `params` modifier on collection types beyond arrays, including `IEnumerable` types.",
782+
"_csharplang/proposals/ref-unsafe-in-terators-async.md": "This proposal modifies restrictions to enable ref local variables and unsafe blocks in iterators and async methods",
781783
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md": "Learn about any breaking changes since the initial release of C# 10",
782784
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 8.md": "Learn about any breaking changes since the initial release of C# 11",
783785
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md": "Learn about any breaking changes since the initial release of C# 12",

docs/azure/includes/dotnet-all.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@
511511
| Microsoft.Azure.Functions.Worker.Sdk.Generators | NuGet [1.3.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk.Generators/1.3.0) | | |
512512
| Microsoft.Azure.WebJobs.CosmosDb.ChangeProcessor | NuGet [1.0.4](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.CosmosDb.ChangeProcessor/1.0.4) | | |
513513
| Microsoft.Azure.WebJobs.CosmosDb.Mongo | NuGet [1.0.4](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.CosmosDb.Mongo/1.0.4) | | |
514-
| Microsoft.Azure.WebJobs.Extensions.Kusto | NuGet [1.0.9-Preview](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Kusto/1.0.9-Preview) | | |
514+
| Microsoft.Azure.WebJobs.Extensions.Kusto | NuGet [1.0.10-Preview](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Kusto/1.0.10-Preview) | | |
515515
| Microsoft.Azure.WebJobs.Extensions.Rpc | NuGet [3.0.39](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Rpc/3.0.39) | | |
516516
| Microsoft.Azure.WebJobs.Rpc.Core | NuGet [3.0.39](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Rpc.Core/3.0.39) | | |
517517
| Service Bus - Message ID plugin | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.ServiceBus.MessageIdPlugin/2.0.0) | | |

docs/core/extensions/snippets/http/generated/generated.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
1313
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
14-
<PackageReference Include="Refit.HttpClientFactory" Version="7.1.0" />
14+
<PackageReference Include="Refit.HttpClientFactory" Version="7.1.2" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

docs/core/resilience/http-resilience.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Build resilient HTTP apps: Key development patterns"
33
description: Learn how to build resilient HTTP apps using the Microsoft.Extensions.Http.Resilience NuGet package.
44
author: IEvangelist
55
ms.author: dapine
6-
ms.date: 10/20/2023
6+
ms.date: 07/01/2024
77
---
88

99
# Build resilient HTTP apps: Key development patterns
@@ -81,13 +81,26 @@ The preceding code adds the standard resilience handler to the <xref:System.Net.
8181

8282
The default configuration chains five resilience strategies in the following order (from the outermost to the innermost):
8383

84-
| Order | Strategy | Description |
85-
|--:|--|--|
86-
| **1** | Rate limiter | The rate limiter pipeline limits the maximum number of concurrent requests being sent to the dependency. |
87-
| **2** | Total request timeout | The total request timeout pipeline applies an overall timeout to the execution, ensuring that the request, including retry attempts, doesn't exceed the configured limit. |
88-
| **3** | Retry | The retry pipeline retries the request in case the dependency is slow or returns a transient error. |
89-
| **4** | Circuit breaker | The circuit breaker blocks the execution if too many direct failures or timeouts are detected. |
90-
| **5** | Attempt timeout | The attempt timeout pipeline limits each request attempt duration and throws if it's exceeded. |
84+
| Order | Strategy | Description | Defaults |
85+
|--:|--|--|--|
86+
| **1** | Rate limiter | The rate limiter pipeline limits the maximum number of concurrent requests being sent to the dependency. | Queue: `0`<br>Permit: `1_000` |
87+
| **2** | Total timeout | The total request timeout pipeline applies an overall timeout to the execution, ensuring that the request, including retry attempts, doesn't exceed the configured limit. | Total timeout: 30s |
88+
| **3** | Retry | The retry pipeline retries the request in case the dependency is slow or returns a transient error. | Max retries: `3`<br>Backoff: `Exponential`<br>Use jitter: `true`<br>Delay:2s |
89+
| **4** | Circuit breaker | The circuit breaker blocks the execution if too many direct failures or timeouts are detected. | Failure ratio: 10%<br>Min throughput: `100`<br>Sampling duration: 30s<br>Break duration: 5s |
90+
| **5** | Attempt timeout | The attempt timeout pipeline limits each request attempt duration and throws if it's exceeded. | Attempt timeout: 10s |
91+
92+
#### Retries and circuit breakers
93+
94+
The retry and circuit breaker strategies both handle a set of specific HTTP status codes and exceptions. Consider the following HTTP status codes:
95+
96+
- HTTP 500 and above (Server errors)
97+
- HTTP 408 (Request timeout)
98+
- HTTP 429 (Too many requests)
99+
100+
Additionally, these strategies handle the following exceptions:
101+
102+
- `HttpRequestException`
103+
- `TimeoutRejectedException`
91104

92105
## Add standard hedging handler
93106

@@ -108,13 +121,13 @@ The standard hedging uses a pool of circuit breakers to ensure that unhealthy en
108121
109122
The preceding code adds the standard hedging handler to the <xref:Microsoft.Extensions.DependencyInjection.IHttpClientBuilder>. The default configuration chains five resilience strategies in the following order (from the outermost to the innermost):
110123

111-
| Order | Strategy | Description |
112-
|--:|--|--|
113-
| **1** | Total request timeout | The total request timeout pipeline applies an overall timeout to the execution, ensuring that the request, including hedging attempts, doesn't exceed the configured limit. |
114-
| **2** | Hedging | The hedging strategy executes the requests against multiple endpoints in case the dependency is slow or returns a transient error. Routing is options, by default it just hedges the URL provided by the original <xref:System.Net.Http.HttpRequestMessage>. |
115-
| **3** | Rate limiter (per endpoint) | The rate limiter pipeline limits the maximum number of concurrent requests being sent to the dependency. |
116-
| **4** | Circuit breaker (per endpoint) | The circuit breaker blocks the execution if too many direct failures or timeouts are detected. |
117-
| **5** | Attempt timeout (per endpoint) | The attempt timeout pipeline limits each request attempt duration and throws if it's exceeded. |
124+
| Order | Strategy | Description | Defaults |
125+
|--:|--|--|--|
126+
| **1** | Total request timeout | The total request timeout pipeline applies an overall timeout to the execution, ensuring that the request, including hedging attempts, doesn't exceed the configured limit. | Total timeout: 30s |
127+
| **2** | Hedging | The hedging strategy executes the requests against multiple endpoints in case the dependency is slow or returns a transient error. Routing is options, by default it just hedges the URL provided by the original <xref:System.Net.Http.HttpRequestMessage>. | Min attempts: `1`<br>Max attempts: `10`<br>Delay: 2s |
128+
| **3** | Rate limiter (per endpoint) | The rate limiter pipeline limits the maximum number of concurrent requests being sent to the dependency. | Queue: `0`<br>Permit: `1_000` |
129+
| **4** | Circuit breaker (per endpoint) | The circuit breaker blocks the execution if too many direct failures or timeouts are detected. | Failure ratio: 10%<br>Min throughput: `100`<br>Sampling duration: 30s<br>Break duration: 5s |
130+
| **5** | Attempt timeout (per endpoint) | The attempt timeout pipeline limits each request attempt duration and throws if it's exceeded. | Timeout: 10s |
118131

119132
### Customize hedging handler route selection
120133

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: "MSTEST0030: Type containing `[TestMethod]` should be marked with `[TestClass]`"
3+
description: "Learn about code analysis rule MSTEST0030: Type contaning `[TestMethod]` should be marked with `[TestClass]`, otherwise the test method will be silently ignored."
4+
ms.date: 07/02/2024
5+
f1_keywords:
6+
- MSTEST0030
7+
- TypeContainingTestMethodShouldBeATestClass
8+
helpviewer_keywords:
9+
- TypeContainingTestMethodShouldBeATestClass
10+
- MSTEST0030
11+
author: engyebrahim
12+
ms.author: enjieid
13+
---
14+
# MSTEST0030: Type containing `[TestMethod]` should be marked with `[TestClass]`
15+
16+
| Property | Value |
17+
|-------------------------------------|--------------------------------------------------------------------|
18+
| **Rule ID** | MSTEST0030 |
19+
| **Title** | Type containing `[TestMethod]` should be marked with `[TestClass]` |
20+
| **Category** | Usage |
21+
| **Fix is breaking or non-breaking** | Non-breaking |
22+
| **Enabled by default** | Yes |
23+
| **Default severity** | Info |
24+
| **Introduced in version** | 3.5.0 |
25+
26+
## Cause
27+
28+
Type contaning `[TestMethod]` should be marked with `[TestClass]`, otherwise the test method will be silently ignored.
29+
30+
## Rule description
31+
32+
MSTest considers test methods only on the context of a test class container (a class marked with [TestClass] or derived attribute) which could lead to some tests being silently ignored. If your class is supposed to represent common test behavior to be executed by children classes, it's recommended to mark the type as abstract to clarify the intent for other developers reading the code.
33+
34+
## How to fix violations
35+
36+
A non-abstract class contains test methods should be marked with '[TestClass]'.
37+
38+
## When to suppress warnings
39+
40+
It's safe to suppress the diagnostic if you are sure that your class is being inherited and that the tests declared on this class should only be run in the context of subclasses. Nonetheless, we recommend marking the class as abstract.

docs/csharp/language-reference/builtin-types/ref-struct.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "ref struct types"
33
description: Learn about the ref struct type in C#
4-
ms.date: 10/12/2022
4+
ms.date: 06/28/2024
55
---
66
# `ref` structure types (C# reference)
77

@@ -12,9 +12,9 @@ You can use the `ref` modifier in the declaration of a [structure type](struct.m
1212
- A `ref struct` can't implement interfaces.
1313
- A `ref struct` can't be boxed to <xref:System.ValueType?displayProperty=nameWithType> or <xref:System.Object?displayProperty=nameWithType>.
1414
- A `ref struct` can't be a type argument.
15-
- A `ref struct` variable can't be captured by a [lambda expression](../operators/lambda-expressions.md) or a [local function](../../programming-guide/classes-and-structs/local-functions.md).
16-
- A `ref struct` variable can't be used in an [`async`](../keywords/async.md) method. However, you can use `ref struct` variables in synchronous methods, for example, in methods that return <xref:System.Threading.Tasks.Task> or <xref:System.Threading.Tasks.Task%601>.
17-
- A `ref struct` variable can't be used in [iterators](../../iterators.md).
15+
- A `ref struct` variable can't be captured in a [lambda expression](../operators/lambda-expressions.md) or a [local function](../../programming-guide/classes-and-structs/local-functions.md).
16+
- Before C# 13,`ref struct` variables can't be used in an `async` method. Beginning with C# 13, a `ref struct` variable can't be used in the same block as the [`await`](../operators/await.md) expression in an [`async`](../keywords/async.md) method. However, you can use `ref struct` variables in synchronous methods, for example, in methods that return <xref:System.Threading.Tasks.Task> or <xref:System.Threading.Tasks.Task%601>.
17+
- Before C# 13, a `ref struct` variable can't be used in [iterators](../../iterators.md). Beginning with C# 13, `ref struct` types and `ref` locals can be used in iterators, provided they aren't in code segments with the `yield return` statement.
1818

1919
You can define a disposable `ref struct`. To do that, ensure that a `ref struct` fits the [disposable pattern](~/_csharplang/proposals/csharp-8.0/using.md#pattern-based-using). That is, it has an instance `Dispose` method, which is accessible, parameterless and has a `void` return type. You can use the [using statement or declaration](../statements/using.md) with an instance of a disposable `ref struct`.
2020

@@ -34,13 +34,13 @@ Beginning with C# 11, you can declare a `ref` field in a `ref struct`, as the fo
3434

3535
:::code language="csharp" source="snippets/shared/StructType.cs" id="SnippetRefField":::
3636

37-
A `ref` field may have the `null` value. Use the <xref:System.Runtime.CompilerServices.Unsafe.IsNullRef%60%601(%60%600@)?displayProperty=nameWithType> method to determine if a `ref` field is `null`.
37+
A `ref` field can have the `null` value. Use the <xref:System.Runtime.CompilerServices.Unsafe.IsNullRef%60%601(%60%600@)?displayProperty=nameWithType> method to determine if a `ref` field is `null`.
3838

3939
You can apply the `readonly` modifier to a `ref` field in the following ways:
4040

4141
- `readonly ref`: You can [ref reassign](../operators/assignment-operator.md#ref-assignment) such a field with the `= ref` operator only inside a constructor or an [`init` accessor](../keywords/init.md). You can assign a value with the `=` operator at any point allowed by the field access modifier.
42-
- `ref readonly`: At any point, you cannot assign a value with the `=` operator to such a field. However, you can ref reassign a field with the `= ref` operator.
43-
- `readonly ref readonly`: You can only ref reassign such a field in a constructor or an `init` accessor. At any point, you cannot assign a value to the field.
42+
- `ref readonly`: At any point, you can't assign a value with the `=` operator to such a field. However, you can ref reassign a field with the `= ref` operator.
43+
- `readonly ref readonly`: You can only ref reassign such a field in a constructor or an `init` accessor. At any point, you can't assign a value to the field.
4444

4545
The compiler ensures that a reference stored in a `ref` field doesn't outlive its referent.
4646

docs/csharp/language-reference/compiler-messages/cs1996.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Compiler Error CS1996"
33
title: "Compiler Error CS1996"
4-
ms.date: 9/12/2022
4+
ms.date: 7/01/2024
55
f1_keywords:
66
- "CS1996"
77
helpviewer_keywords:
@@ -13,7 +13,7 @@ Cannot await in the body of a lock statement
1313

1414
## Example
1515

16-
The following sample generates CS1996:
16+
The following sample generates CS1996:
1717

1818
```csharp
1919
public class C
@@ -33,9 +33,11 @@ public class C
3333
}
3434
```
3535

36+
The preceding code produces the same error with C# 13, as the `await` is in the `lock` statement block.
37+
3638
## To correct this error
3739

38-
Asynchronous code within a `lock` statement block is hard to implement reliably and even harder to implement in a general sense. The C# compiler doesn't support doing this to avoid emitting code that will be prone to deadlocks. Extracting the asynchronous code from the `lock` statement block will correct this error. For example:
40+
Asynchronous code within a `lock` statement block is hard to implement reliably and even harder to implement in a general sense. The C# compiler doesn't support doing this to avoid emitting code prone to deadlocks. Extracting the asynchronous code from the `lock` statement block corrects this error. For example:
3941

4042
```csharp
4143
public class C

docs/csharp/language-reference/compiler-messages/cs4004.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Compiler Error CS4004"
33
title: "Compiler Error CS4004"
4-
ms.date: 9/12/2022
4+
ms.date: 07/01/2024
55
f1_keywords:
66
- "CS4004"
77
helpviewer_keywords:
@@ -13,7 +13,7 @@ Cannot await in an unsafe context
1313

1414
## Example
1515

16-
The following sample generates CS4004:
16+
The following sample generates CS4004:
1717

1818
```csharp
1919
using System.Threading.Tasks;
@@ -47,11 +47,13 @@ public static class C
4747
}
4848
```
4949

50+
This code generates an error in C# 13 because the `await` is in the `unsafe` block.
51+
5052
The `ReverseText` method naively uses a background task to asynchronously create a new string in reverse order of a given string.
5153

5254
## To correct this error
5355

54-
Separating the unsafe code from the awaitable code will correct this error. One separation technique is creating a new method for the unsafe code and then calling it from the awaitable code. For example:
56+
Separating the unsafe code from the awaitable code corrects this error. One separation technique is creating a new method for the unsafe code and then calling it from the awaitable code. For example:
5557

5658
```csharp
5759
public static class C

0 commit comments

Comments
 (0)