Skip to content

Commit

Permalink
Removed usage of ThrowExceptionForHR for ThrowOnFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuelie committed Dec 17, 2023
1 parent 7783e1a commit e33dac2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Shmuelie.WinRTServer/ComServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public unsafe bool RegisterClassFactory(BaseClassFactory factory)
proxy.Attach(BaseClassFactoryProxy.Create(factory));

uint cookie;
Marshal.ThrowExceptionForHR(CoRegisterClassObject(&clsid, (IUnknown*)proxy.Get(), CLSCTX.CLSCTX_LOCAL_SERVER, (REGCLS.REGCLS_MULTIPLEUSE | REGCLS.REGCLS_SUSPENDED), &cookie));
CoRegisterClassObject(&clsid, (IUnknown*)proxy.Get(), CLSCTX.CLSCTX_LOCAL_SERVER, (REGCLS.REGCLS_MULTIPLEUSE | REGCLS.REGCLS_SUSPENDED), &cookie).ThrowOnFailure();

factories.Add(clsid, (factory, cookie));
return true;
Expand Down Expand Up @@ -163,7 +163,7 @@ public unsafe bool UnregisterClassFactory(Guid clsid)

data.factory.InstanceCreated -= Factory_InstanceCreated;

Marshal.ThrowExceptionForHR(CoRevokeClassObject(data.cookie));
CoRevokeClassObject(data.cookie).ThrowOnFailure();
return true;
}

Expand Down Expand Up @@ -201,7 +201,7 @@ public void Start()

firstInstanceCreated = new();
lifetimeCheckTimer.Start();
Marshal.ThrowExceptionForHR(CoResumeClassObjects());
CoResumeClassObjects().ThrowOnFailure();
}

/// <summary>
Expand All @@ -221,7 +221,7 @@ public void Stop()

firstInstanceCreated = null;
lifetimeCheckTimer.Stop();
Marshal.ThrowExceptionForHR(CoSuspendClassObjects());
CoSuspendClassObjects().ThrowOnFailure();
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Shmuelie.WinRTServer/WinRtServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public unsafe WinRtServer()
HRESULT result = RoInitialize(RO_INIT_TYPE.RO_INIT_MULTITHREADED);
if (result != HRESULT.S_OK && result != HRESULT.S_FALSE)
{
Marshal.ThrowExceptionForHR(result);
result.ThrowOnFailure();
}

using ComPtr<IGlobalOptions> options = default;
Expand Down Expand Up @@ -232,7 +232,7 @@ public unsafe void Start()
string managedActivatableClassId = managedActivatableClassIds[activatableClassIdIndex];
fixed (char* managedActivatableClassIdPtr = managedActivatableClassId)
{
Marshal.ThrowExceptionForHR(WindowsCreateString((PCWSTR)managedActivatableClassIdPtr, (uint)managedActivatableClassId.Length, &activatableClassIds[activatableClassIdIndex]));
WindowsCreateString((PCWSTR)managedActivatableClassIdPtr, (uint)managedActivatableClassId.Length, &activatableClassIds[activatableClassIdIndex]).ThrowOnFailure();
}
}

Expand All @@ -244,7 +244,7 @@ public unsafe void Start()

fixed (RO_REGISTRATION_COOKIE* cookie = &registrationCookie)
{
Marshal.ThrowExceptionForHR(RoRegisterActivationFactories(activatableClassIds, activationFactoryCallbacks, (uint)managedActivatableClassIds.Length, cookie));
RoRegisterActivationFactories(activatableClassIds, activationFactoryCallbacks, (uint)managedActivatableClassIds.Length, cookie).ThrowOnFailure();
}
}
finally
Expand Down

0 comments on commit e33dac2

Please sign in to comment.