当前位置: 首页>>代码示例>>C#>>正文


C# Emit.EmitContext类代码示例

本文整理汇总了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类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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