Skip to content

Commit 042ad29

Browse files
authored
EventsThreadShutdown obsoletion (#44287)
1 parent cf92601 commit 042ad29

File tree

8 files changed

+135
-2
lines changed

8 files changed

+135
-2
lines changed

docs/core/compatibility/10.0.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Breaking changes in .NET 10
3+
titleSuffix: ""
4+
description: Navigate to the breaking changes in .NET 10.
5+
ms.date: 12/19/2024
6+
no-loc: [Blazor, Razor, Kestrel]
7+
---
8+
# Breaking changes in .NET 10
9+
10+
If you're migrating an app to .NET 10, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or Windows Forms.
11+
12+
[!INCLUDE [binary-source-behavioral](includes/binary-source-behavioral.md)]
13+
14+
> [!NOTE]
15+
>
16+
> This article is a work in progress. It's not a complete list of breaking changes in .NET 10. To query breaking changes that are still pending publication, see [Issues of .NET](https://issuesof.net/?q=%20is:open%20-label:Documented%20is:issue%20(label:%22Breaking%20Change%22%20or%20label:breaking-change)%20(repo:dotnet/docs%20or%20repo:aspnet/Announcements)%20group:repo%20(label:%22:checkered_flag:%20Release:%20.NET%2010%22%20or%20label:10.0.0)%20sort:created-desc).
17+
18+
## Core .NET libraries
19+
20+
| Title | Type of change | Introduced version |
21+
|------------------------------------------------------------------------------------------|---------------------|--------------------|
22+
| [API obsoletions with non-default diagnostic IDs](core-libraries/10.0/obsolete-apis.md) | Source incompatible | Preview 1 |
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: "Breaking change: .NET 10 obsoletions with custom IDs"
3+
titleSuffix: ""
4+
description: Learn about the APIs that have been marked as obsolete in .NET 10 with a custom diagnostic ID.
5+
ms.date: 01/14/2025
6+
---
7+
# API obsoletions with non-default diagnostic IDs (.NET 10)
8+
9+
Some APIs have been marked as obsolete, starting in .NET 10. This breaking change is specific to APIs that have been marked as obsolete *with a custom diagnostic ID*. Suppressing the default obsoletion diagnostic ID, which is [CS0618](../../../../csharp/language-reference/compiler-messages/cs0618.md) for the C# compiler, does not suppress the warnings that the compiler generates when these APIs are used.
10+
11+
## Change description
12+
13+
In previous .NET versions, these APIs can be used without any build warning. In .NET 10 and later versions, use of these APIs produces a compile-time warning or error with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the obsoletion warnings individually instead of blanket-suppressing all obsoletion warnings.
14+
15+
The following table lists the custom diagnostic IDs and their corresponding warning messages for obsoleted APIs.
16+
17+
| Diagnostic ID | Description | Severity |
18+
|---------------|-------------|----------|
19+
| [SYSLIB0059](../../../../fundamentals/syslib-diagnostics/syslib0059.md) | <xref:Microsoft.Win32.SystemEvents.EventsThreadShutdown?displayProperty=nameWithType> callbacks aren't run before the process exits. Use <xref:System.AppDomain.ProcessExit?displayProperty=nameWithType> instead. | Warning |
20+
21+
## Version introduced
22+
23+
.NET 9
24+
25+
## Type of breaking change
26+
27+
These obsoletions can affect [source compatibility](../../categories.md#source-compatibility).
28+
29+
## Recommended action
30+
31+
- Follow the specific guidance provided for the each diagnostic ID using the URL link provided on the warning.
32+
33+
- Warnings or errors for these obsoletions can't be suppressed using the standard diagnostic ID for obsolete types or members; use the custom `SYSLIBxxxx` diagnostic ID value instead.
34+
35+
## Affected APIs
36+
37+
### SYSLIB0059
38+
39+
- <xref:Microsoft.Win32.SystemEvents.EventsThreadShutdown?displayProperty=fullName>
40+
41+
## See also
42+
43+
- [API obsoletions with non-default diagnostic IDs (.NET 9)](../9.0/obsolete-apis-with-custom-diagnostics.md)
44+
- [API obsoletions with non-default diagnostic IDs (.NET 8)](../8.0/obsolete-apis-with-custom-diagnostics.md)
45+
- [Obsolete features in .NET 5+](../../../../fundamentals/syslib-diagnostics/obsoletions-overview.md)

docs/core/compatibility/core-libraries/8.0/obsolete-apis-with-custom-diagnostics.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ The `SYSLIB0051` API obsoletions are organized here by namespace.
562562

563563
## See also
564564

565+
- [API obsoletions with non-default diagnostic IDs (.NET 10)](../10.0/obsolete-apis.md)
566+
- [API obsoletions with non-default diagnostic IDs (.NET 9)](../9.0/obsolete-apis-with-custom-diagnostics.md)
565567
- [API obsoletions with non-default diagnostic IDs (.NET 7)](../7.0/obsolete-apis-with-custom-diagnostics.md)
566568
- [API obsoletions with non-default diagnostic IDs (.NET 6)](../6.0/obsolete-apis-with-custom-diagnostics.md)
567569
- [API obsoletions with non-default diagnostic IDs (.NET 5)](../5.0/obsolete-apis-with-custom-diagnostics.md)

docs/core/compatibility/core-libraries/9.0/obsolete-apis-with-custom-diagnostics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ These obsoletions can affect [source compatibility](../../categories.md#source-c
106106

107107
## See also
108108

109+
- [API obsoletions with non-default diagnostic IDs (.NET 10)](../10.0/obsolete-apis.md)
109110
- [API obsoletions with non-default diagnostic IDs (.NET 8)](../8.0/obsolete-apis-with-custom-diagnostics.md)
110111
- [API obsoletions with non-default diagnostic IDs (.NET 7)](../7.0/obsolete-apis-with-custom-diagnostics.md)
111112
- [API obsoletions with non-default diagnostic IDs (.NET 6)](../6.0/obsolete-apis-with-custom-diagnostics.md)

docs/core/compatibility/toc.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ items:
44
- name: Breaking changes by version
55
expanded: true
66
items:
7+
- name: .NET 10
8+
items:
9+
- name: Overview
10+
href: 10.0.md
11+
- name: Core .NET libraries
12+
items:
13+
- name: API obsoletions with non-default diagnostic IDs
14+
href: core-libraries/10.0/obsolete-apis.md
715
- name: .NET 9
816
items:
917
- name: Overview
@@ -1302,6 +1310,10 @@ items:
13021310
href: https://github.com/dotnet/dotnet-docker/discussions/3699
13031311
- name: Core .NET libraries
13041312
items:
1313+
- name: .NET 10
1314+
items:
1315+
- name: API obsoletions with non-default diagnostic IDs
1316+
href: core-libraries/10.0/obsolete-apis.md
13051317
- name: .NET 9
13061318
items:
13071319
- name: Adding a ZipArchiveEntry sets header general-purpose bit flags

docs/fundamentals/syslib-diagnostics/obsoletions-overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Obsolete features in .NET 5+
33
titleSuffix: ""
44
description: Learn about APIs that are marked as obsolete in .NET 5 and later versions that produce SYSLIB compiler warnings.
5-
ms.date: 08/07/2024
5+
ms.date: 01/14/2025
66
---
77

88
# Obsolete features in .NET 5+
@@ -78,6 +78,8 @@ The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+
7878
| [SYSLIB0055](syslib0055.md) | Warning | `AdvSimd.ShiftRightLogicalRoundedNarrowingSaturate*` methods with signed parameters are obsolete. Use the unsigned overloads instead. |
7979
| [SYSLIB0056](syslib0056.md) | Warning | `Assembly.LoadFrom` with a custom `AssemblyHashAlgorithm` is obsolete. Use overloads without an `AssemblyHashAlgorithm`. |
8080
| [SYSLIB0057](syslib0057.md) | Warning | `X509Certificate2` and `X509Certificate` constructors for binary and file content are obsolete. |
81+
| SYSLIB0058 | Warning | The `KeyExchangeAlgorithm`, `KeyExchangeStrength`, `CipherAlgorithm`, `CipherAlgorithmStrength`, `HashAlgorithm`, and `HashStrength` properties of <xref:System.Net.Security.SslStream> are obsolete. Use <xref:System.Net.Security.SslStream.NegotiatedCipherSuite> instead. |
82+
| [SYSLIB0059](syslib0059.md) | Warning | <xref:Microsoft.Win32.SystemEvents.EventsThreadShutdown?displayProperty=nameWithType> callbacks aren't run before the process exits. Use <xref:System.AppDomain.ProcessExit?displayProperty=nameWithType> instead. |
8183

8284
## Suppress warnings
8385

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: SYSLIB0059 warning - SystemEvents.EventsThreadShutdown callbacks aren't run before the process exits
3+
description: Learn about the obsoletion of SystemEvents.EventsThreadShutdown that generates compile-time warning SYSLIB0059.
4+
ms.date: 08/01/2024
5+
f1_keywords:
6+
- SYSLIB0059
7+
---
8+
# SYSLIB0059: SystemEvents.EventsThreadShutdown callbacks aren't run before the process exits
9+
10+
The <xref:Microsoft.Win32.SystemEvents.EventsThreadShutdown?displayProperty=nameWithType> event is obsolete, starting in .NET 10. Referencing this event in code generates warning `SYSLIB0059` at compile time.
11+
12+
## Reason for obsoletion
13+
14+
The previous shutdown handling in <xref:Microsoft.Win32.SystemEvents> could block the finalizer thread during app shutdown. To avoid blocking the finalizer thread, <xref:Microsoft.Win32.SystemEvents> no longer has shutdown handling, which means that the <xref:Microsoft.Win32.SystemEvents.EventsThreadShutdown?displayProperty=nameWithType> event is no longer called. To surface this behavior change, the event was marked obsolete.
15+
16+
## Workaround
17+
18+
Use <xref:System.AppDomain.ProcessExit?displayProperty=nameWithType> instead.
19+
20+
## Suppress a warning
21+
22+
If you must use the obsolete API, you can suppress the warning in code or in your project file.
23+
24+
To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.
25+
26+
```csharp
27+
// Disable the warning.
28+
#pragma warning disable SYSLIB0059
29+
30+
// Code that uses obsolete API.
31+
// ...
32+
33+
// Re-enable the warning.
34+
#pragma warning restore SYSLIB0059
35+
```
36+
37+
To suppress all the `SYSLIB0059` warnings in your project, add a `<NoWarn>` property to your project file.
38+
39+
```xml
40+
<Project Sdk="Microsoft.NET.Sdk">
41+
<PropertyGroup>
42+
...
43+
<NoWarn>$(NoWarn);SYSLIB0059</NoWarn>
44+
</PropertyGroup>
45+
</Project>
46+
```
47+
48+
For more information, see [Suppress warnings](obsoletions-overview.md#suppress-warnings).

docs/navigate/tools-diagnostics/toc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1818,14 +1818,15 @@ items:
18181818
href: ../../fundamentals/syslib-diagnostics/syslib0056.md
18191819
- name: SYSLIB0057
18201820
href: ../../fundamentals/syslib-diagnostics/syslib0057.md
1821+
- name: SYSLIB0059
1822+
href: ../../fundamentals/syslib-diagnostics/syslib0059.md
18211823
- name: Experimental features
18221824
items:
18231825
- name: Overview
18241826
displayName: syslib, experimental
18251827
href: ../../fundamentals/syslib-diagnostics/experimental-overview.md
18261828
- name: SYSLIB5003
18271829
href: ../../fundamentals/syslib-diagnostics/syslib5003.md
1828-
displayProperty: syslib5003
18291830
- name: Source-generated code
18301831
items:
18311832
- name: Overview

0 commit comments

Comments
 (0)