Issue with TurboActivate extra data on MacOSAnswered

Hello.

I have encountered a problem with TurboActivate dylib for MacOS.
I am already using TurboActivate on Windows, and it works fine, but on Mac it behaves unexpectedly: extra data that I pass to the Activate() method does not get fully saved to the machine or the cloud, only the 1st character does. I use TA_USER flag.


Have anybody seen this kind of behavior?

Hey Evgeniy,

We got your email about this, but we haven't had time to reproduce it on a macOS system. After Microsoft dropped support for Visual Studio on macOS, we haven't yet set up Visual Studio Code with all the necessary dependencies so we can test this.

In short everything with extra data work fine in “native languages” (like C/C++/etc.) on macOS.

It's something in the C# layer that's messing things up on macOS. We'll investigate and get back to you when we've figured it out.

Just guessing based on how Microsoft does unicode (UTF-16 🤮) and how the rest of the sane-world does unicode (UTF-8), Microsoft's .NET is passing your string as UTF-16 despite the PINVOKE specifically saying *not* to do that (pass as raw characters).

Of course we have to confirm this and then figure out how to work around Microsoft's many bugs in an unobtrusive way.

Thank you for the reply, we will be waiting for the resolution of the issue.

Answer

We had the same issue activating with C# Avalonia on macOS. 

Changing the ACTIVATE_OPTIONS struct solved this. See below:

[StructLayout(LayoutKind.Sequential)]
public struct ACTIVATE_OPTIONS
{
   public UInt32 nLength;
   [MarshalAs(UnmanagedType.LPUTF8Str)]
   public string sExtraData;
}
, edited

Good catch Tim! The next version (released soon) will have the modified ACTIVATE_OPTIONS code:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ACTIVATE_OPTIONS
{
    public UInt32 nLength;

	#if (MACOS || UNIX)
    [MarshalAs(UnmanagedType.LPUTF8Str)]
	#else
    [MarshalAs(UnmanagedType.LPWStr)]
	#endif
    public string sExtraData;
}