I'm writing a custom C++/WinRT component which will be consumed from a C# application. Inside this component I have objects that I need to expose to the caller application and these objects have properties, in this case an Id and a Position. The Id is an integer type, and the Position is float3.
Here are the contents of the .idl and the header file: .idl:
runtimeclass MyObject
{
MyObject();
Int32 Id();
Windows::Foundation::Numerics::float3 Position();
}
.h:
#pragma once
#include "MyObject.g.h"
namespace winrt::TestComponent::implementation
{
struct MyObject : MyObjectT<MyObject>
{
MyObject();
int32_t Id();
Windows::Foundation::Numerics::float3 Position();
private:
int _id;
Windows::Foundation::Numerics::float3 _position;
};
}
namespace winrt::TestComponent::factory_implementation
{
struct MyObject : MyObjectrT<MyObject, implementation::MyObject>
{
};
}
It looks like that Windows::Foundation::Numerics::float3
is not supported inside .idl files, when I try to build the project the process fails with [msg]syntax error [context]: expecting an identifier near ":"
error at the line where the Position() is declared inside the .idl. What would be the best way to use expose float3 property of a runtime class using C++/WinRT?