Fix WinRT marshalling for NotifyPropertyChangedEventArgs and NotifyCollectionChangedE...
authorJeremy Koritzinsky <jkoritzinsky@gmail.com>
Tue, 26 Mar 2019 19:24:45 +0000 (12:24 -0700)
committerGitHub <noreply@github.com>
Tue, 26 Mar 2019 19:24:45 +0000 (12:24 -0700)
commite6f95a5fe7caedcda86d276fce664bfa5a9073a8
tree4667b4b4f975a0701fb23bb5608c86f4fd57fbfd
parente77c2b77ba412a8727381d4fc0deac93ab5e65db
Fix WinRT marshalling for NotifyPropertyChangedEventArgs and NotifyCollectionChangedEventArgs (CoreFX side) (dotnet/corefx#36224)

The fix for dotnet/corefxdotnet/corefx#35909 requires both some runtime work and some framework work since the marshalling helpers for NotifyPropertyChangedEventArgs and NotifyCollectionChangedEventArgs lives in corefx.

In this PR:

 - Update the signatures of `INotifyCollectionChangedEventArgsFactory.CreateInstanceWithAllParameters` and `INotifyPropertyChangedEventArgsFactory.CreateInstance` to be as close to their official `winmd` signature as possible.

We cannot update the return types since we need to make sure we return the raw COM object pointer and not a pointer to an RCW that was projected through our WinRT type projection back to managed. (depends on dotnet/coreclrdotnet/corefx#23401)

- Call a new function on `System.Runtime.InteropServices.WindowsRuntimeMarshal` called `GetUniqueObjectForIUnknownWithoutUnboxing` (introduced in dotnet/coreclrdotnet/corefx#23401) to get back an RCW for the IUnknown pointer without going through the WinRT projections. The WinRT projections for `INotifyPropertyChangedEventArgs` and `INotifyCollectionChangedEventArgs` go through this code to project themselves to the managed code, so we need a way to get back a "raw" RCW that is not projected to avoid infinitely recursing into a stack-overflow (current behavior) and avoid having to manually traversing the vtable of the native interfaces (impractical to implement).

Depends on dotnet/coreclrdotnet/corefx#23401

Fixes dotnet/corefx#35909

Co-authored-by: Jeff Schwartz <JeffSchw@microsoft.com>
Commit migrated from https://github.com/dotnet/corefx/commit/b0123b9bdd9a4bf0b1447d9d2a4c4b77ed708f05
src/libraries/System.Runtime.WindowsRuntime/src/System/Runtime/InteropServices/WindowsRuntime/MarshalingHelpers.cs