Skip to content
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

Fast abi consumption #998

Merged
merged 17 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Projections/Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
<ItemGroup>
<ProjectReference Include="..\..\Tests\TestComponentCSharp\TestComponentCSharp.vcxproj" />
<ProjectReference Include="..\..\TestWinRT\TestComponent\TestComponent.vcxproj" />
<ProjectReference Include="..\..\TestWinRT\test_component_base\test_component_base.vcxproj" />
<ProjectReference Include="..\..\TestWinRT\test_component_derived\test_component_derived.vcxproj" />
<ProjectReference Include="..\..\TestWinRT\test_component_base\test_component_base.vcxproj" />
<ProjectReference Include="..\..\TestWinRT\test_component_derived\test_component_derived.vcxproj" />
<ProjectReference Include="..\..\TestWinRT\test_component_fast\test_component_fast.vcxproj" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" />
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" />
Expand All @@ -19,8 +20,8 @@
</ItemGroup>

<PropertyGroup>
<CsWinRTIncludes>TestComponent;TestComponentCSharp;test_component_base;test_component_derived;</CsWinRTIncludes>
<CsWinRTExcludes>TestComponentCSharp.AnotherAssembly;</CsWinRTExcludes>
<CsWinRTIncludes>TestComponent;TestComponentCSharp;test_component_base;test_component_derived;test_component_fast;</CsWinRTIncludes>
<!--PkgMicrosoft_WinUI is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting-->
<PkgMicrosoft_WinUI Condition="'$(PkgMicrosoft_WinUI)'==''">$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.winui', '$(MicrosoftWinUIVersion)'))</PkgMicrosoft_WinUI>
</PropertyGroup>
Expand Down
42 changes: 21 additions & 21 deletions src/Tests/UnitTest/TestComponentCSharp_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
using Windows.Security.Cryptography.Core;
using System.Reflection;
using Windows.Devices.Enumeration.Pnp;

#if NET
using WeakRefNS = System;
#else
Expand All @@ -50,11 +50,11 @@ public class TestCSharp
public TestCSharp()
{
TestObject = new Class();
}
}


// Test a fix for a bug in Mono.Cecil that was affecting the IIDOptimizer when it encountered long class names
[Fact]
[Fact]
public void TestLongClassNameEventSource()
{
bool flag = false;
Expand Down Expand Up @@ -118,17 +118,17 @@ public void TestEnums()
TestObject.EnumsProperty = expectedEnums;
Assert.Equal(expectedEnums, TestObject.EnumsProperty);
TestObject.CallForEnums(() => expectedEnums);
Assert.Equal(expectedEnums, TestObject.EnumsProperty);
Assert.Equal(expectedEnums, TestObject.EnumsProperty);

TestObject.EnumsProperty = null;
Assert.Equal(null, TestObject.EnumsProperty);

var expectedEnumStructs = new EnumStruct[] { new EnumStruct(EnumValue.One), new EnumStruct(EnumValue.Two) };
TestObject.EnumStructsProperty = expectedEnumStructs;
Assert.Equal(expectedEnumStructs, TestObject.EnumStructsProperty);
TestObject.CallForEnumStructs(() => expectedEnumStructs);
Assert.Equal(expectedEnumStructs, TestObject.EnumStructsProperty);
Assert.Equal(expectedEnumStructs, TestObject.EnumStructsProperty);

TestObject.EnumStructsProperty = null;
Assert.Equal(null, TestObject.EnumStructsProperty);

Expand Down Expand Up @@ -750,10 +750,10 @@ public void TestCustomProjections()
Assert.Equal("name", propertyName);

bool eventCalled = false;
TestObject.CanExecuteChanged += (object sender, EventArgs e) =>
{
eventCalled = true;
};
TestObject.CanExecuteChanged += (object sender, EventArgs e) =>
{
eventCalled = true;
};

TestObject.RaiseCanExecuteChanged();
Assert.True(eventCalled);
Expand All @@ -767,8 +767,8 @@ public void TestCustomProjections()
// Ensure robustness with bad runtime class names (parsing errors, type not found, etc)
var badRuntimeClassName = Class.BadRuntimeClassName;
Assert.NotNull(badRuntimeClassName);
}

}
[Fact]
public void TestKeyValuePair()
{
Expand Down Expand Up @@ -1176,8 +1176,8 @@ public void TestComposedNonBlittableStruct()
Assert.True(val.bools.x);
Assert.False(val.bools.y);
Assert.True(val.bools.z);
}
}

[Fact]
public void TestBlittableArrays()
{
Expand Down Expand Up @@ -2453,8 +2453,8 @@ public void TestInterfaceObjectMarshalling()
TestObject.CopyProperties(nativeProperties);

Assert.Equal(TestObject.ReadWriteProperty, nativeProperties.ReadWriteProperty);
}
}

[Fact]
public void TestSetPropertyAcrossProjections()
{
Expand Down Expand Up @@ -2615,8 +2615,8 @@ public void TestEventSourceCaching()
GC.WaitForPendingFinalizers();
Assert.False(weakClassInstance.TryGetTarget(out _));
Assert.False(weakEventHandlerClass.TryGetTarget(out _));
}
}

class EventHandlerClass
{
private readonly Action eventCalled;
Expand All @@ -2627,7 +2627,7 @@ public EventHandlerClass(Action eventCalled)
}

public void IntPropertyChanged(object sender, int e) => eventCalled();
}
}

// Test scenario where events may be removed by the native event source without an unsubscribe.
[Fact]
Expand Down
43 changes: 43 additions & 0 deletions src/Tests/UnitTest/TestComponent_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -974,12 +974,55 @@ public void TestVectorGetMany()
Assert.True(composableObjects.GetRange(1, 3).SequenceEqual(interfaceSubset));
}

#if NET
[Fact]
public void Fast_Abi_Simple()
{
var simple = new test_component_fast.Simple();
Assert.Equal("Method1", simple.Method1());
Assert.Equal("Method2", simple.Method2());
Assert.Equal("Method3", simple.Method3());
Assert.Equal("Method4", simple.Method4());
Assert.Equal("Method5", simple.Method5());
Assert.Equal("Method6", simple.Method6());
Assert.Equal("Method7", simple.Method7());
Assert.Equal("Method8", simple.Method8());
Assert.Equal("Method9", simple.Method9());
simple.Property1 = "Property1";
simple.Property3 = "Property3";
Assert.Equal("Property1", simple.Property1);
Assert.Equal("Property2", simple.Property2);
Assert.Equal("Property3", simple.Property3);
var ev = "";
simple.Event0 += () =>
{
ev = "Hello";
};
simple.InvokeEvent0();
Assert.Equal("Hello", ev);
}

[Fact]
public void Fast_Abi_Composition()
{
var compositor = new test_component_fast.Composition.Compositor();
var sv = compositor.CreateSpriteVisual();
sv.Offset = 10;
sv.StartAnimationGroup();
Assert.Equal("", sv.Serialize(100));
Assert.Equal(10, sv.Offset);
Assert.Equal(10, sv.Pad);
sv.ObjectProperty = new List<int> { 1, 2, 3 };
Assert.Equal(3, ((List<int>)sv.ObjectProperty).Count);
}
#endif
// Nota Bene: this test case must always remain the final one
[Fact]
public void Z_Check_Coverage()
{
Tests.Simple();
//Assert.Equal((double)Tests.Percentage, (double)100);
}

}
}
5 changes: 3 additions & 2 deletions src/WinRT.Runtime/MatchingRefApiCompatBaseline.net5.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ TypesMustExist : Type 'WinRT.ComWrappersHelper' does not exist in the reference
MembersMustExist : Member 'public WinRT.ObjectReference<T> WinRT.ComWrappersSupport.GetObjectReferenceForInterface<T>(System.IntPtr)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.ComWrappersSupport.RegisterObjectForInterface(System.Object, System.IntPtr, System.Runtime.InteropServices.CreateObjectFlags)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'protected void WinRT.IObjectReference.AddRef(System.Boolean)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public WinRT.ObjectReference<WinRT.Interop.IUnknownVftbl> WinRT.IObjectReference.AsKnownPtr(System.IntPtr)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.Int32 WinRT.IObjectReference.TryAs(System.Guid, System.IntPtr)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public WinRT.IObjectReference WinRT.MarshalInspectable<T>.CreateMarshaler<V>(T, System.Guid, System.Boolean)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void WinRT.MarshalString..ctor(System.String)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public WinRT.MarshalString.Pinnable WinRT.MarshalString.CreatePinnable(System.String)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.IntPtr WinRT.MarshalString.GetAbi()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.IntPtr WinRT.MarshalString.GetAbi(WinRT.MarshalString.Pinnable)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public WinRT.IObjectReference WinRT.MarshalInspectable<T>.CreateMarshaler<V>(T, System.Guid, System.Boolean)' does not exist in the reference but it does exist in the implementation.
TypesMustExist : Type 'WinRT.MarshalString.Pinnable' does not exist in the reference but it does exist in the implementation.
TypesMustExist : Type 'WinRT.Interop.IWeakReference' does not exist in the reference but it does exist in the implementation.
TypesMustExist : Type 'WinRT.Interop.IWeakReferenceSource' does not exist in the reference but it does exist in the implementation.
Total Issues: 20
Total Issues: 21
Loading