• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ModuleCompilationState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ModuleCompilationState的典型用法代码示例。如果您正苦于以下问题:C# ModuleCompilationState类的具体用法?C# ModuleCompilationState怎么用?C# ModuleCompilationState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ModuleCompilationState类属于命名空间,在下文中一共展示了ModuleCompilationState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddSynthesizedAttributes

        internal sealed override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            var compilation = this.DeclaringCompilation;

            if (this.IsParams)
            {
                AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_ParamArrayAttribute__ctor));
            }

            // Synthesize DecimalConstantAttribute if we don't have an explicit custom attribute already:
            var defaultValue = this.ExplicitDefaultConstantValue;
            if (defaultValue != ConstantValue.NotAvailable &&
                defaultValue.SpecialType == SpecialType.System_Decimal &&
                DefaultValueFromAttributes == ConstantValue.NotAvailable)
            {
                AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDecimalConstantAttribute(defaultValue.DecimalValue));
            }

            if (this.Type.ContainsDynamic())
            {
                AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDynamicAttribute(this.Type, this.CustomModifiers.Length, this.RefKind));
            }

            if (Type.ContainsTupleNames())
            {
                AddSynthesizedAttribute(ref attributes,
                    compilation.SynthesizeTupleNamesAttribute(Type));
            }
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:31,代码来源:SourceParameterSymbolBase.cs


示例2: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            var compilation = this.DeclaringCompilation;
            AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor));
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:SynthesizedFieldLikeEventAccessorSymbol.cs


示例3: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            CSharpCompilation compilation = this.DeclaringCompilation;

            // do not emit CompilerGenerated attributes for fields inside compiler generated types:
            if (!_containingType.IsImplicitlyDeclared)
            {
                AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor));
            }

            if (!this.SuppressDynamicAttribute &&
                this.Type.ContainsDynamic() &&
                compilation.HasDynamicEmitAttributes() &&
                compilation.CanEmitBoolean())
            {
                AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDynamicAttribute(this.Type, this.CustomModifiers.Length));
            }

            if (Type.ContainsTuple() &&
                compilation.HasTupleNamesAttributes &&
                compilation.CanEmitSpecialType(SpecialType.System_String))
            {
                AddSynthesizedAttribute(ref attributes,
                    compilation.SynthesizeTupleNamesAttributeOpt(Type));
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:28,代码来源:SynthesizedFieldSymbolBase.cs


示例4: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            var compilation = this.DeclaringCompilation;
            AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_Diagnostics_DebuggerHiddenAttribute__ctor));
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:7,代码来源:IteratorConstructor.cs


示例5: GetCustomAttributesToEmit

        internal virtual IEnumerable<CSharpAttributeData> GetCustomAttributesToEmit(ModuleCompilationState compilationState)
        {
            CheckDefinitionInvariant();

            Debug.Assert(this.Kind != SymbolKind.Assembly);
            return GetCustomAttributesToEmit(compilationState, emittingAssemblyAttributesInNetModule: false);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:SymbolAdapter.cs


示例6: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            var compilation = this.DeclaringCompilation;

            // Dev11 doesn't synthesize this attribute, the debugger has a knowledge 
            // of special name C# compiler uses for backing fields, which is not desirable.
            AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDebuggerBrowsableNeverAttribute());
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:10,代码来源:SynthesizedBackingFieldSymbol.cs


示例7: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            var compilation = this.DeclaringCompilation;
            if (this.ReturnType.ContainsDynamic() && compilation.HasDynamicEmitAttributes() && compilation.CanEmitBoolean())
            {
                AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDynamicAttribute(this.ReturnType, this.ReturnTypeCustomModifiers.Length));
            }
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:10,代码来源:SynthesizedImplementationMethod.cs


示例8: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            var compilation = this.DeclaringCompilation;
            AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor));

            // Dev11 doesn't synthesize this attribute, the debugger has a knowledge 
            // of special name C# compiler uses for backing fields, which is not desirable.
            AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDebuggerBrowsableNeverAttribute());
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:SourceEventFieldSymbol.cs


示例9: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            var compilation = this.DeclaringCompilation;
            var systemType = compilation.GetWellKnownType(WellKnownType.System_Type);
            var intType = compilation.GetSpecialType(SpecialType.System_Int32);
            var item1 = new TypedConstant(systemType, TypedConstantKind.Type, ((PointerTypeSymbol)this.Type).PointedAtType);
            var item2 = new TypedConstant(intType, TypedConstantKind.Primitive, this.FixedSize);
            AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(
                WellKnownMember.System_Runtime_CompilerServices_FixedBufferAttribute__ctor,
                ImmutableArray.Create<TypedConstant>(item1, item2)));
        }
开发者ID:orthoxerox,项目名称:roslyn,代码行数:13,代码来源:SourceFixedFieldSymbol.cs


示例10: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            // do not generate attributes for members of compiler-generated types:
            if (ContainingType.IsImplicitlyDeclared)
            {
                return;
            }

            var compilation = this.DeclaringCompilation;

            AddSynthesizedAttribute(ref attributes,
                compilation.TrySynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor));
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:15,代码来源:SynthesizedMethodBaseSymbol.cs


示例11: AddSynthesizedAttributes

        internal sealed override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            if (debuggerHidden)
            {
                var compilation = this.DeclaringCompilation;
                AddSynthesizedAttribute(ref attributes, compilation.SynthesizeAttribute(WellKnownMember.System_Diagnostics_DebuggerHiddenAttribute__ctor));
            }

            if (this.ReturnType.ContainsDynamic())
            {
                var compilation = this.DeclaringCompilation;
                AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDynamicAttribute(this.ReturnType, this.ReturnTypeCustomModifiers.Length));
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:16,代码来源:SynthesizedImplementationMethod.cs


示例12: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            var compilation = this.DeclaringCompilation;
            if (this.ReturnType.ContainsDynamic() && compilation.HasDynamicEmitAttributes() && compilation.CanEmitBoolean())
            {
                AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDynamicAttribute(this.ReturnType, this.ReturnTypeCustomModifiers.Length + this.RefCustomModifiers.Length, this.RefKind));
            }

            if (ReturnType.ContainsTupleNames() &&
                compilation.HasTupleNamesAttributes &&
                compilation.CanEmitSpecialType(SpecialType.System_String))
            {
                AddSynthesizedAttribute(ref attributes,
                    compilation.SynthesizeTupleNamesAttribute(ReturnType));
            }
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:18,代码来源:SynthesizedImplementationMethod.cs


示例13: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            if (ContainingSymbol.Kind == SymbolKind.NamedType && ContainingSymbol.IsImplicitlyDeclared)
            {
                return;
            }

            var compilation = ContainingSymbol.DeclaringCompilation;

            // this can only happen if frame is not nested in a source type/namespace (so far we do not do this)
            // if this happens for whatever reason, we do not need "CompilerGenerated" anyways
            Debug.Assert(compilation != null, "SynthesizedClass is not contained in a source module?");

            AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(
                WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor));
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:18,代码来源:SynthesizedContainer.cs


示例14: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            // do not emit Dynamic or CompilerGenerated attributes for fields inside compiler generated types:
            if (containingType.IsImplicitlyDeclared)
            {
                return;
            }

            CSharpCompilation compilation = this.DeclaringCompilation;

            // Assume that someone checked earlier that the attribute ctor is available and has no use-site errors.
            AddSynthesizedAttribute(ref attributes, compilation.SynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor));

            // TODO (tomat): do we need to emit dynamic attribute on any synthesized field?
            if (this.Type.ContainsDynamic())
            {
                // Assume that someone checked earlier that the attribute ctor is available and has no use-site errors.
                AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDynamicAttribute(this.Type, customModifiersCount: 0));
            }
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:22,代码来源:SynthesizedFieldSymbolBase.cs


示例15: GetCustomAttributesToEmit

 protected override IEnumerable<CSharpAttributeData> GetCustomAttributesToEmit(ModuleCompilationState compilationState)
 {
     return UnderlyingProperty.GetCustomAttributesToEmit(compilationState);
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:4,代码来源:EmbeddedProperty.cs


示例16: Bug530209


//.........这里部分代码省略.........
    .param[1]
    .custom instance void [mscorlib]System.Runtime.CompilerServices.DecimalConstantAttribute::.ctor(uint8,
                                                                                                    uint8,
                                                                                                    uint32,
                                                                                                    uint32,
                                                                                                    uint32)
             = {
        uint8(0)
                uint8(128)
                uint32(0)
                uint32(0)
                uint32(7)}
    .custom instance void [mscorlib]System.Runtime.CompilerServices.DecimalConstantAttribute::.ctor(uint8,
                                                                                                    uint8,
                                                                                                    int32,
                                                                                                    int32,
                                                                                                    int32)
             = {
        uint8(0)
                uint8(128)
                int32(0)
                int32(0)
                int32(8)}
    .param[2]
    .custom instance void [mscorlib]System.Runtime.CompilerServices.DateTimeConstantAttribute::.ctor(int64)
             = { int64(634925952000000001)}
    .custom instance void [mscorlib]System.Runtime.CompilerServices.DateTimeConstantAttribute::.ctor(int64)
             = { int64(634925952000000000)}
    // Code size       1 (0x1)
    .maxstack  8
    IL_0000:  ret
} // end of method Class1::M1

} // end of class Class1
";

            var c1 = CreateCompilationWithMscorlib(
@"
public class Class1
{
    public const decimal d1 = -7;

    public void M1(decimal d1 = -7)
    {}
}");


            var class1 = c1.GetTypeByMetadataName("Class1");
            var d1 = class1.GetMember<FieldSymbol>("d1");
            var m1 = class1.GetMember<MethodSymbol>("M1");

            var state = new ModuleCompilationState();

            Assert.Empty(d1.GetAttributes());
            Assert.Equal("System.Runtime.CompilerServices.DecimalConstantAttribute(0, 128, 0, 0, 7)", d1.GetCustomAttributesToEmit(state).Single().ToString());
            Assert.Equal(d1.ConstantValue, -7m);
            Assert.Empty(m1.Parameters[0].GetAttributes());
            Assert.Equal("System.Runtime.CompilerServices.DecimalConstantAttribute(0, 128, 0, 0, 7)", m1.Parameters[0].GetCustomAttributesToEmit(state).Single().ToString());
            Assert.Equal(m1.Parameters[0].ExplicitDefaultValue, -7m);

            var c2 = CreateCompilationWithCustomILSource("", ilSource);

            class1 = c2.GetTypeByMetadataName("Class1");
            d1 = class1.GetMember<FieldSymbol>("d1");
            var d2 = class1.GetMember<FieldSymbol>("d2");
            m1 = class1.GetMember<MethodSymbol>("M1");

            Assert.Empty(d1.GetAttributes());
            Assert.Equal("System.Runtime.CompilerServices.DecimalConstantAttribute(0, 128, 0, 0, 7)", d1.GetCustomAttributesToEmit(state).Single().ToString());
            Assert.Equal(d1.ConstantValue, -7m);
            Assert.Equal(2, d2.GetAttributes().Length);
            Assert.Equal(2, d2.GetCustomAttributesToEmit(state).Count());
            Assert.Null(d2.ConstantValue);
            Assert.Empty(m1.Parameters[0].GetAttributes());
            Assert.Equal("System.Runtime.CompilerServices.DecimalConstantAttribute(0, 128, 0, 0, 7)", m1.Parameters[0].GetCustomAttributesToEmit(state).Single().ToString());
            Assert.Equal(m1.Parameters[0].ExplicitDefaultValue, -7m);
            Assert.Empty(m1.Parameters[1].GetAttributes());
            Assert.Equal("System.Runtime.CompilerServices.DateTimeConstantAttribute(634925952000000000)", m1.Parameters[1].GetCustomAttributesToEmit(state).Single().ToString());
            Assert.Equal(m1.Parameters[1].ExplicitDefaultValue, new DateTime(2013, 1, 1));

            var c3 = CreateCompilationWithCustomILSource("", ilSource);

            class1 = c3.GetTypeByMetadataName("Class1");
            d1 = class1.GetMember<FieldSymbol>("d1");
            d2 = class1.GetMember<FieldSymbol>("d2");
            m1 = class1.GetMember<MethodSymbol>("M1");

            Assert.Equal(d1.ConstantValue, -7m);
            Assert.Empty(d1.GetAttributes());
            Assert.Equal("System.Runtime.CompilerServices.DecimalConstantAttribute(0, 128, 0, 0, 7)", d1.GetCustomAttributesToEmit(state).Single().ToString());
            Assert.Null(d2.ConstantValue);
            Assert.Equal(2, d2.GetAttributes().Length);
            Assert.Equal(2, d2.GetCustomAttributesToEmit(state).Count());
            Assert.Equal(m1.Parameters[0].ExplicitDefaultValue, -7m);
            Assert.Empty(m1.Parameters[0].GetAttributes());
            Assert.Equal("System.Runtime.CompilerServices.DecimalConstantAttribute(0, 128, 0, 0, 7)", m1.Parameters[0].GetCustomAttributesToEmit(state).Single().ToString());
            Assert.Equal(m1.Parameters[1].ExplicitDefaultValue, new DateTime(2013, 1, 1));
            Assert.Empty(m1.Parameters[1].GetAttributes());
            Assert.Equal("System.Runtime.CompilerServices.DateTimeConstantAttribute(634925952000000000)", m1.Parameters[1].GetCustomAttributesToEmit(state).Single().ToString());
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:101,代码来源:LoadingAttributes.cs


示例17: AddSynthesizedAttributes

 internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
 {
     // no attributes should be emitted
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:SynthesizedEnumValueFieldSymbol.cs


示例18: AddSynthesizedAttributes

        internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
        {
            base.AddSynthesizedAttributes(compilationState, ref attributes);

            var compilation = this.DeclaringCompilation;
            var value = this.GetConstantValue(ConstantFieldsInProgress.Empty, earlyDecodingWellKnownAttributes: false);

            // Synthesize DecimalConstantAttribute when the default value is of type decimal
            if (this.IsConst && value != null
                && this.Type.SpecialType == SpecialType.System_Decimal)
            {
                var data = GetDecodedWellKnownAttributeData();

                if (data == null || data.ConstValue == CodeAnalysis.ConstantValue.Unset)
                {
                    AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDecimalConstantAttribute(value.DecimalValue));
                }
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:19,代码来源:SourceMemberFieldSymbol.cs


示例19: AddSynthesizedAttributes

 internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
 {
     // Emit [Dynamic] on synthesized parameter symbols when the original parameter was dynamic 
     // in order to facilitate debugging.  In the case the necessary attributes are missing 
     // this is a no-op.  Emitting an error here, or when the original parameter was bound, would
     // adversely effect the compilation or potentially change overload resolution.  
     var compilation = this.DeclaringCompilation;
     if (Type.ContainsDynamic() && 
         compilation.HasDynamicEmitAttributes() &&
         compilation.GetSpecialType(SpecialType.System_Boolean).SpecialType == SpecialType.System_Boolean)
     {
         AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDynamicAttribute(this.Type, this.CustomModifiers.Length, this.RefKind));
     }
 }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:14,代码来源:SynthesizedParameterSymbol.cs


示例20: GetCustomAttributesToEmit

 internal override IEnumerable<CSharpAttributeData> GetCustomAttributesToEmit(ModuleCompilationState compilationState)
 {
     throw ExceptionUtilities.Unreachable;
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:4,代码来源:SubstitutedNamedTypeSymbol.cs



注:本文中的ModuleCompilationState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ModuleDef类代码示例发布时间:2022-05-24
下一篇:
C# ModuleCatalog类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap