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 dotnet#90311
  • Loading branch information
jkotas committed Aug 14, 2023
1 parent 1d09abf commit fe931fb
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 fe931fb

Please sign in to comment.