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

C# Emit.EmitContext类代码示例

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

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



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

示例1: WritePeToStream

        public static bool WritePeToStream(
            EmitContext context,
            CommonMessageProvider messageProvider,
            Func<Stream> getPeStream,
            PdbWriter nativePdbWriterOpt,
            string pdbPathOpt,
            bool allowMissingMethodBodies,
            bool deterministic,
            CancellationToken cancellationToken)
        {
            // If PDB writer is given, we have to have PDB path.
            Debug.Assert(nativePdbWriterOpt == null || pdbPathOpt != null);

            var peWriter = new PeWriter(context.Module, pdbPathOpt, deterministic);
            var mdWriter = FullMetadataWriter.Create(context, messageProvider, allowMissingMethodBodies, deterministic, cancellationToken);

            return peWriter.WritePeToStream(mdWriter, getPeStream, nativePdbWriterOpt);
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:18,代码来源:PeWriter.cs


示例2: WritePeToStream

        public static void WritePeToStream(
            EmitContext context,
            CommonMessageProvider messageProvider,
            Stream peStream,
            PdbWriter nativePdbWriterOpt,
            bool allowMissingMethodBodies,
            bool deterministic,
            CancellationToken cancellationToken)
        {
            var peWriter = new PeWriter(context.Module, nativePdbWriterOpt, deterministic);

            var mdWriter = FullMetadataWriter.Create(context, messageProvider, allowMissingMethodBodies, deterministic, cancellationToken);

            if (nativePdbWriterOpt != null)
            {
                nativePdbWriterOpt.SetMetadataEmitter(mdWriter);
            }

            uint entryPointToken;
            peWriter.WritePeToStream(mdWriter, peStream, nativePdbWriterOpt, out entryPointToken);

            if (nativePdbWriterOpt != null)
            {
                if (entryPointToken != 0)
                {
                    nativePdbWriterOpt.SetEntryPoint(entryPointToken);
                }

                var assembly = context.Module.AsAssembly;
                if (assembly != null && assembly.Kind == ModuleKind.WindowsRuntimeMetadata)
                {
                    // Dev12: If compiling to winmdobj, we need to add to PDB source spans of
                    //        all types and members for better error reporting by WinMDExp.
                    nativePdbWriterOpt.WriteDefinitionLocations(context.Module.GetSymbolToLocationMap());
                }
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:37,代码来源:PeWriter.cs


示例3:

 ITypeDefinition ITypeReference.GetResolvedType(EmitContext context)
 {
     throw ExceptionUtilities.Unreachable;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:4,代码来源:ModifiedTypeReference.cs


示例4: NoPiaReferenceIndexer

 internal NoPiaReferenceIndexer(EmitContext context)
     : base(context)
 {
     this.module = context.Module;
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:5,代码来源:ReferenceIndexer.cs


示例5: WritePeToStream

        public static bool WritePeToStream(
            EmitContext context,
            CommonMessageProvider messageProvider,
            Func<Stream> getPeStream,
            Func<Stream> getPortablePdbStreamOpt,
            PdbWriter nativePdbWriterOpt,
            string pdbPathOpt,
            bool allowMissingMethodBodies,
            bool isDeterministic,
            CancellationToken cancellationToken)
        {
            // If PDB writer is given, we have to have PDB path.
            Debug.Assert(nativePdbWriterOpt == null || pdbPathOpt != null);

            var mdWriter = FullMetadataWriter.Create(context, messageProvider, allowMissingMethodBodies, isDeterministic, getPortablePdbStreamOpt != null, cancellationToken);

            var properties = context.Module.Properties;

            nativePdbWriterOpt?.SetMetadataEmitter(mdWriter);

            // Since we are producing a full assembly, we should not have a module version ID
            // imposed ahead-of time. Instead we will compute a deterministic module version ID
            // based on the contents of the generated stream.
            Debug.Assert(properties.PersistentIdentifier == default(Guid));

            var ilBuilder = new BlobBuilder(32 * 1024);
            var mappedFieldDataBuilder = new BlobBuilder();
            var managedResourceBuilder = new BlobBuilder(1024);

            Blob mvidFixup;
            mdWriter.BuildMetadataAndIL(
                nativePdbWriterOpt,
                ilBuilder,
                mappedFieldDataBuilder,
                managedResourceBuilder,
                out mvidFixup);

            MethodDefinitionHandle entryPointHandle;
            MethodDefinitionHandle debugEntryPointHandle;
            mdWriter.GetEntryPoints(out entryPointHandle, out debugEntryPointHandle);
            
            if (!debugEntryPointHandle.IsNil)
            {
                nativePdbWriterOpt?.SetEntryPoint((uint)MetadataTokens.GetToken(debugEntryPointHandle));
            }

            if (nativePdbWriterOpt != null)
            {
                var assembly = mdWriter.Module.AsAssembly;
                if (assembly != null && assembly.Kind == OutputKind.WindowsRuntimeMetadata)
                {
                    // Dev12: If compiling to winmdobj, we need to add to PDB source spans of
                    //        all types and members for better error reporting by WinMDExp.
                    nativePdbWriterOpt.WriteDefinitionLocations(mdWriter.Module.GetSymbolToLocationMap());
                }
                else
                {
#if DEBUG
                    // validate that all definitions are writable
                    // if same scenario would happen in an winmdobj project
                    nativePdbWriterOpt.AssertAllDefinitionsHaveTokens(mdWriter.Module.GetSymbolToLocationMap());
#endif
                }
            }

            Stream peStream = getPeStream();
            if (peStream == null)
            {
                return false;
            }

            ContentId nativePdbContentId = nativePdbWriterOpt?.GetContentId() ?? default(ContentId);

            // the writer shall not be used after this point for writing:
            nativePdbWriterOpt = null;

            var metadataSerializer = mdWriter.GetTypeSystemMetadataSerializer();

            var peBuilder = new PEBuilder(
                machine: properties.Machine,
                sectionAlignment: properties.SectionAlignment,
                fileAlignment: properties.FileAlignment,
                imageBase: properties.BaseAddress,
                majorLinkerVersion: properties.LinkerMajorVersion,
                minorLinkerVersion: properties.LinkerMinorVersion,
                majorOperatingSystemVersion: 4,
                minorOperatingSystemVersion: 0,
                majorImageVersion: 0,
                minorImageVersion: 0,
                majorSubsystemVersion: properties.MajorSubsystemVersion,
                minorSubsystemVersion: properties.MinorSubsystemVersion,
                subsystem: properties.Subsystem,
                dllCharacteristics: properties.DllCharacteristics,
                imageCharacteristics: properties.ImageCharacteristics,
                sizeOfStackReserve: properties.SizeOfStackReserve,
                sizeOfStackCommit: properties.SizeOfStackCommit,
                sizeOfHeapReserve: properties.SizeOfHeapReserve,
                sizeOfHeapCommit: properties.SizeOfHeapCommit,
                deterministicIdProvider: isDeterministic ? new Func<BlobBuilder, ContentId>(content => ContentId.FromHash(CryptographicHashProvider.ComputeSha1(content))) : null);

//.........这里部分代码省略.........
开发者ID:Rookieek,项目名称:roslyn,代码行数:101,代码来源:PeWriter.cs


示例6: TypeCode

 public PrimitiveTypeCode TypeCode(EmitContext context)
 {
     return PrimitiveTypeCode.NotPrimitive;
 }
开发者ID:pheede,项目名称:roslyn,代码行数:4,代码来源:InheritedTypeParameter.cs


示例7: GetAttributes

 public IEnumerable<ICustomAttribute> GetAttributes(EmitContext context)
 {
     return this.parentParameter.GetAttributes(context);
 }
开发者ID:pheede,项目名称:roslyn,代码行数:4,代码来源:InheritedTypeParameter.cs


示例8: AsTypeDefinition

 public ITypeDefinition AsTypeDefinition(EmitContext context)
 {
     return this as ITypeDefinition;
 }
开发者ID:pheede,项目名称:roslyn,代码行数:4,代码来源:InheritedTypeParameter.cs


示例9: AsNamespaceTypeDefinition

 public INamespaceTypeDefinition AsNamespaceTypeDefinition(EmitContext context)
 {
     return this as INamespaceTypeDefinition;
 }
开发者ID:pheede,项目名称:roslyn,代码行数:4,代码来源:InheritedTypeParameter.cs


示例10: GetType

 public override Cci.ITypeReference GetType(EmitContext context)
     => _arrayType.GetElementType(context);
开发者ID:GloryChou,项目名称:roslyn,代码行数:2,代码来源:ArrayMembers.cs


示例11: AsDefinition

 public Cci.IDefinition AsDefinition(EmitContext context)
 {
     return null;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:4,代码来源:ArrayMembers.cs


示例12: GetAttributes

 public IEnumerable<ICustomAttribute> GetAttributes(EmitContext context)
 {
     return this.containingMethod.ReturnValueAttributes;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:4,代码来源:ReturnValueParameter.cs


示例13: GetDefaultValue

 public IMetadataConstant GetDefaultValue(EmitContext context)
 {
     return null;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:4,代码来源:ReturnValueParameter.cs


示例14: AsNestedTypeDefinition

 public INestedTypeDefinition AsNestedTypeDefinition(EmitContext context)
 {
     return this as INestedTypeDefinition;
 }
开发者ID:pheede,项目名称:roslyn,代码行数:4,代码来源:InheritedTypeParameter.cs


示例15: GetParameters

 public ImmutableArray<Cci.IParameterTypeInformation> GetParameters(EmitContext context)
     => StaticCast<Cci.IParameterTypeInformation>.From(_parameters);
开发者ID:GloryChou,项目名称:roslyn,代码行数:2,代码来源:ArrayMembers.cs


示例16: AsDefinition

 public IDefinition AsDefinition(EmitContext context)
 {
     return this as IDefinition;
 }
开发者ID:pheede,项目名称:roslyn,代码行数:4,代码来源:InheritedTypeParameter.cs


示例17: GetResolvedMethod

 public Cci.IMethodDefinition GetResolvedMethod(EmitContext context) => null;
开发者ID:GloryChou,项目名称:roslyn,代码行数:1,代码来源:ArrayMembers.cs


示例18: GetResolvedType

 public ITypeDefinition GetResolvedType(EmitContext context)
 {
     throw ExceptionUtilities.Unreachable;
 }
开发者ID:pheede,项目名称:roslyn,代码行数:4,代码来源:InheritedTypeParameter.cs


示例19: GetContainingType

 public Cci.ITypeReference GetContainingType(EmitContext context)
 {
     // We are not translating arrayType. 
     // It is an array type and it is never generic or contained in a generic.
     return this.arrayType;
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:6,代码来源:ArrayMembers.cs


示例20: GetConstraints

 public IEnumerable<ITypeReference> GetConstraints(EmitContext context)
 {
     return this.parentParameter.GetConstraints(context);
 }
开发者ID:pheede,项目名称:roslyn,代码行数:4,代码来源:InheritedTypeParameter.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Microsoft.ManagementConsole类代码示例发布时间:2022-05-24
下一篇:
C# Microsoft.Cci类代码示例发布时间: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