public static string GetName(this ISymUnmanagedVariable local) { int numAvailable; local.GetName(0, out numAvailable, null); if (numAvailable == 0) { return(""); } var chars = new char[numAvailable]; int numRead; local.GetName(numAvailable, out numRead, chars); if (numRead != numAvailable) { throw new InvalidOperationException(string.Format("Read only {0} of {1} name characters.", numRead, numAvailable)); } Debug.Assert(chars[numAvailable - 1] == 0); return(new string(chars, 0, numAvailable - 1)); }
public static void ValidateVariable(ISymUnmanagedVariable variable, string name, int slot, LocalVariableAttributes attributes, byte[] signature) { int length, length2; // name: Assert.Equal(HResult.S_OK, variable.GetName(0, out length, null)); Assert.Equal(name.Length + 1, length); var actualName = new char[length]; Assert.Equal(HResult.S_OK, variable.GetName(length, out length2, actualName)); Assert.Equal(length, length2); Assert.Equal(name + "\0", new string(actualName)); int value; Assert.Equal(HResult.S_OK, variable.GetAddressField1(out value)); Assert.Equal(slot, value); Assert.Equal(HResult.E_NOTIMPL, variable.GetAddressField2(out value)); Assert.Equal(HResult.E_NOTIMPL, variable.GetAddressField3(out value)); Assert.Equal(HResult.E_NOTIMPL, variable.GetStartOffset(out value)); Assert.Equal(HResult.E_NOTIMPL, variable.GetEndOffset(out value)); Assert.Equal(HResult.S_OK, variable.GetAttributes(out value)); Assert.Equal(attributes, (LocalVariableAttributes)value); Assert.Equal(HResult.S_OK, variable.GetAddressKind(out value)); Assert.Equal(1, value); Assert.Equal(HResult.S_OK, variable.GetSignature(0, out length, null)); var actualSignature = new byte[length]; Assert.Equal(HResult.S_OK, variable.GetSignature(length, out length2, actualSignature)); Assert.Equal(length, length2); AssertEx.Equal(signature, actualSignature); }