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

Convert to using CsWin32 HRESULT definition #10155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JeremyKuhne
Copy link
Member

@JeremyKuhne JeremyKuhne commented Dec 10, 2024

This converts to using the CsWin32 HRESULT definition. It creates two HRESULT helpers to provide compatible throw behavior for existing code (PresentationCore threw things one way, other assemblies threw a different way).

Also:

  • Remove dead interop defines (a lot)
  • Add Primitives test project
  • Force test projects to use open source key (which System.Private.Windows.Core expects)
  • Tweak build files a bit to try and ensure test dependencies are in place
  • Add strings to System.Windows.Primitives to facilitate unifying hresult handling in the future (need to redirect InvalidWmpVersionException)

It would be nice to always throw the same way, but that would change exceptions that currently get thrown. Combining the behavior from both would give whatever Marshal gives with special handling for WIC/MIL errors and unwrapping of Win32 COMExceptions into Win32Exceptions.

Converting the existing interop to use CsWin32 types will make transitioning far easier. The next change I'm working on is using HWND.

Microsoft Reviewers: Open in CodeFlow

This converts to using the CsWin32 HRESULT definition. It creates two HRESULT helpers to provide compatible throw behavior for existing code (PresentationCore threw things one way, other assemblies threw a different way).

Also:

- Remove dead interop defines (a lot)
- Add Primitives test project
- Force test projects to use open source key (which System.Private.Windows.Core expects)
- Tweak build files a bit to try and ensure test dependencies are in place
- Add strings to System.Windows.Primitives to facilitate unifying hresult handling in the future (need to redirect InvalidWmpVersionException)

It would be nice to always throw the same way, but that would change exceptions that currently get thrown. Combining the behavior from both would give whatever Marshal gives with special handling for WIC/MIL errors and unwrapping of Win32 COMExceptions into Win32Exceptions.

Converting the existing interop to use CsWin32 types will make transitioning far easier. The next change I'm working on is using HWND.
@JeremyKuhne JeremyKuhne requested review from a team as code owners December 10, 2024 01:22
@JeremyKuhne
Copy link
Member Author

FYI @harshit7962

@dotnet-policy-service dotnet-policy-service bot added the PR metadata: Label to tag PRs, to facilitate with triage label Dec 10, 2024
Copy link
Member

@lonitra lonitra left a comment

Choose a reason for hiding this comment

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

Got through some, looks good so far. Will circle back to review the rest.

Copy link
Member

@lonitra lonitra left a comment

Choose a reason for hiding this comment

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

LGTM mostly just some small style comments

Copy link
Member

@lonitra lonitra left a comment

Choose a reason for hiding this comment

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

👍

@JeremyKuhne
Copy link
Member Author

Note that I haven't changed every instance of int to HRESULT. If we weren't looking at the result, I didn't necessarily change it as most of this will go away when switching to generated interop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants