|
1 | 1 | ---
|
2 |
| -title: What's new in the SDK for .NET 9 |
| 2 | +title: What's new in the SDK and tooling for .NET 9 |
3 | 3 | description: Learn about the new .NET SDK features introduced in .NET 9, including for unit testing, terminal logger, tool roll-forward, and build script analyzers.
|
4 | 4 | titleSuffix: ""
|
5 |
| -ms.date: 10/08/2024 |
| 5 | +ms.date: 10/26/2024 |
6 | 6 | ms.topic: whats-new
|
7 | 7 | ---
|
8 | 8 |
|
9 |
| -# What's new in the SDK for .NET 9 |
| 9 | +# What's new in the SDK and tooling for .NET 9 |
10 | 10 |
|
11 |
| -This article describes new features in the .NET SDK for .NET 9. It's been updated for .NET RC 2. |
| 11 | +This article describes new features in the .NET SDK and tooling for .NET 9. It's been updated for .NET RC 2. |
12 | 12 |
|
13 | 13 | ## Unit testing
|
14 | 14 |
|
@@ -200,3 +200,19 @@ Requirements (depending on your environment):
|
200 | 200 | ### Environment variable naming
|
201 | 201 |
|
202 | 202 | Environment variables that the container publish tooling uses to control some of the finer aspects of registry communication and security now start with the prefix `DOTNET` instead of `SDK`. The `SDK` prefix will continue to be supported in the near term.
|
| 203 | + |
| 204 | +## Code analysis |
| 205 | + |
| 206 | +.NET 9 includes several new code analyzers and fixers to help verify that you're using .NET library APIs correctly and efficiently. The following table summarizes the new analyzers. |
| 207 | + |
| 208 | +| Rule ID | Category | Description | |
| 209 | +|---------|----------|-------------| |
| 210 | +| [CA1514: Avoid redundant length argument](../../../fundamentals/code-analysis/quality-rules/ca1514.md) | Maintainability | An explicitly calculated length argument can be error-prone and is unnecessary when you're slicing to the end of a string or buffer. | |
| 211 | +| [CA1515: Consider making public types internal](../../../fundamentals/code-analysis/quality-rules/ca1515.md) | Maintainability | Types inside an executable assembly should be declared as `internal`. | |
| 212 | +| [CA1871: Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull'](../../../fundamentals/code-analysis/quality-rules/ca1871.md) | Performance | For improved performance, it's better to check the `HasValue` property and manually throw an exception than to pass a nullable struct to `ArgumentNullException.ThrowIfNull`. | |
| 213 | +| [CA1872: Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString'](../../../fundamentals/code-analysis/quality-rules/ca1872.md) | Performance | Use <xref:System.Convert.ToHexString*?displayProperty=nameWithType> or <xref:System.Convert.ToHexStringLower*?displayProperty=nameWithType> when encoding bytes to a hexadecimal string representation. | |
| 214 | +| [CA2022: Avoid inexact read with Stream.Read](../../../fundamentals/code-analysis/quality-rules/ca2022.md) | Reliability | A call to `Stream.Read` might return fewer bytes than requested, resulting in unreliable code if the return value isn't checked. | |
| 215 | +| [CA2262: Set 'MaxResponseHeadersLength' properly](../../../fundamentals/code-analysis/quality-rules/ca2262.md) | Usage | The <xref:System.Net.Http.HttpClientHandler.MaxResponseHeadersLength?displayProperty=nameWithType> property is measured in kilobytes, not bytes. | |
| 216 | +| [CA2263: Prefer generic overload when type is known](../../../fundamentals/code-analysis/quality-rules/ca2263.md) | Usage | Generic overloads are preferable to overloads that accept an argument of type <xref:System.Type?displayProperty=fullName> when the type is known at compile time. | |
| 217 | +| [CA2264: Do not pass a non-nullable value to 'ArgumentNullException.ThrowIfNull'](../../../fundamentals/code-analysis/quality-rules/ca2264.md) | Usage | Certain constructs like non-nullable structs (except for <xref:System.Nullable%601>), 'nameof()' expressions, and 'new' expressions are known to never be null, so `ArgumentNullException.ThrowIfNull` will never throw. | |
| 218 | +| [CA2265](../../../fundamentals/code-analysis/quality-rules/ca2265.md) | Usage | Comparing a span to `null` or `default` might not do what you intended. `default` and the `null` literal are implicitly converted to <xref:System.Span`1.Empty?displayProperty=nameWithType>. Remove the redundant comparison or make the code more explicit by using `IsEmpty`. | |
0 commit comments