Pchp.CodeAnalysis.Symbols.FieldSymbol.GetMetadataConstantValue C# (CSharp) Méthode

GetMetadataConstantValue() private méthode

private GetMetadataConstantValue ( Microsoft.CodeAnalysis.Emit.EmitContext context ) : Microsoft.Cci.IMetadataConstant
context Microsoft.CodeAnalysis.Emit.EmitContext
Résultat Microsoft.Cci.IMetadataConstant
        internal Cci.IMetadataConstant GetMetadataConstantValue(EmitContext context)
        {
            // A constant field of type decimal is not treated as a compile time value in CLR,
            // so check if it is a metadata constant, not just a constant to exclude decimals.
            if (this.IsMetadataConstant)
            {
                // NOTE: We would like to be able to assert that the constant value of this field
                // is not bad (i.e. ConstantValue.Bad) if it is being consumed by CCI, but we can't
                // because this method is called by the ReferenceIndexer in the metadata-only case
                // (and we specifically don't want to prevent metadata-only emit because of a bad
                // constant).  If the constant value is bad, we'll end up exposing null to CCI.
                return ((PEModuleBuilder)context.Module).CreateConstant(this.Type, this.ConstantValue,
                                                               syntaxNodeOpt: context.SyntaxNodeOpt,
                                                               diagnostics: context.Diagnostics);
            }

            return null;
        }