public static void ValidateConstant(ISymUnmanagedConstant constant, string name, object value, byte[] signature) { int length, length2; // name: Assert.Equal(HResult.S_OK, constant.GetName(0, out length, null)); Assert.Equal(name.Length + 1, length); var actualName = new char[length]; Assert.Equal(HResult.S_OK, constant.GetName(length, out length2, actualName)); Assert.Equal(length, length2); Assert.Equal(name + "\0", new string(actualName)); // value: object actualValue; Assert.Equal(HResult.S_OK, constant.GetValue(out actualValue)); Assert.Equal(value, actualValue); // signature: Assert.Equal(HResult.S_OK, constant.GetSignature(0, out length, null)); var actualSignature = new byte[length]; Assert.Equal(HResult.S_OK, constant.GetSignature(length, out length2, actualSignature)); Assert.Equal(length, length2); AssertEx.Equal(signature, actualSignature); }
public String GetName() { m_target.GetName(0, out var count, null); StringBuilder name = new StringBuilder(count); m_target.GetName(count, out count, name); return(name.ToString()); }
public string GetName() { int count; unmanagedConstant.GetName(0, out count, null); StringBuilder name = new StringBuilder(count); unmanagedConstant.GetName(count, out count, name); return(name.ToString()); }
string GetName(ISymUnmanagedConstant unc) { unc.GetName(0, out uint count, null); var chars = new char[count]; unc.GetName((uint)chars.Length, out count, chars); if (chars.Length == 0) { return(string.Empty); } return(new string(chars, 0, chars.Length - 1)); }
private static bool TryGetConstantValue(this ISymUnmanagedConstant constant, out NamedLocalConstant value) { value = default(NamedLocalConstant); int length; int hresult = constant.GetName(0, out length, null); SymUnmanagedReaderExtensions.ThrowExceptionForHR(hresult); Debug.Assert(length > 0); if (length == 0) { return(false); } var chars = new char[length]; hresult = constant.GetName(length, out length, chars); SymUnmanagedReaderExtensions.ThrowExceptionForHR(hresult); Debug.Assert(chars[length - 1] == 0); var name = new string(chars, 0, length - 1); constant.GetSignature(0, out length, null); Debug.Assert(length > 0); if (length == 0) { return(false); } var signature = new byte[length]; constant.GetSignature(length, out length, signature); object val; constant.GetValue(out val); var constantValue = GetConstantValue(signature, val); value = new NamedLocalConstant(name, signature, constantValue); return(true); }
public int GetName(int cchName, out int pcchName, char[] name) { return(_constant.GetName(cchName, out pcchName, name)); }