Skip to content
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

Improve handling of not found exception from GetViewForHwnd() and re-add TogglePin functions #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sliddington
Copy link

Catch not found exception from GetViewForHwnd() to return null or throw ArgumentException

@sliddington sliddington changed the title Improve handling of not found exception from GetViewForHwnd() Improve handling of not found exception from GetViewForHwnd() and add TogglePin functions Aug 21, 2016
@sliddington sliddington changed the title Improve handling of not found exception from GetViewForHwnd() and add TogglePin functions Improve handling of not found exception from GetViewForHwnd() and re-add TogglePin functions Aug 21, 2016
Copy link

@ericnewton76 ericnewton76 left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this pull request. I added a few thoughts to the code.

ComObjects.ApplicationViewCollection.GetViewForHwnd(hWnd, out view);
return view;
}
catch (System.Runtime.InteropServices.COMException ex) when (ex.Match(HResult.TYPE_E_ELEMENTNOTFOUND))

Choose a reason for hiding this comment

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

might consider not using C#6.0 specific features yet for more broad compilation support of the library itself


if (view == null)
{
throw new ArgumentException(nameof(hWnd));

Choose a reason for hiding this comment

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

this should message out why its an argument exception, and probably not use C#6.0 for more broad compilation possibility:
throw new ArgumentException("hWnd specified not found","hWnd");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants