本文整理汇总了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);
}
示例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());
}
}
}
示例3:
ITypeDefinition ITypeReference.GetResolvedType(EmitContext context)
{
throw ExceptionUtilities.Unreachable;
}
示例4: NoPiaReferenceIndexer
internal NoPiaReferenceIndexer(EmitContext context)
: base(context)
{
this.module = context.Module;
}
示例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);
//.........这里部分代码省略.........
示例6: TypeCode
public PrimitiveTypeCode TypeCode(EmitContext context)
{
return PrimitiveTypeCode.NotPrimitive;
}
示例7: GetAttributes
public IEnumerable<ICustomAttribute> GetAttributes(EmitContext context)
{
return this.parentParameter.GetAttributes(context);
}
示例8: AsTypeDefinition
public ITypeDefinition AsTypeDefinition(EmitContext context)
{
return this as ITypeDefinition;
}
示例9: AsNamespaceTypeDefinition
public INamespaceTypeDefinition AsNamespaceTypeDefinition(EmitContext context)
{
return this as INamespaceTypeDefinition;
}
示例10: GetType
public override Cci.ITypeReference GetType(EmitContext context)
=> _arrayType.GetElementType(context);
示例11: AsDefinition
public Cci.IDefinition AsDefinition(EmitContext context)
{
return null;
}
示例12: GetAttributes
public IEnumerable<ICustomAttribute> GetAttributes(EmitContext context)
{
return this.containingMethod.ReturnValueAttributes;
}
示例13: GetDefaultValue
public IMetadataConstant GetDefaultValue(EmitContext context)
{
return null;
}
示例14: AsNestedTypeDefinition
public INestedTypeDefinition AsNestedTypeDefinition(EmitContext context)
{
return this as INestedTypeDefinition;
}
示例15: GetParameters
public ImmutableArray<Cci.IParameterTypeInformation> GetParameters(EmitContext context)
=> StaticCast<Cci.IParameterTypeInformation>.From(_parameters);