Skip to content

Commit

Permalink
Merge branch 'staging/AOT' into manodasanw/streams
Browse files Browse the repository at this point in the history
  • Loading branch information
manodasanW authored Jul 1, 2024
2 parents ed90dfc + c0ea513 commit 4870a1f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Tests/FunctionalTests/Collections/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using test_component_derived.Nested;
Expand Down Expand Up @@ -69,6 +70,12 @@
return 101;
}

var types = Class.ListOfTypes;
if (types.Count != 2 || types[0] != typeof(Class))
{
return 101;
}

var cancellationDictionary = new Dictionary<string, CancellationTokenSource>();
instance.BindableIterableProperty = cancellationDictionary;
if (cancellationDictionary != instance.BindableIterableProperty)
Expand Down
15 changes: 15 additions & 0 deletions src/Tests/TestComponentCSharp/Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,11 @@ namespace winrt::TestComponentCSharp::implementation
return winrt::unbox_value<TestComponentCSharp::ProvideInt>(obj);
}

Windows::UI::Xaml::Interop::TypeName Class::UnboxType(WF::IInspectable const& obj)
{
return winrt::unbox_value<Windows::UI::Xaml::Interop::TypeName>(obj);
}

com_array<int32_t> Class::UnboxInt32Array(WF::IInspectable const& obj)
{
return obj.as<IReferenceArray<int32_t>>().Value();
Expand Down Expand Up @@ -1633,6 +1638,16 @@ namespace winrt::TestComponentCSharp::implementation
return winrt::xaml_typename<winrt::TestComponentCSharp::Class>();
}

WF::IInspectable Class::BoxedType()
{
return winrt::box_value(winrt::xaml_typename<winrt::TestComponentCSharp::Class>());
}

IVector<Windows::UI::Xaml::Interop::TypeName> Class::ListOfTypes()
{
return single_threaded_vector<Windows::UI::Xaml::Interop::TypeName>({ winrt::xaml_typename<winrt::TestComponentCSharp::Class>(), winrt::xaml_typename<IReference<int32_t>>() });
}

bool Class::VerifyTypeIsInt32Type(TypeName const& type_name)
{
return winrt::xaml_typename<int32_t>() == type_name;
Expand Down
4 changes: 4 additions & 0 deletions src/Tests/TestComponentCSharp/Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ namespace winrt::TestComponentCSharp::implementation
static hstring UnboxString(IInspectable const& obj);
static EnumValue UnboxEnum(IInspectable const& obj);
static TestComponentCSharp::ProvideInt UnboxDelegate(IInspectable const& obj);
static Windows::UI::Xaml::Interop::TypeName UnboxType(IInspectable const& obj);
static com_array<int32_t> UnboxInt32Array(IInspectable const& obj);
static com_array<bool> UnboxBooleanArray(IInspectable const& obj);
static com_array<hstring> UnboxStringArray(IInspectable const& obj);
Expand All @@ -384,6 +385,9 @@ namespace winrt::TestComponentCSharp::implementation
static Windows::UI::Xaml::Interop::TypeName Int32Type();
static Windows::UI::Xaml::Interop::TypeName ReferenceInt32Type();
static Windows::UI::Xaml::Interop::TypeName ThisClassType();
static Windows::Foundation::IInspectable BoxedType();
static Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Interop::TypeName> ListOfTypes();

static bool VerifyTypeIsInt32Type(Windows::UI::Xaml::Interop::TypeName const& type_name);
static bool VerifyTypeIsReferenceInt32Type(Windows::UI::Xaml::Interop::TypeName const& type_name);
static bool VerifyTypeIsThisClassType(Windows::UI::Xaml::Interop::TypeName const& type_name);
Expand Down
3 changes: 3 additions & 0 deletions src/Tests/TestComponentCSharp/TestComponentCSharp.idl
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ namespace TestComponentCSharp
static String UnboxString(Object obj);
static ProvideInt UnboxDelegate(Object obj);
static EnumValue UnboxEnum(Object obj);
static Windows.UI.Xaml.Interop.TypeName UnboxType(Object obj);
static Int32[] UnboxInt32Array(Object obj);
static Boolean[] UnboxBooleanArray(Object obj);
static String[] UnboxStringArray(Object obj);
Expand All @@ -420,6 +421,8 @@ namespace TestComponentCSharp
static Windows.UI.Xaml.Interop.TypeName Int32Type { get; };
static Windows.UI.Xaml.Interop.TypeName ThisClassType { get; };
static Windows.UI.Xaml.Interop.TypeName ReferenceInt32Type { get; };
static Object BoxedType{ get; };
static Windows.Foundation.Collections.IVector<Windows.UI.Xaml.Interop.TypeName> ListOfTypes{ get; };

static Boolean VerifyTypeIsInt32Type(Windows.UI.Xaml.Interop.TypeName type);
static Boolean VerifyTypeIsThisClassType(Windows.UI.Xaml.Interop.TypeName type);
Expand Down
14 changes: 14 additions & 0 deletions src/Tests/UnitTest/TestComponentCSharp_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2574,6 +2574,11 @@ public void TestValueBoxing()

EnumValue enumValue = EnumValue.Two;
Assert.Equal(enumValue, Class.UnboxEnum(enumValue));

var type = typeof(EnumValue);
Assert.Equal(type, Class.UnboxType(type));

Assert.Equal(typeof(Class), Class.BoxedType);
}

[Fact]
Expand All @@ -2599,6 +2604,15 @@ public void TestArrayUnboxing()
Assert.Equal(i, (IEnumerable<int>)obj);
}

[Fact]
public void TestListOfTypes()
{
var types = Class.ListOfTypes;
Assert.Equal(2, types.Count);
Assert.Equal(typeof(Class), types[0]);
Assert.Equal(typeof(int?), types[1]);
}

[Fact]
public void PrimitiveTypeInfo()
{
Expand Down
5 changes: 5 additions & 0 deletions src/WinRT.Runtime/GuidGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public static string GetSignature(
return "string";
}

if (type == typeof(Type))
{
return ABI.System.Type.GetGuidSignature();
}

if (type.IsGenericType)
{
#if NET
Expand Down
2 changes: 2 additions & 0 deletions src/WinRT.Runtime/Projections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ static Projections()
RegisterCustomAbiTypeMappingNoLock(typeof(char), typeof(ABI.System.Char), "Char");

// Also always register Type, since it's "free" (no associated ABI type to root)
// given Type is special-cased in all relevant areas including Marshaler<T>.
CustomTypeToAbiTypeNameMappings.Add(typeof(Type), "Windows.UI.Xaml.Interop.TypeName");
CustomAbiTypeNameToTypeMappings.Add("Windows.UI.Xaml.Interop.TypeName", typeof(Type));

#if NET
// If default mappings are disabled, we avoid rooting everything by default.
Expand Down

0 comments on commit 4870a1f

Please sign in to comment.