Skip to content

Conversation

@hughbe
Copy link
Contributor

@hughbe hughbe commented Jul 6, 2019

Fixes #1296
Contributes to #817

@hughbe hughbe requested a review from a team as a code owner July 6, 2019 11:10
Copy link
Contributor

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please clarify what the bug was?

IWindowsFormsEditorService edSvc =
(IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null)
if (provider.GetService(typeof(IWindowsFormsEditorService)) is IWindowsFormsEditorService edSvc)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the contribution to #817 @RussKie

get
{
if (((Keys)currentValue & Keys.KeyCode) == 0)
if (currentValue is Keys currentKeys && (currentKeys & Keys.KeyCode) == 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix to #1296 @RussKie

originalValue = currentValue = value;

Keys keys = (Keys)value;
Keys keys = value is Keys ? (Keys)value : Keys.None;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix to #1296 @RussKie

@hughbe
Copy link
Contributor Author

hughbe commented Jul 8, 2019

Can you please clarify what the bug was?

If you called new ShortcutKeysEditor().EditValue(null, provider, new object()) then we'd throw an InvalidCastException

@hughbe hughbe closed this Jul 8, 2019
@hughbe hughbe reopened this Jul 8, 2019
@RussKie RussKie merged commit c251efa into dotnet:master Jul 9, 2019
@hughbe hughbe deleted the ShortcutKeysEditor-Tests branch July 9, 2019 08:47
@ghost ghost locked as resolved and limited conversation to collaborators Feb 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ShortcutKeysEditor.EditValue throws InvalidCastException if value is not a Shortcut

2 participants