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

type mappings for xaml structs #141

Merged
merged 3 commits into from
Apr 15, 2020
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
73 changes: 73 additions & 0 deletions TestComponentCSharp/Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,79 @@ namespace winrt::TestComponentCSharp::implementation
_color = value;
}

Windows::UI::Xaml::CornerRadius Class::CornerRadiusProperty()
{
return _cornerRadius;
}
void Class::CornerRadiusProperty(Windows::UI::Xaml::CornerRadius const& value)
{
_cornerRadius = value;
}
Windows::UI::Xaml::Duration Class::DurationProperty()
{
return _duration;
}
void Class::DurationProperty(Windows::UI::Xaml::Duration const& value)
{
_duration = value;
}
Windows::UI::Xaml::GridLength Class::GridLengthProperty()
{
return _gridLength;
}
void Class::GridLengthProperty(Windows::UI::Xaml::GridLength const& value)
{
_gridLength = value;
}
Windows::UI::Xaml::Thickness Class::ThicknessProperty()
{
return _thickness;
}
void Class::ThicknessProperty(Windows::UI::Xaml::Thickness const& value)
{
_thickness = value;
}
Windows::UI::Xaml::Controls::Primitives::GeneratorPosition Class::GeneratorPositionProperty()
{
return _generatorPosition;
}
void Class::GeneratorPositionProperty(Windows::UI::Xaml::Controls::Primitives::GeneratorPosition const& value)
{
_generatorPosition = value;
}
Windows::UI::Xaml::Media::Matrix Class::MatrixProperty()
{
return _matrix;
}
void Class::MatrixProperty(Windows::UI::Xaml::Media::Matrix const& value)
{
_matrix = value;
}
Windows::UI::Xaml::Media::Animation::KeyTime Class::KeyTimeProperty()
{
return _keyTime;
}
void Class::KeyTimeProperty(Windows::UI::Xaml::Media::Animation::KeyTime const& value)
{
_keyTime = value;
}
Windows::UI::Xaml::Media::Animation::RepeatBehavior Class::RepeatBehaviorProperty()
{
return _repeatBehavior;
}
void Class::RepeatBehaviorProperty(Windows::UI::Xaml::Media::Animation::RepeatBehavior const& value)
{
_repeatBehavior = value;
}
Windows::UI::Xaml::Media::Media3D::Matrix3D Class::Matrix3DProperty()
{
return _matrix3D;
}
void Class::Matrix3DProperty(Windows::UI::Xaml::Media::Media3D::Matrix3D const& value)
{
_matrix3D = value;
}

IReference<Point> Class::GetPointReference()
{
return _point;
Expand Down
27 changes: 27 additions & 0 deletions TestComponentCSharp/Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ namespace winrt::TestComponentCSharp::implementation
Windows::Foundation::Rect _rect{};
Windows::Foundation::Size _size{};
Windows::UI::Color _color{};
Windows::UI::Xaml::CornerRadius _cornerRadius{};
Windows::UI::Xaml::Duration _duration{};
Windows::UI::Xaml::GridLength _gridLength{};
Windows::UI::Xaml::Thickness _thickness{};
Windows::UI::Xaml::Controls::Primitives::GeneratorPosition _generatorPosition{};
Windows::UI::Xaml::Media::Matrix _matrix{};
Windows::UI::Xaml::Media::Animation::KeyTime _keyTime{};
Windows::UI::Xaml::Media::Animation::RepeatBehavior _repeatBehavior{};
Windows::UI::Xaml::Media::Media3D::Matrix3D _matrix3D{};
Windows::Foundation::TimeSpan _timeSpan{};
Windows::Foundation::DateTime _dateTime{};
winrt::hresult _hr;
Expand Down Expand Up @@ -211,6 +220,24 @@ namespace winrt::TestComponentCSharp::implementation
void SizeProperty(Windows::Foundation::Size const& value);
Windows::UI::Color ColorProperty();
void ColorProperty(Windows::UI::Color const& value);
Windows::UI::Xaml::CornerRadius CornerRadiusProperty();
void CornerRadiusProperty(Windows::UI::Xaml::CornerRadius const& value);
Windows::UI::Xaml::Duration DurationProperty();
void DurationProperty(Windows::UI::Xaml::Duration const& value);
Windows::UI::Xaml::GridLength GridLengthProperty();
void GridLengthProperty(Windows::UI::Xaml::GridLength const& value);
Windows::UI::Xaml::Thickness ThicknessProperty();
void ThicknessProperty(Windows::UI::Xaml::Thickness const& value);
Windows::UI::Xaml::Controls::Primitives::GeneratorPosition GeneratorPositionProperty();
void GeneratorPositionProperty(Windows::UI::Xaml::Controls::Primitives::GeneratorPosition const& value);
Windows::UI::Xaml::Media::Matrix MatrixProperty();
void MatrixProperty(Windows::UI::Xaml::Media::Matrix const& value);
Windows::UI::Xaml::Media::Animation::KeyTime KeyTimeProperty();
void KeyTimeProperty(Windows::UI::Xaml::Media::Animation::KeyTime const& value);
Windows::UI::Xaml::Media::Animation::RepeatBehavior RepeatBehaviorProperty();
void RepeatBehaviorProperty(Windows::UI::Xaml::Media::Animation::RepeatBehavior const& value);
Windows::UI::Xaml::Media::Media3D::Matrix3D Matrix3DProperty();
void Matrix3DProperty(Windows::UI::Xaml::Media::Media3D::Matrix3D const& value);
Windows::Foundation::IReference<Windows::Foundation::Point> GetPointReference();
Windows::Foundation::TimeSpan TimeSpanProperty();
void TimeSpanProperty(Windows::Foundation::TimeSpan const& value);
Expand Down
11 changes: 10 additions & 1 deletion TestComponentCSharp/TestComponentCSharp.idl
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,19 @@ namespace TestComponentCSharp
// Type mappings
// "Simple" structs (blittable with changes to add properties/functions/constructors/etc.)
Windows.Foundation.Point PointProperty;
Windows.Foundation.IReference<Windows.Foundation.Point> GetPointReference();
Windows.Foundation.Rect RectProperty;
Windows.Foundation.Size SizeProperty;
Windows.UI.Color ColorProperty;
Windows.Foundation.IReference<Windows.Foundation.Point> GetPointReference();
Windows.UI.Xaml.CornerRadius CornerRadiusProperty;
Windows.UI.Xaml.Duration DurationProperty;
Windows.UI.Xaml.GridLength GridLengthProperty;
Windows.UI.Xaml.Thickness ThicknessProperty;
Windows.UI.Xaml.Controls.Primitives.GeneratorPosition GeneratorPositionProperty;
Windows.UI.Xaml.Media.Matrix MatrixProperty;
Windows.UI.Xaml.Media.Animation.KeyTime KeyTimeProperty;
Windows.UI.Xaml.Media.Animation.RepeatBehavior RepeatBehaviorProperty;
Windows.UI.Xaml.Media.Media3D.Matrix3D Matrix3DProperty;
// Structs mapped to equivalent ones in the System namespace
Windows.Foundation.TimeSpan TimeSpanProperty;
Windows.Foundation.IReference<Windows.Foundation.TimeSpan> GetTimeSpanReference();
Expand Down
22 changes: 18 additions & 4 deletions UnitTest/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,26 @@
-in 10.0.18362.0
-in @(UnitTestWinMDs->'&quot;%(FullPath)&quot;', ' ')
-out &quot;$(ProjectDir)Generated Files&quot;
-include TestComponentCSharp
-include TestComponent
-include TestComponentCSharp
-include Windows.Foundation
-include Windows.Foundation
-include Windows.UI.Color
-include Windows.UI.IColor
-exclude Windows.Foundation.Diagnostics
-exclude Windows.UI.Colors
-include Windows.UI.Xaml.CornerRadius
-include Windows.UI.Xaml.Duration
-include Windows.UI.Xaml.DurationType
-include Windows.UI.Xaml.GridLength
-include Windows.UI.Xaml.GridUnitType
-include Windows.UI.Xaml.Thickness
-include Windows.UI.Xaml.Controls.Primitives.GeneratorPosition
-include Windows.UI.Xaml.Media.Matrix
-exclude Windows.UI.Xaml.Media.MatrixTransform
-exclude Windows.UI.Xaml.Media.Matrix3DProjection
-include Windows.UI.Xaml.Media.Animation.KeyTime
-include Windows.UI.Xaml.Media.Animation.RepeatBehavior
-include Windows.UI.Xaml.Media.Animation.RepeatBehaviorType
-include Windows.UI.Xaml.Media.Media3D.Matrix3D
-exclude Windows.Foundation.Diagnostics
</CsWinRTParams>
</PropertyGroup>
<WriteLinesToFile
Expand Down
125 changes: 122 additions & 3 deletions UnitTest/TestComponentCSharp_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
using Xunit;
using WinRT;

using WF = Windows.Foundation;
using WFC = Windows.Foundation.Collections;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Interop;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Media.Media3D;

using TestComponentCSharp;
using System.Collections.Generic;
using Windows.UI.Xaml.Interop;
using System.Collections;

namespace UnitTest
Expand Down Expand Up @@ -1057,6 +1060,122 @@ public void TestColorTypeMapping()
Assert.True(TestObject.ColorProperty == color);
}

[Fact]
public void TestCornerRadiusTypeMapping()
{
var cornerRadius = new CornerRadius { TopLeft = 1, TopRight = 2, BottomRight = 3, BottomLeft = 4 };
TestObject.CornerRadiusProperty = cornerRadius;
Assert.Equal(cornerRadius.TopLeft, TestObject.CornerRadiusProperty.TopLeft);
Assert.Equal(cornerRadius.TopRight, TestObject.CornerRadiusProperty.TopRight);
Assert.Equal(cornerRadius.BottomRight, TestObject.CornerRadiusProperty.BottomRight);
Assert.Equal(cornerRadius.BottomLeft, TestObject.CornerRadiusProperty.BottomLeft);
Assert.True(TestObject.CornerRadiusProperty == cornerRadius);
}

[Fact]
public void TestDurationTypeMapping()
{
var duration = new Duration(TimeSpan.FromTicks(42));
TestObject.DurationProperty = duration;
Assert.Equal(duration.TimeSpan, TestObject.DurationProperty.TimeSpan);
Assert.True(TestObject.DurationProperty == duration);
}

[Fact]
public void TestGridLengthTypeMapping()
{
var gridLength = new GridLength( 42, GridUnitType.Pixel );
TestObject.GridLengthProperty = gridLength;
Assert.Equal(gridLength.GridUnitType, TestObject.GridLengthProperty.GridUnitType);
Assert.Equal(gridLength.Value, TestObject.GridLengthProperty.Value);
Assert.True(TestObject.GridLengthProperty == gridLength);
}

[Fact]
public void TestThicknessTypeMapping()
{
var thickness = new Thickness { Left = 1, Top = 2, Right = 3, Bottom = 4 };
TestObject.ThicknessProperty = thickness;
Assert.Equal(thickness.Left, TestObject.ThicknessProperty.Left);
Assert.Equal(thickness.Top, TestObject.ThicknessProperty.Top);
Assert.Equal(thickness.Right, TestObject.ThicknessProperty.Right);
Assert.Equal(thickness.Bottom, TestObject.ThicknessProperty.Bottom);
Assert.True(TestObject.ThicknessProperty == thickness);
}

[Fact]
public void TestGeneratorPositionTypeMapping()
{
var generatorPosition = new GeneratorPosition { Index = 1, Offset = 2 };
TestObject.GeneratorPositionProperty = generatorPosition;
Assert.Equal(generatorPosition.Index, TestObject.GeneratorPositionProperty.Index);
Assert.Equal(generatorPosition.Offset, TestObject.GeneratorPositionProperty.Offset);
Assert.True(TestObject.GeneratorPositionProperty == generatorPosition);
}

[Fact]
public void TestMatrixTypeMapping()
{
var matrix = new Matrix { M11 = 11, M12 = 12, M21 = 21, M22 = 22, OffsetX = 3, OffsetY = 4 };
TestObject.MatrixProperty = matrix;
Assert.Equal(matrix.M11, TestObject.MatrixProperty.M11);
Assert.Equal(matrix.M12, TestObject.MatrixProperty.M12);
Assert.Equal(matrix.M21, TestObject.MatrixProperty.M21);
Assert.Equal(matrix.M22, TestObject.MatrixProperty.M22);
Assert.Equal(matrix.OffsetX, TestObject.MatrixProperty.OffsetX);
Assert.Equal(matrix.OffsetY, TestObject.MatrixProperty.OffsetY);
Assert.True(TestObject.MatrixProperty == matrix);
}

[Fact]
public void TestKeyTimeTypeMapping()
{
var keyTime = KeyTime.FromTimeSpan(TimeSpan.FromTicks(42));
TestObject.KeyTimeProperty = keyTime;
Assert.Equal(keyTime.TimeSpan, TestObject.KeyTimeProperty.TimeSpan);
Assert.True(TestObject.KeyTimeProperty == keyTime);
}

[Fact]
public void TestRepeatBehaviorTypeMapping()
{
var repeatBehavior = new RepeatBehavior {
Count = 1, Duration = TimeSpan.FromTicks(42), Type = RepeatBehaviorType.Forever };
TestObject.RepeatBehaviorProperty = repeatBehavior;
Assert.Equal(repeatBehavior.Count, TestObject.RepeatBehaviorProperty.Count);
Assert.Equal(repeatBehavior.Duration, TestObject.RepeatBehaviorProperty.Duration);
Assert.Equal(repeatBehavior.Type, TestObject.RepeatBehaviorProperty.Type);
Assert.True(TestObject.RepeatBehaviorProperty == repeatBehavior);
}

[Fact]
public void TestMatrix3DTypeMapping()
{
var matrix3D = new Matrix3D {
M11 = 11, M12 = 12, M13 = 13, M14 = 14,
M21 = 21, M22 = 22, M23 = 23, M24 = 24,
M31 = 31, M32 = 32, M33 = 33, M34 = 34,
OffsetX = 41, OffsetY = 42, OffsetZ = 43,M44 = 44 };
TestObject.Matrix3DProperty = matrix3D;
Assert.Equal(matrix3D.M11, TestObject.Matrix3DProperty.M11);
Assert.Equal(matrix3D.M12, TestObject.Matrix3DProperty.M12);
Assert.Equal(matrix3D.M13, TestObject.Matrix3DProperty.M13);
Assert.Equal(matrix3D.M14, TestObject.Matrix3DProperty.M14);
Assert.Equal(matrix3D.M21, TestObject.Matrix3DProperty.M21);
Assert.Equal(matrix3D.M22, TestObject.Matrix3DProperty.M22);
Assert.Equal(matrix3D.M23, TestObject.Matrix3DProperty.M23);
Assert.Equal(matrix3D.M24, TestObject.Matrix3DProperty.M24);
Assert.Equal(matrix3D.M31, TestObject.Matrix3DProperty.M31);
Assert.Equal(matrix3D.M32, TestObject.Matrix3DProperty.M32);
Assert.Equal(matrix3D.M33, TestObject.Matrix3DProperty.M33);
Assert.Equal(matrix3D.M34, TestObject.Matrix3DProperty.M34);
Assert.Equal(matrix3D.OffsetX, TestObject.Matrix3DProperty.OffsetX);
Assert.Equal(matrix3D.OffsetY, TestObject.Matrix3DProperty.OffsetY);
Assert.Equal(matrix3D.OffsetZ, TestObject.Matrix3DProperty.OffsetZ);
Assert.Equal(matrix3D.M44, TestObject.Matrix3DProperty.M44);
Assert.True(TestObject.Matrix3DProperty == matrix3D);
}

[Fact]
public void TestTimeSpanMapping()
{
Expand Down
3 changes: 0 additions & 3 deletions WinUI/WinUIProjection/WinUIProjection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute
-include Windows.UI.Xaml.Media.Animation.IndependentlyAnimatableAttribute
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute
# Because we pull in Windows.UI.Xaml attributes, the Duration addition is included,
# which in turn requires the DurationType projection
-include Windows.UI.Xaml.DurationType
</CsWinRTParams>
</PropertyGroup>
<MakeDir Directories="$(ProjectDir)Generated Files"/>
Expand Down
5 changes: 5 additions & 0 deletions cswinrt/cswinrt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@
<None Include="strings\additions\Windows.Storage\IStorageItemHandleAccess.cs" />
<None Include="strings\additions\Windows.Storage\Windows.Storage.SR.cs" />
<None Include="strings\additions\Windows.Storage\WindowsRuntimeStorageExtensions.cs" />
<None Include="strings\additions\Windows.UI.Xaml.Controls.Primitives\Windows.UI.Xaml.Controls.Primitives.cs" />
<None Include="strings\additions\Windows.UI.Xaml.Media.Animation\Windows.UI.Xaml.Media.Animation.cs" />
<None Include="strings\additions\Windows.UI.Xaml.Media.Media3D\Windows.UI.Xaml.Media.Media3D.cs" />
<None Include="strings\additions\Windows.UI.Xaml.Media\Windows.UI.Xaml.Media.cs" />
<None Include="strings\additions\Windows.UI.Xaml\Windows.UI.Xaml.cs" />
<None Include="strings\additions\Windows.UI.Xaml\Windows.UI.Xaml.SR.cs" />
<None Include="strings\additions\Windows.UI\Windows.UI.cs" />
<None Include="strings\WinRT.cs" />
<None Include="strings\WinRT_Interop.cs" />
Expand Down
Loading