Closed abenedik closed 7 years ago
Yeah, I guess what happened is that at some point the constructor new string((char*)
was not supported on one platform (Windows/WindowsPhone 8 certification that was really horrible to work with...) and when the code was removed to try to make things more uniform, the original behaviour was actually not preserved
I use AdapterDescription1.Description text to show the used Adapter.
When using SharpDX 2.6.3 this worked well. But in SharpDX 3.1 the Description text is 128 chars long and contains the actual adapter description followed with many zero characters.
The AdapterDescription1.Description text is initialized by using the:
The problem is that the Utilities.PtrToStringUni has changed. In the 2.6.3 version the method was implemented as:
The unsafe part of the code correctly ended the .Net string at first '\0' char. The description of the method shows that this is the desired functionality.
But in the latest version of SharpDX the source for the PtrToStringUni is simply:
As written in the MSDN description (https://msdn.microsoft.com/en-us/library/k4x4bfws(v=vs.110).aspx). the Marshal.PtrToStringUni just copies the specified number of unmanaged characters into managed string and does not check for the first zero char.
I think that this method should be reverted to its previous version.
Another option is to use Marshal.PtrToStringUni method without specifying the maxLenght - this will return the string when the first zero char is found (though this does not allow limiting the string to 128 chars) - see https://msdn.microsoft.com/en-us/library/dyf0tzy4(v=vs.110).aspx
A quick search reveals that the PtrToStringUni is used for Description that is defined in AdapterDescription, AdapterDescription1, AdapterDescription2 and in DeviceName defined in OutputDescription.