WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

FrameworkUDK's NotificationProperties::get_Payload should return a wstring

Open loneursid opened this issue 4 years ago • 0 comments

Describe the bug

In the FrameworkUDK, NotificationProperties' ctor takes a PCWSTR and internally converts it to utf8 but, the corresponding get_Payload() operation returns a utf8 string. This means that NotificationProperties is responsible for encoding the payload while the caller is responsible for decoding it. This not only breaks the symmetry developers are usually expecting from this king of API, it means the code responsible for the encoding is located in an entirely different part of the system (in this case in different DLLs and different repos), this is a recipe for disaster as there is a risk for the encoding and decoding functions to diverge.

Consider fixing get_Payload(), so it returns a wide string, if get_Payload() can't be changed, consider adding an overload that would return a wstring.

Then remove the decoding function from WindowsAppSDK.

Steps to reproduce the bug

This decoding function wil::unique_cotaskmem_string Microsoft::Windows::AppNotifications::Helpers::ConvertUtf8StringToWideString(unsigned long length, const byte* utf8String), should be in the UDK, next to the encoding one.

Expected behavior

No response

Screenshots

No response

NuGet package version

No response

Packaging type

No response

Windows version

No response

IDE

No response

Additional context

No response

loneursid avatar Mar 04 '22 14:03 loneursid