-
Notifications
You must be signed in to change notification settings - Fork 103
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
Consume IDynamicInterfaceCastable in the .NET 5 projection #369
Changes from all commits
4be3620
7ad98c8
58c590a
6e455f3
686cead
4fd093b
89a83ee
6511ae6
bcaf88e
cc30448
1f2efee
1f4d869
25e4e4b
b58f37d
a02a72c
b5c3c31
597a024
229fead
c38b4a2
471979e
ba117da
1cb8c01
4418c1b
80ccff5
94294d2
b06d2d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,22 @@ public class TestCSharp | |
public TestCSharp() | ||
{ | ||
TestObject = new Class(); | ||
} | ||
|
||
#if NET5_0 | ||
[Fact] | ||
public void TestDynamicInterfaceCastingOnValidInterface() | ||
{ | ||
var agileObject = (IAgileObject)(IWinRTObject)TestObject; | ||
Assert.NotNull(agileObject); | ||
} | ||
|
||
[Fact] | ||
public void TestDynamicInterfaceCastingOnInvalidInterface() | ||
{ | ||
Assert.ThrowsAny<System.Exception>(() => (IStringableInterop)(IWinRTObject)TestObject); | ||
} | ||
#endif | ||
|
||
async Task InvokeWriteBufferAsync() | ||
{ | ||
|
@@ -588,15 +603,17 @@ public void TestComposedNonBlittableStruct() | |
Assert.True(val.bools.x); | ||
Assert.False(val.bools.y); | ||
Assert.True(val.bools.z); | ||
} | ||
|
||
} | ||
|
||
#if NETCOREAPP2_0 | ||
[Fact] | ||
public void TestGenericCast() | ||
{ | ||
var ints = TestObject.GetIntVector(); | ||
var abiView = (ABI.System.Collections.Generic.IReadOnlyList<int>)ints; | ||
Assert.Equal(abiView.ThisPtr, abiView.As<WinRT.IInspectable>().As<ABI.System.Collections.Generic.IReadOnlyList<int>.Vftbl>().ThisPtr); | ||
} | ||
#endif | ||
|
||
[ComImport] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
|
@@ -838,7 +855,7 @@ public void TestClassGeneric() | |
{ | ||
var obj = objs[i]; | ||
Assert.Same(obj, TestObject); | ||
Assert.Equal(TestObject.ThisPtr, objs[i].ThisPtr); | ||
Assert.Equal(TestObject, objs[i]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how come the ThisPtr check was removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no longer a |
||
} | ||
} | ||
[Fact] | ||
|
@@ -1556,7 +1573,7 @@ internal class ManagedType { } | |
public void CCWOfListOfManagedType() | ||
{ | ||
using var ccw = ComWrappersSupport.CreateCCWForObject(new List<ManagedType>()); | ||
using var qiResult = ccw.As(GuidGenerator.GetIID(typeof(ABI.System.Collections.Generic.IEnumerable<object>))); | ||
using var qiResult = ccw.As(GuidGenerator.GetIID(typeof(global::System.Collections.Generic.IEnumerable<object>).GetHelperType())); | ||
} | ||
|
||
[Fact] | ||
|
@@ -1598,7 +1615,8 @@ public void WeakReferenceOfNativeObjectRehydratedAfterWrapperIsCollected() | |
[Fact] | ||
public void TestUnwrapInspectable() | ||
{ | ||
var inspectable = IInspectable.FromAbi(TestObject.ThisPtr); | ||
using var objRef = MarshalInspectable.CreateMarshaler(TestObject); | ||
var inspectable = IInspectable.FromAbi(objRef.ThisPtr); | ||
Assert.True(ComWrappersSupport.TryUnwrapObject(inspectable, out _)); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ public enum TrustLevel | |
// IInspectable | ||
[ObjectReferenceWrapper(nameof(_obj))] | ||
[Guid("AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90")] | ||
public class IInspectable | ||
public partial class IInspectable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. partial only to combine with IInspectable.net5.cs? #if NET5_0 might be simpler There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that IInspectable implements an extra interface in .NET 5.0, we'd have to add quite a few |
||
{ | ||
[Guid("AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90")] | ||
public unsafe struct Vftbl | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
|
||
namespace WinRT | ||
{ | ||
public partial class IInspectable : IWinRTObject | ||
{ | ||
IObjectReference IWinRTObject.NativeObject => _obj; | ||
|
||
ConcurrentDictionary<RuntimeTypeHandle, IObjectReference> IWinRTObject.QueryInterfaceCache { get; } = new(); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the failing test? if so can you add a comment/TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not, but this test uses the ABI type directly which is not possible with IDIC anymore so I removed it from .net5