The bug has already been mentioned, but it is not fixed at the current
version located in the SVN.
File: MetadataWriter.cs
Location: method 'AddUserString'
Changes:
// !!GetBytes change!!
// byte [] us = Encoding.Unicode.GetBytes (str);
byte[] us = GetBytes(str);
private static byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * 2];
char[] chars = str.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
char value = chars[i];
byte highPart = (byte)(value >> 8);
byte lowPart = (byte)(value & 0xFF);
bytes[2 * i] = lowPart;
bytes[2 * i + 1] = highPart;
}
return bytes;
}
P.S.
The code is not well-optimized, but i think that the idea is clear
( the same idea as in mistake in file UserStringHeap.cs - mistake in
reading strings; mistake was fixed by the patch )
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---