private FullMetadataWriter( EmitContext context, MetadataHeapsBuilder heaps, CommonMessageProvider messageProvider, bool allowMissingMethodBodies, bool deterministic, CancellationToken cancellationToken) : base(heaps, context, messageProvider, allowMissingMethodBodies, deterministic, cancellationToken) { // EDMAURER make some intelligent guesses for the initial sizes of these things. int numMethods = this.module.HintNumberOfMethodDefinitions; int numTypeDefsGuess = numMethods / 6; int numFieldDefsGuess = numTypeDefsGuess * 4; int numPropertyDefsGuess = numMethods / 4; _typeDefs = new DefinitionIndex <ITypeDefinition>(numTypeDefsGuess); _eventDefs = new DefinitionIndex <IEventDefinition>(0); _fieldDefs = new DefinitionIndex <IFieldDefinition>(numFieldDefsGuess); _methodDefs = new DefinitionIndex <IMethodDefinition>(numMethods); _propertyDefs = new DefinitionIndex <IPropertyDefinition>(numPropertyDefsGuess); _parameterDefs = new DefinitionIndex <IParameterDefinition>(numMethods); _genericParameters = new DefinitionIndex <IGenericParameter>(0); _fieldDefIndex = new Dictionary <ITypeDefinition, uint>(numTypeDefsGuess); _methodDefIndex = new Dictionary <ITypeDefinition, uint>(numTypeDefsGuess); _parameterListIndex = new Dictionary <IMethodDefinition, uint>(numMethods); _assemblyRefIndex = new HeapOrReferenceIndex <IAssemblyReference>(this, AssemblyReferenceComparer.Instance); _moduleRefIndex = new HeapOrReferenceIndex <string>(this); _memberRefIndex = new InstanceAndStructuralReferenceIndex <ITypeMemberReference>(this, new MemberRefComparer(this)); _methodSpecIndex = new InstanceAndStructuralReferenceIndex <IGenericMethodInstanceReference>(this, new MethodSpecComparer(this)); _typeRefIndex = new HeapOrReferenceIndex <ITypeReference>(this); _typeSpecIndex = new InstanceAndStructuralReferenceIndex <ITypeReference>(this, new TypeSpecComparer(this)); _standAloneSignatureIndex = new HeapOrReferenceIndex <uint>(this); }
public FullPeWriter( Microsoft.CodeAnalysis.Emit.Context context, CommonMessageProvider messageProvider, PdbWriter pdbWriter, bool allowMissingMethodBodies, bool foldIdenticalMethodBodies, CancellationToken cancellationToken) : base(context, messageProvider, pdbWriter, allowMissingMethodBodies, foldIdenticalMethodBodies, cancellationToken) { // EDMAURER make some intelligent guesses for the initial sizes of these things. int numMethods = this.module.HintNumberOfMethodDefinitions; int numTypeDefsGuess = numMethods / 6; int numFieldDefsGuess = numTypeDefsGuess * 4; int numPropertyDefsGuess = numMethods / 4; this.typeDefs = new DefinitionIndex <ITypeDefinition>(numTypeDefsGuess); this.eventDefs = new DefinitionIndex <IEventDefinition>(0); this.fieldDefs = new DefinitionIndex <IFieldDefinition>(numFieldDefsGuess); this.methodDefs = new DefinitionIndex <IMethodDefinition>(numMethods); this.propertyDefs = new DefinitionIndex <IPropertyDefinition>(numPropertyDefsGuess); this.parameterDefs = new DefinitionIndex <IParameterDefinition>(numMethods); this.genericParameters = new DefinitionIndex <IGenericParameter>(0); this.fieldDefIndex = new Dictionary <ITypeDefinition, uint>(numTypeDefsGuess); this.methodDefIndex = new Dictionary <ITypeDefinition, uint>(numTypeDefsGuess); this.parameterListIndex = new Dictionary <IMethodDefinition, uint>(numMethods); this.assemblyRefIndex = new HeapOrReferenceIndex <IAssemblyReference>(this, AssemblyReferenceComparer.Instance); this.moduleRefIndex = new HeapOrReferenceIndex <string>(this); this.memberRefIndex = new InstanceAndStructuralReferenceIndex <ITypeMemberReference>(this, new MemberRefComparer(this)); this.methodSpecIndex = new InstanceAndStructuralReferenceIndex <IGenericMethodInstanceReference>(this, new MethodSpecComparer(this)); this.typeRefIndex = new HeapOrReferenceIndex <ITypeReference>(this); this.typeSpecIndex = new InstanceAndStructuralReferenceIndex <ITypeReference>(this, new TypeSpecComparer(this)); this.standAloneSignatureIndex = new HeapOrReferenceIndex <uint>(this); // Add zero-th entry for indexed tables in full metadata. (For delta // metadata, the indexed tables will be concatenated with the full // metadata by the CLR, so the zero-th entries are not needed.) this.blobWriter.WriteByte(0); this.stringWriter.WriteByte(0); this.userStringWriter.WriteByte(0); }
private FullMetadataWriter( EmitContext context, MetadataBuilder builder, MetadataBuilder debugBuilderOpt, DynamicAnalysisDataWriter dynamicAnalysisDataWriterOpt, CommonMessageProvider messageProvider, bool metadataOnly, bool deterministic, bool emitTestCoverageData, CancellationToken cancellationToken) : base(builder, debugBuilderOpt, dynamicAnalysisDataWriterOpt, context, messageProvider, metadataOnly, deterministic, emitTestCoverageData, cancellationToken) { // EDMAURER make some intelligent guesses for the initial sizes of these things. int numMethods = this.module.HintNumberOfMethodDefinitions; int numTypeDefsGuess = numMethods / 6; int numFieldDefsGuess = numTypeDefsGuess * 4; int numPropertyDefsGuess = numMethods / 4; _typeDefs = new DefinitionIndex <ITypeDefinition>(numTypeDefsGuess); _eventDefs = new DefinitionIndex <IEventDefinition>(0); _fieldDefs = new DefinitionIndex <IFieldDefinition>(numFieldDefsGuess); _methodDefs = new DefinitionIndex <IMethodDefinition>(numMethods); _propertyDefs = new DefinitionIndex <IPropertyDefinition>(numPropertyDefsGuess); _parameterDefs = new DefinitionIndex <IParameterDefinition>(numMethods); _genericParameters = new DefinitionIndex <IGenericParameter>(0); _fieldDefIndex = new Dictionary <ITypeDefinition, int>(numTypeDefsGuess); _methodDefIndex = new Dictionary <ITypeDefinition, int>(numTypeDefsGuess); _parameterListIndex = new Dictionary <IMethodDefinition, int>(numMethods); _assemblyRefIndex = new HeapOrReferenceIndex <AssemblyIdentity>(this); _moduleRefIndex = new HeapOrReferenceIndex <string>(this); _memberRefIndex = new InstanceAndStructuralReferenceIndex <ITypeMemberReference>(this, new MemberRefComparer(this)); _methodSpecIndex = new InstanceAndStructuralReferenceIndex <IGenericMethodInstanceReference>(this, new MethodSpecComparer(this)); _typeRefIndex = new HeapOrReferenceIndex <ITypeReference>(this); _typeSpecIndex = new InstanceAndStructuralReferenceIndex <ITypeReference>(this, new TypeSpecComparer(this)); _standAloneSignatureIndex = new HeapOrReferenceIndex <BlobHandle>(this); }