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

Update staging with latest #1361

Merged
merged 4 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<Target Name="CsWinRTGenerateProjection"
DependsOnTargets="CsWinRTPrepareProjection;CsWinRTRemoveWinMDReferences"
Condition="'$(CsWinRTGenerateProjection)' == 'true'"
Inputs="$(MSBuildAllProjects);@(CsWinRTInputs);$(CsWinRTExcludes);$(CsWinRTIncludes);$(CsWinRTExcludesPrivate);$(CsWinRTIncludesPrivate);$(CsWinRTFilters);$(CsWinRTWindowsMetadata)"
Inputs="$(MSBuildAllProjects);@(CsWinRTInputs);$(CsWinRTExe);$(CsWinRTExcludes);$(CsWinRTIncludes);$(CsWinRTExcludesPrivate);$(CsWinRTIncludesPrivate);$(CsWinRTFilters);$(CsWinRTWindowsMetadata)"
Outputs="$(CsWinRTGeneratedFilesDir)cswinrt.rsp">

<PropertyGroup>
Expand Down
43 changes: 43 additions & 0 deletions src/Tests/TestComponentCSharp/Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,49 @@ namespace winrt::TestComponentCSharp::implementation
return winrt::single_threaded_vector_view(std::vector<TestComponentCSharp::Class>{ *this, *this, *this });
}

IMap<int32_t, int32_t> Class::GetIntToIntDictionary()
{
return single_threaded_map<int32_t, int32_t>(std::map<int32_t, int32_t>{ {1, 4}, { 2, 8 }, { 3, 12 } });
}

IMap<hstring, TestComponentCSharp::ComposedBlittableStruct> Class::GetStringToBlittableDictionary()
{
return single_threaded_map<hstring, TestComponentCSharp::ComposedBlittableStruct>(std::map<hstring, TestComponentCSharp::ComposedBlittableStruct>
{
{ L"alpha", ComposedBlittableStruct{ 5 } },
{ L"beta", ComposedBlittableStruct{ 4 } },
{ L"charlie", ComposedBlittableStruct{ 7 } }
});
}

IMap<hstring, TestComponentCSharp::ComposedNonBlittableStruct> Class::GetStringToNonBlittableDictionary()
{
return single_threaded_map<hstring, TestComponentCSharp::ComposedNonBlittableStruct>(std::map<hstring, TestComponentCSharp::ComposedNonBlittableStruct>
{
{ L"String0", ComposedNonBlittableStruct{ { 0 }, { L"String0" }, { true, false, true, false }, { 0 } } },
{ L"String1", ComposedNonBlittableStruct{ { 1 }, { L"String1" }, { false, true, false, true }, { 1 } } },
{ L"String2", ComposedNonBlittableStruct{ { 2 }, { L"String2" }, { true, false, true, false }, { 2 } } }
});
}

struct ComposedBlittableStructComparer
{
bool operator() (const TestComponentCSharp::ComposedBlittableStruct& l, const TestComponentCSharp::ComposedBlittableStruct& r) const
{
return (l.blittable.i32 < r.blittable.i32);
}
};

IMap<TestComponentCSharp::ComposedBlittableStruct, WF::IInspectable> Class::GetBlittableToObjectDictionary()
{
return single_threaded_map<TestComponentCSharp::ComposedBlittableStruct, WF::IInspectable>(std::map<TestComponentCSharp::ComposedBlittableStruct, WF::IInspectable, ComposedBlittableStructComparer>
{
{ ComposedBlittableStruct{ 1 }, winrt::box_value(0) },
{ ComposedBlittableStruct{ 4 }, winrt::box_value(L"box") },
{ ComposedBlittableStruct{ 8 }, *this }
});
}

// Test IIDOptimizer
IVectorView<Microsoft::UI::Xaml::Data::DataErrorsChangedEventArgs> Class::GetEventArgsVector()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Tests/TestComponentCSharp/Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ namespace winrt::TestComponentCSharp::implementation
Windows::Foundation::Collections::IVectorView<Windows::Foundation::IInspectable> GetObjectVector();
Windows::Foundation::Collections::IVectorView<TestComponentCSharp::IProperties1> GetInterfaceVector();
Windows::Foundation::Collections::IVectorView<TestComponentCSharp::Class> GetClassVector() noexcept;

Windows::Foundation::Collections::IMap<int32_t, int32_t> GetIntToIntDictionary();
Windows::Foundation::Collections::IMap<hstring, TestComponentCSharp::ComposedBlittableStruct> GetStringToBlittableDictionary();
Windows::Foundation::Collections::IMap<hstring, TestComponentCSharp::ComposedNonBlittableStruct> GetStringToNonBlittableDictionary();
Windows::Foundation::Collections::IMap<TestComponentCSharp::ComposedBlittableStruct, Windows::Foundation::IInspectable> GetBlittableToObjectDictionary();

// Test IIDOptimizer -- testing the windows projection covers most code paths, and these two types exercise the rest.
Windows::Foundation::Collections::IVectorView<Microsoft::UI::Xaml::Data::DataErrorsChangedEventArgs> GetEventArgsVector();
Expand Down
5 changes: 5 additions & 0 deletions src/Tests/TestComponentCSharp/TestComponentCSharp.idl
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ namespace TestComponentCSharp
Windows.Foundation.Collections.IVectorView<IProperties1> GetInterfaceVector();
[noexcept] Windows.Foundation.Collections.IVectorView<Class> GetClassVector();

Windows.Foundation.Collections.IMap<Int32, Int32> GetIntToIntDictionary();
Windows.Foundation.Collections.IMap<String, ComposedBlittableStruct> GetStringToBlittableDictionary();
Windows.Foundation.Collections.IMap<String, ComposedNonBlittableStruct> GetStringToNonBlittableDictionary();
Windows.Foundation.Collections.IMap<ComposedBlittableStruct, Object> GetBlittableToObjectDictionary();

// Test IIDOptimizer
Windows.Foundation.Collections.IVectorView<Microsoft.UI.Xaml.Data.DataErrorsChangedEventArgs> GetEventArgsVector();
Windows.Foundation.Collections.IVectorView<ProvideUri> GetNonGenericDelegateVector();
Expand Down
26 changes: 26 additions & 0 deletions src/Tests/UnitTest/TestComponentCSharp_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3068,5 +3068,31 @@ public void TestWeakReferenceEventsFromMultipleContexts()
staThread.Start();
staThread.Join();
}

[Fact]
public void TestDictionary()
{
var intToIntDict = TestObject.GetIntToIntDictionary();
Assert.Equal(8, intToIntDict[2]);
Assert.Equal(8, intToIntDict[2]);
Assert.Equal(12, intToIntDict[3]);

var stringToBlittableDict = TestObject.GetStringToBlittableDictionary();
Assert.Equal(5, stringToBlittableDict["alpha"].blittable.i32);
Assert.Equal(7, stringToBlittableDict["charlie"].blittable.i32);
Assert.Equal(5, stringToBlittableDict["alpha"].blittable.i32);

var stringToNonBlittableDict = TestObject.GetStringToNonBlittableDictionary();
Assert.Equal(1, stringToNonBlittableDict["String1"].blittable.i32);
Assert.Equal("String1", stringToNonBlittableDict["String1"].strings.str);
Assert.False(stringToNonBlittableDict["String1"].bools.w);
Assert.True(stringToNonBlittableDict["String1"].bools.x);

var blittableToObjectDict = TestObject.GetBlittableToObjectDictionary();
ComposedBlittableStruct key;
key.blittable.i32 = 4;
Assert.Equal("box", (string)blittableToObjectDict[key]);
Assert.Equal("box", (string)blittableToObjectDict[key]);
}
}
}
13 changes: 0 additions & 13 deletions src/WinRT.Runtime/ApiCompatBaseline.net5.0.txt

This file was deleted.

Loading
Loading