Skip to content

Commit 4ecc90e

Browse files
author
Cam Soper
authored
Windows Form warnings (#45189)
* Windows Form warnings * date
1 parent 75a5e1d commit 4ecc90e

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

docs/core/compatibility/10.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
5656

5757
| Title | Type of change | Introduced version |
5858
|-------------------------------------------------------------------------------------------------------------------|---------------------|--------------------|
59+
| [API obsoletions](windows-forms/10.0/obsolete-apis.md) | Source incompatible | Preview 1 |
5960
| [Renamed parameter in HtmlElement.InsertAdjacentElement](windows-forms/10.0/insertadjacentelement-orientation.md) | Source incompatible | Preview 1 |
6061
| [TreeView checkbox image truncation](windows-forms/10.0/treeview-text-location.md) | Behavioral change | Preview 1 |
6162
| [StatusStrip uses System RenderMode by default](windows-forms/10.0/statusstrip-renderer.md) | Behavioral change | Preview 1 |

docs/core/compatibility/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ items:
4444
href: sdk/10.0/custom-build-event-warning.md
4545
- name: Windows Forms
4646
items:
47+
- name: API obsoletions
48+
href: windows-forms/10.0/obsolete-apis.md
4749
- name: Renamed parameter in HtmlElement.InsertAdjacentElement
4850
href: windows-forms/10.0/insertadjacentelement-orientation.md
4951
- name: TreeView checkbox image truncation
@@ -2124,6 +2126,8 @@ items:
21242126
items:
21252127
- name: .NET 10
21262128
items:
2129+
- name: API obsoletions
2130+
href: windows-forms/10.0/obsolete-apis.md
21272131
- name: Renamed parameter in HtmlElement.InsertAdjacentElement
21282132
href: windows-forms/10.0/insertadjacentelement-orientation.md
21292133
- name: TreeView checkbox image truncation
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: "Breaking change: .NET 10 obsoletions in Windows Forms"
3+
titleSuffix: ""
4+
description: Learn about the .NET 10 breaking change where some Windows Forms APIs have been marked as obsolete.
5+
ms.date: 03/10/2025
6+
---
7+
# Windows Forms obsoletions (.NET 10)
8+
9+
Some Windows Forms APIs have been marked as obsolete, starting in .NET 10.
10+
11+
## Previous behavior
12+
13+
In previous .NET versions, these APIs can be used without any build warning.
14+
15+
## New behavior
16+
17+
In .NET 10 and later versions, use of these APIs produces a compile-time warning with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the warnings individually instead of blanket-suppressing all obsoletion warnings.
18+
19+
The following table lists the custom diagnostic IDs and their corresponding warning messages.
20+
21+
| Diagnostic ID | Description | Severity | Version introduced |
22+
| - | - |
23+
| [WFDEV004](/dotnet/desktop/winforms/wfdev-diagnostics/wfdev004) | <xref:System.Windows.Forms.Form.OnClosing(System.ComponentModel.CancelEventArgs)?displayProperty=nameWithType>, <xref:System.Windows.Forms.Form.OnClosed(System.EventArgs)?displayProperty=nameWithType> and the corresponding events are obsolete. Use <xref:System.Windows.Forms.Form.OnFormClosing(System.Windows.Forms.FormClosingEventArgs)?displayProperty=nameWithType>, <xref:System.Windows.Forms.Form.OnFormClosed(System.Windows.Forms.FormClosedEventArgs)?displayProperty=nameWithType>, <xref:System.Windows.Forms.Form.FormClosing?displayProperty=nameWithType> and <xref:System.Windows.Forms.Form.FormClosed?displayProperty=nameWithType> instead. | Warning | Preview 1 |
24+
| [WFDEV005](/dotnet/desktop/winforms/wfdev-diagnostics/wfdev005) | <xref:System.Windows.Clipboard.GetData(System.String)?displayProperty=nameWithType> method is obsolete. Use <xref:System.Windows.Forms.Clipboard.TryGetData*?displayProperty=nameWithType> methods instead. | Warning | Preview 1 |
25+
| [WFDEV006](/dotnet/desktop/winforms/wfdev-diagnostics/wfdev006) | <xref:System.Windows.Forms.ContextMenu>, <xref:System.Windows.Forms.DataGrid>, <xref:System.Windows.Forms.MainMenu>, <xref:System.Windows.Forms.Menu>, <xref:System.Windows.Forms.StatusBar>, <xref:System.Windows.Forms.ToolBar> are obsolete. They're provided for binary compatibility with .NET Framework. | Warning | Preview 1 |
26+
27+
## Version introduced
28+
29+
.NET 10
30+
31+
## Type of breaking change
32+
33+
These obsoletion warnings can affect [source compatibility](../../categories.md#source-compatibility).
34+
35+
## Recommended action
36+
37+
- Follow the specific guidance provided for the each diagnostic ID using the URL link provided on the warning.
38+
- If necessary, you can suppress the warning using the custom `WFDEVxxx` diagnostic ID value.
39+
40+
## Affected APIs
41+
42+
### WFDEV004
43+
44+
- <xref:System.Windows.Forms.Form.OnClosing(System.ComponentModel.CancelEventArgs)>
45+
- <xref:System.Windows.Forms.Form.OnClosed(System.EventArgs)?displayProperty=fullName>
46+
47+
### WFDEV005
48+
49+
- <xref:System.Windows.Clipboard.GetData(System.String)?displayProperty=fullName>
50+
51+
### WFDEV006
52+
53+
- <xref:System.Windows.Forms.ContextMenu?displayProperty=fullName>
54+
- <xref:System.Windows.Forms.DataGrid?displayProperty=fullName>
55+
- <xref:System.Windows.Forms.MainMenu?displayProperty=fullName>
56+
- <xref:System.Windows.Forms.Menu?displayProperty=fullName>
57+
- <xref:System.Windows.Forms.StatusBar?displayProperty=fullName>
58+
- <xref:System.Windows.Forms.ToolBar?displayProperty=fullName>
59+
60+
## See also
61+
62+
- [Obsolete Windows Forms features in .NET 10+](/dotnet/desktop/winforms/wfdev-diagnostics/obsoletions-overview)

0 commit comments

Comments
 (0)