예제 #1
0
        private void DefineLocalConstant(string name, object value, PrimitiveTypeCode typeCode, uint constantSignatureToken)
        {
            if (value == null)
            {
                // ISymUnmanagedWriter2.DefineConstant2 throws an ArgumentException
                // if you pass in null - Dev10 appears to use 0 instead.
                // (See EMITTER::VariantFromConstVal)
                value    = 0;
                typeCode = PrimitiveTypeCode.Int32;
            }

            if (typeCode == PrimitiveTypeCode.String)
            {
                DefineLocalStringConstant(name, (string)value, constantSignatureToken);
            }
            else if (value is DateTime)
            {
                // Marshal.GetNativeVariantForObject would create a variant with type VT_DATE and value equal to the
                // number of days since 1899/12/30.  However, ConstantValue::VariantFromConstant in the native VB
                // compiler actually created a variant with type VT_DATE and value equal to the tick count.
                // http://blogs.msdn.com/b/ericlippert/archive/2003/09/16/eric-s-complete-guide-to-vt-date.aspx
                _symWriter.DefineConstant2(name, new VariantStructure((DateTime)value), constantSignatureToken);
            }
            else
            {
                try
                {
                    _symWriter.DefineConstant2(name, value, constantSignatureToken);
                }
                catch (Exception ex)
                {
                    throw new PdbWritingException(ex);
                }
            }
        }
예제 #2
0
        public void DefineConstant2(string name, object value, SymbolToken sigToken)
        {
            if (value == null)
            {
                m_writer.DefineConstant2(name, 0, sigToken);
                return;
            }

            m_writer.DefineConstant2(name, value, sigToken);
        }
예제 #3
0
파일: SymWriter.cs 프로젝트: wuxiongbin/XIL
        public void DefineConstant2(string name, object value, int sigToken)
        {
            if (value == null)
            {
                writer.DefineConstant2(name, 0, sigToken);
                return;
            }

            writer.DefineConstant2(name, value, sigToken);
        }
예제 #4
0
        public static unsafe void DefineConstant2(this ISymUnmanagedWriter2 writer, string name, object value, uint sigToken)
        {
            VariantStructure variant = new VariantStructure();

            Marshal.GetNativeVariantForObject(value, new IntPtr(&variant));
            writer.DefineConstant2(name, variant, sigToken);
        }
예제 #5
0
 public void DefineConstant2(string name, object value, uint sigToken)
 {
     writer.DefineConstant2(name, value, sigToken);
 }
 public override void DefineConstant(string name, object value, uint sigToken) => writer.DefineConstant2(name, value, sigToken);
예제 #7
0
 private void WriteConstant(Constant constant)
 {
     pdb.DefineConstant2(constant.Name, constant.Value, constant.Token);
 }