microsoft / CsWinRT

C# language projection for the Windows Runtime
MIT License
540 stars 102 forks source link

Authored component doesn't have expected System.DateTime to Foundation.DateTime type mapping #1231

Open Psychlist1972 opened 2 years ago

Psychlist1972 commented 2 years ago

I authored a component in C#/WinRT. It has a class which exposes a .NET DateTime property.

When I went to consume that component from C++/WinRT, it didn't work. C++ complained that it couldn't find the System.DateTime type.

My expectation was that DateTime would be mapped to a Windows::Foundation::DateTime and therefore usable from C++/WinRT.

AdamBraden commented 2 years ago

authoring bug?

manodasanW commented 2 years ago

We do have a diagnostics issue here where if System.DateTime is used, we should say it isn't a valid WinRT type. @Psychlist1972 instead of System.DateTime, can you use System.DateTimeOffset? System.DateTimeOffset is the .NET type which gets mapped to the WinRT type Windows.Foundation.DateTime.