Skip to content

Commit

Permalink
Return false from ComWrappers.Try... methods
Browse files Browse the repository at this point in the history
Return false from ComWrappers.TryGetComInstance/TryGetObject instead of
throwing PNSE. It saves callers from needing to protect against PNSE.

Fix #90311
  • Loading branch information
jkotas authored and github-actions committed Aug 15, 2023
1 parent 9607d25 commit 325eeb7
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ public abstract partial class ComWrappers
{
public static unsafe bool TryGetComInstance(object obj, out IntPtr unknown)
{
throw new PlatformNotSupportedException();
unknown = default;
return false;
}

public static unsafe bool TryGetObject(IntPtr unknown, [NotNullWhen(true)] out object? obj)
{
throw new PlatformNotSupportedException();
obj = default;
return false;
}

public partial struct ComInterfaceDispatch
Expand Down

0 comments on commit 325eeb7

Please sign in to comment.