コード例 #1
0
        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);
        }
コード例 #2
0
        public byte[] GetSignature()
        {
            int count;

            unmanagedConstant.GetSignature(0, out count, null);
            byte[] sig = new byte[count];
            unmanagedConstant.GetSignature(count, out count, sig);
            return(sig);
        }
コード例 #3
0
        public byte[] GetSignature()
        {
            int count = 0;

            m_target.GetSignature(0, out count, null);
            byte[] sig = new byte[count];
            m_target.GetSignature(count, out count, sig);
            return(sig);
        }
コード例 #4
0
        byte[] GetSignatureBytes(ISymUnmanagedConstant unc)
        {
            const int E_FAIL    = unchecked ((int)0x80004005);
            const int E_NOTIMPL = unchecked ((int)0x80004001);
            int       hr        = unc.GetSignature(0, out uint bufSize, null);

            if (bufSize == 0 || (hr < 0 && hr != E_FAIL && hr != E_NOTIMPL))
            {
                return(Array2.Empty <byte>());
            }
            var buffer = new byte[bufSize];

            hr = unc.GetSignature((uint)buffer.Length, out bufSize, buffer);
            Debug.Assert(hr == 0);
            if (hr != 0)
            {
                return(Array2.Empty <byte>());
            }
            return(buffer);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: SymTestHelpers.cs プロジェクト: antonfirsov/roslyn
        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);
        }