-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add breaking change documentation for WPF and WinForms disambiguation #45203
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
docs/core/compatibility/windows-forms/10.0/menuitem-contextmenu.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| --- | ||
| title: "Breaking change - Applications referencing both WPF and WinForms must disambiguate MenuItem and ContextMenu types" | ||
| description: "Learn about the breaking change in .NET 10 Preview 1 where applications referencing both WPF and WinForms must disambiguate MenuItem and ContextMenu types." | ||
| ms.date: 3/11/2025 | ||
| ai-usage: ai-assisted | ||
| ms.custom: https://github.com/dotnet/docs/issues/44738 | ||
| --- | ||
|
|
||
| # Applications referencing both WPF and WinForms must disambiguate MenuItem and ContextMenu types | ||
|
|
||
| This document describes a breaking change introduced in .NET 10 Preview 1. Applications that reference both Windows Presentation Foundation (WPF) and Windows Forms (WinForms) must disambiguate certain types, such as `MenuItem` and `ContextMenu`, to avoid compile-time errors. | ||
|
|
||
| ## Version introduced | ||
|
|
||
| .NET 10 Preview 1 | ||
|
|
||
| ## Previous behavior | ||
|
|
||
| Previously, the types `ContextMenu`, `DataGrid`, `DataGridCell`, `Menu`, `MenuItem`, `ToolBar`, and `StatusBar` would resolve to the <xref:System.Windows.Controls> namespace because they did not exist in the <xref:System.Windows.Forms> namespace in .NET Core 3.1 through .NET 9.0. | ||
|
|
||
| ```xml | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <UseWindowsForms>true</UseWindowsForms> | ||
| <UseWPF>true</UseWPF> | ||
| ``` | ||
|
|
||
| ## New behavior | ||
|
|
||
| The affected types in the <xref:System.Windows.Forms> namespace cause a compile-time error when there is an ambiguous reference between <xref:System.Windows.Controls> and <xref:System.Windows.Forms>. | ||
|
|
||
| ```output | ||
| CS0104 'ContextMenu' is an ambiguous reference between 'System.Windows.Controls.ContextMenu' and 'System.Windows.Forms.ContextMenu' | ||
| ``` | ||
|
|
||
| ## Type of breaking change | ||
|
|
||
| This is a [source incompatible](../../categories.md#source-compatibility) change. | ||
|
|
||
| ## Reason for change | ||
|
|
||
| The change facilitates migration from .NET Framework when third-party libraries cannot be updated. A .NET 10 application can continue to reference .NET Framework dependencies and handle errors at runtime. | ||
|
|
||
| ## Recommended action | ||
|
|
||
| Use aliases to resolve conflicting namespaces. For example: | ||
|
|
||
| ```csharp | ||
| using ContextMenu = System.Windows.Controls.ContextMenu; | ||
| ``` | ||
|
|
||
| Refer to the [alias name conflicts documentation](/dotnet/csharp/language-reference/compiler-messages/using-directive-errors#alias-name-conflicts) for more details. | ||
|
|
||
| ## Affected APIs | ||
|
|
||
| - <xref:System.Windows.Forms.ContextMenu?displayProperty=fullName> | ||
| - <xref:System.Windows.Forms.DataGrid?displayProperty=fullName> | ||
| - <xref:System.Windows.Forms.DataGridCell?displayProperty=fullName> | ||
| - <xref:System.Windows.Forms.Menu?displayProperty=fullName> | ||
| - <xref:System.Windows.Forms.MenuItem?displayProperty=fullName> | ||
| - <xref:System.Windows.Forms.ToolBar?displayProperty=fullName> | ||
| - <xref:System.Windows.Forms.StatusBar?displayProperty=fullName> | ||
| - <xref:System.Windows.Controls.ContextMenu?displayProperty=fullName> | ||
| - <xref:System.Windows.Controls.DataGrid?displayProperty=fullName> | ||
| - <xref:System.Windows.Controls.DataGridCell?displayProperty=fullName> | ||
| - <xref:System.Windows.Controls.Menu?displayProperty=fullName> | ||
| - <xref:System.Windows.Controls.MenuItem?displayProperty=fullName> | ||
| - <xref:System.Windows.Controls.ToolBar?displayProperty=fullName> | ||
| - `System.Windows.Controls.StatusBar` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be relative link since it's in the same repo.