-
Notifications
You must be signed in to change notification settings - Fork 957
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
fix 2091 Remove deprecated controls #2157
fix 2091 Remove deprecated controls #2157
Conversation
It seems strange that controls such as |
Codecov Report
@@ Coverage Diff @@
## release/3.1 #2157 +/- ##
===================================================
- Coverage 26.41782% 25.575% -0.84282%
===================================================
Files 818 793 -25
Lines 268811 252958 -15853
Branches 38145 35956 -2189
===================================================
- Hits 71014 64694 -6320
+ Misses 192719 183539 -9180
+ Partials 5078 4725 -353
|
I don't see how that documentation piece implies deprecation. |
@mikedn the documentation says the classes/properties couldn't be removed for backwards compatibility and you should use the replacement instead for any new code, sounds pretty much like deprecation to me even if it isn't spelled out. Its not said the underlying win32 API is deprecated, but having the same concept mapped twice into WinForms is unnecessary to say the least. WinForms already started this deprecation in other PRs, this is just continuing it. If you have problems with it and reasons to use those classes in your application its probably a good idea to open a separate issue to discuss it, as some PRs have already passed I think. For what it matters the corresponding properties to set e.g. ContextMenu have been removed from designers for a while, it is just consequential to also hide the classes |
The documentation does not say "you should use the replacement". The documentation says "retained for both backward compatibility and future use if you choose".
Thanks but considering RussKie's teleported documentation paragraph without any other comment and your claim that the documentation says something that it actually doesn't I'm probably wasting my time here. |
@mikedn language lawyering is probably wasting time, yes. If something has been "retained for backwards compatibility" it indicates it was considered to be removed/replaced. Deprecation is not a formal process (even if it sometimes would be nice to have one) and documentation isn't specification (so arguing as such is also wasting time). I'm just explaining, if you don't care or are aware thats ok, I won't continue the discussion.
Well, that should probably be updated in the .NET Core documentation then, assuming they are planning on actually removing the API in later versions and not just keep hiding it from view. |
In .NET Framework we were bound to never remove any types because of the backwards compatibility reasons. .NET Core, being a SxS framework allows us more flexibility in this area. We've created, and the bulk of our customers use, the replacements of MenuStrip and DataGridView classes. As we modernize WinForms on Core we may be removing classes for which there are better alternatives. If a customer really wants to use the Menu, DataGrid and ContextMenu they are able to keep their app on the current version .NET Core (3.0) and use the classes. If they want to use other improvements in the stack we encourage them to look at the replacement classes. |
1291188
to
527587c
Compare
if (ContextMenu != null) | ||
{ | ||
CaptureInternal = false; | ||
} |
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 looks like a bug, originally CaptureInternal = true
if ContextMenu != null || ContextMenuStrip != null
, however it was reverted only in case of ContextMenu != null
...
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.
Could also have been a workaround for HMENU specific behavior, maybe HWND based menus didn't need to reset the capture, the events and call chains would have been entirely different. Without comments why it was done the way it is thats really hard to tell.
@@ -4157,49 +4151,15 @@ public HRESULT GetDragDropEffect(BOOL fDrag, int grfKeyState, ref int pdwEffect) | |||
public HRESULT GetContextMenu(short seltype, IntPtr lpoleobj, ref Richedit.CHARRANGE lpchrg, out IntPtr hmenu) |
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.
❗️ I'm really unsure about this method 😕
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.
I don't think ContextMenuStrip.Handle is a HMENU, is it? (Probably HWND) I don't know how this GetContextMenu method is used but if its for interop with win32 richedit you can't just rip out and replace their usage of HMENU. In fact, if you need HMENU for interop with a native controls menu you can't get rid of the old class at all (well you can replace it with something internal I guess)
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.
Just to confirm, I've checked base classes (see my other comment) and my suspicion is correct and you introduced a bug here by using ContextMenuStrip.Handle
(HWND) in place of ContextMenu.Handle
(HMENU)
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.
I see you did the same update here as with the other HMENU Handle access, I agree removing the code block for now until some regression can be identified (if there is any) is definitely better than leaving broken code in place.
For what its worth context menus appear to work without having this code block in place, so if it triggers at all it probably needs very special conditions and doesn't affect the general usecase.
src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs
Show resolved
Hide resolved
src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IMenuEditorService.cs
Outdated
Show resolved
Hide resolved
Marking things as IMHO the title of the PR is misleading, you are not just marking deprecated controls as obsolete, you are already removing the functionality. This should definitely NOT go into 3.1, thats something for a major version change. |
We have new directions every day 😁 |
fe34344
to
c4c39bf
Compare
Ok, just make sure you get the interop right, I'm not an expert on that part of the WinForms implementation but I think the replacement classes are a WinForms-only reimplementation (not a wrapper around win32 anymore) while the classes to be removed were interoperable with the win32 HMENU API. That means the replacement will be incompatible with any win32 interop (e.g. richedit came up above, ActiveX hosting and various OLE interfaces are other candidates which may interop over HMENU) |
ef75d09
to
c25937a
Compare
i have a concern though, winforms (unlike wpf) is heavily reliant on the visual designer, i.e. any modifications to the design will have to go through the visual designer, how do you plan on simplifying that process to replace old deprecated controls with new ones? |
It is not possible to replace controls via the Designer. |
Docs: dotnet/docs#15813 |
`ToolBar` implementation was removed in dotnet#2157. Closes dotnet#2372
Fixes #2091
Proposed changes
Menu
MainMenu
ContextMenu
MenuItem
IMenuEditorService
ToolBar
ToolBarAppearance
ToolBarButton
ToolBarButtonClickEventArgs
ToolBarButtonClickEventHandler
ToolBarButtonStyle
ToolBarTextAlign
DataGrid
DataGridAddNewRow
DataGridBoolColumn
DataGridCaption
DataGridCell
DataGridColumnCollection
DataGridColumnStyle
DataGridDefaultColumnWidthTypeConverter
DataGridLineStyle
DataGridParentRows
DataGridParentRowsLabel
DataGridRelationshipRow
DataGridRow
DataGridState
DataGridTableCollection
DataGridTableStyle
DataGridTextBox
DataGridTextBoxColumn
DataGridToolTip
GridTablesFactory
IDataGridEditingService
AxHost
type:ContextMenu ContextMenu { get; set; }
event EventHandler ContextMenuChanged
Control
type:ContextMenu ContextMenu { get; set; }
event EventHandler ContextMenuChanged
void OnContextMenuChanged(EventArgs e)
Form
type:MainMenu Menu { get; set; }
MainMenu MergedMenu { get; }
void Control.OnContextMenuChanged(EventArgs e)
NotifyIcon
type:ContextMenu ContextMenu { get; set; }
PrintPreviewDialog
type:MainMenu Menu { get; set; }
ContextMenu ContextMenu { get; set; }
event EventHandler ContextMenuChanged
ToolStripDropDown
type:ContextMenu ContextMenu { get; set; }
event EventHandler ContextMenuChanged
TreeNode
type:ContextMenu ContextMenu { get; set; }
UpDownBase
type:ContextMenu ContextMenu { get; set; }
Customer Impact
Regression?
Risk
Testing
Tested by the CTI team
Microsoft Reviewers: Open in CodeFlow