public EmitContext( CommonPEModuleBuilder module, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics, bool metadataOnly, bool includePrivateMembers ) { Debug.Assert(module != null); Debug.Assert(diagnostics != null); Debug.Assert(includePrivateMembers || metadataOnly); Module = module; SyntaxNodeOpt = syntaxNodeOpt; Diagnostics = diagnostics; Flags flags = Flags.None; if (metadataOnly) { flags |= Flags.MetadataOnly; } if (includePrivateMembers) { flags |= Flags.IncludePrivateMembers; } _flags = flags; }
public EmitContext( CommonPEModuleBuilder module, DiagnosticBag diagnostics, bool metadataOnly, bool includePrivateMembers, SyntaxNode?syntaxNode = null, RebuildData?rebuildData = null) { Debug.Assert(rebuildData is null || !metadataOnly); RebuildData = rebuildData; Debug.Assert(module != null); Debug.Assert(diagnostics != null); Debug.Assert(includePrivateMembers || metadataOnly); Module = module; SyntaxNode = syntaxNode; RebuildData = rebuildData; Diagnostics = diagnostics; Flags flags = Flags.None; if (metadataOnly) { flags |= Flags.MetadataOnly; } if (includePrivateMembers) { flags |= Flags.IncludePrivateMembers; } _flags = flags; }
public EmitContext(CommonPEModuleBuilder module, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics) { Debug.Assert(module != null); Debug.Assert(diagnostics != null); Module = module; SyntaxNodeOpt = syntaxNodeOpt; Diagnostics = diagnostics; }
internal EmitBaseline With( Compilation compilation, CommonPEModuleBuilder moduleBuilder, int ordinal, Guid encId, IReadOnlyDictionary <Cci.ITypeDefinition, int> typesAdded, IReadOnlyDictionary <Cci.IEventDefinition, int> eventsAdded, IReadOnlyDictionary <Cci.IFieldDefinition, int> fieldsAdded, IReadOnlyDictionary <Cci.IMethodDefinition, int> methodsAdded, IReadOnlyDictionary <Cci.IPropertyDefinition, int> propertiesAdded, IReadOnlyDictionary <int, int> eventMapAdded, IReadOnlyDictionary <int, int> propertyMapAdded, IReadOnlyDictionary <MethodImplKey, int> methodImplsAdded, ImmutableArray <int> tableEntriesAdded, int blobStreamLengthAdded, int stringStreamLengthAdded, int userStringStreamLengthAdded, int guidStreamLengthAdded, IReadOnlyDictionary <AnonymousTypeKey, AnonymousTypeValue> anonymousTypeMap, ImmutableDictionary <Cci.ITypeDefinition, ImmutableArray <Cci.ITypeDefinitionMember> > synthesizedMembers, IReadOnlyDictionary <int, AddedOrChangedMethodInfo> addedOrChangedMethods, Func <MethodDefinitionHandle, EditAndContinueMethodDebugInformation> debugInformationProvider) { Debug.Assert(_anonymousTypeMap == null || anonymousTypeMap != null); Debug.Assert(_anonymousTypeMap == null || anonymousTypeMap.Count >= _anonymousTypeMap.Count); return(new EmitBaseline( InitialBaseline, OriginalMetadata, compilation, moduleBuilder, ModuleVersionId, ordinal, encId, HasPortablePdb, typesAdded, eventsAdded, fieldsAdded, methodsAdded, propertiesAdded, eventMapAdded, propertyMapAdded, methodImplsAdded, tableEntriesAdded, blobStreamLengthAdded: blobStreamLengthAdded, stringStreamLengthAdded: stringStreamLengthAdded, userStringStreamLengthAdded: userStringStreamLengthAdded, guidStreamLengthAdded: guidStreamLengthAdded, anonymousTypeMap: anonymousTypeMap, synthesizedMembers: synthesizedMembers, methodsAddedOrChanged: addedOrChangedMethods, debugInformationProvider: debugInformationProvider, typeToEventMap: TypeToEventMap, typeToPropertyMap: TypeToPropertyMap, methodImpls: MethodImpls)); }
internal EmitBaseline With( Compilation compilation, CommonPEModuleBuilder moduleBuilder, int ordinal, Guid encId, IReadOnlyDictionary <ITypeDefinition, uint> typesAdded, IReadOnlyDictionary <IEventDefinition, uint> eventsAdded, IReadOnlyDictionary <IFieldDefinition, uint> fieldsAdded, IReadOnlyDictionary <IMethodDefinition, uint> methodsAdded, IReadOnlyDictionary <IPropertyDefinition, uint> propertiesAdded, IReadOnlyDictionary <uint, uint> eventMapAdded, IReadOnlyDictionary <uint, uint> propertyMapAdded, IReadOnlyDictionary <MethodImplKey, uint> methodImplsAdded, ImmutableArray <int> tableEntriesAdded, int blobStreamLengthAdded, int stringStreamLengthAdded, int userStringStreamLengthAdded, int guidStreamLengthAdded, IReadOnlyDictionary <AnonymousTypeKey, AnonymousTypeValue> anonymousTypeMap, IReadOnlyDictionary <uint, ImmutableArray <EncLocalInfo> > localsForMethodsAddedOrChanged, LocalVariableNameProvider localNames) { Debug.Assert((this.AnonymousTypeMap == null) || (anonymousTypeMap != null)); Debug.Assert((this.AnonymousTypeMap == null) || (anonymousTypeMap.Count >= this.AnonymousTypeMap.Count)); return(new EmitBaseline( this.OriginalMetadata, compilation, moduleBuilder, this.ModuleVersionId, ordinal, encId, typesAdded, eventsAdded, fieldsAdded, methodsAdded, propertiesAdded, eventMapAdded, propertyMapAdded, methodImplsAdded, tableEntriesAdded, blobStreamLengthAdded: blobStreamLengthAdded, stringStreamLengthAdded: stringStreamLengthAdded, userStringStreamLengthAdded: userStringStreamLengthAdded, guidStreamLengthAdded: guidStreamLengthAdded, anonymousTypeMap: anonymousTypeMap, localsForMethodsAddedOrChanged: localsForMethodsAddedOrChanged, localNames: localNames, typeToEventMap: this.TypeToEventMap, typeToPropertyMap: this.TypeToPropertyMap, methodImpls: this.MethodImpls)); }
public EmitBaseline MapBaselineToCompilation( EmitBaseline baseline, Compilation targetCompilation, CommonPEModuleBuilder targetModuleBuilder, ImmutableDictionary <ISymbolInternal, ImmutableArray <ISymbolInternal> > mappedSynthesizedMembers, ImmutableDictionary <ISymbolInternal, ImmutableArray <ISymbolInternal> > mappedDeletedMembers) { // Map all definitions to this compilation. var typesAdded = MapDefinitions(baseline.TypesAdded); var eventsAdded = MapDefinitions(baseline.EventsAdded); var fieldsAdded = MapDefinitions(baseline.FieldsAdded); var methodsAdded = MapDefinitions(baseline.MethodsAdded); var propertiesAdded = MapDefinitions(baseline.PropertiesAdded); var generationOrdinals = MapDefinitions(baseline.GenerationOrdinals); return(baseline.With( targetCompilation, targetModuleBuilder, baseline.Ordinal, baseline.EncId, generationOrdinals, typesAdded, eventsAdded, fieldsAdded, methodsAdded, firstParamRowMap: baseline.FirstParamRowMap, propertiesAdded, eventMapAdded: baseline.EventMapAdded, propertyMapAdded: baseline.PropertyMapAdded, methodImplsAdded: baseline.MethodImplsAdded, customAttributesAdded: baseline.CustomAttributesAdded, tableEntriesAdded: baseline.TableEntriesAdded, blobStreamLengthAdded: baseline.BlobStreamLengthAdded, stringStreamLengthAdded: baseline.StringStreamLengthAdded, userStringStreamLengthAdded: baseline.UserStringStreamLengthAdded, guidStreamLengthAdded: baseline.GuidStreamLengthAdded, anonymousTypeMap: MapAnonymousTypes(baseline.AnonymousTypeMap), anonymousDelegates: MapAnonymousDelegates(baseline.AnonymousDelegates), anonymousDelegatesWithFixedTypes: MapAnonymousDelegatesWithFixedTypes(baseline.AnonymousDelegatesWithFixedTypes), synthesizedMembers: mappedSynthesizedMembers, deletedMembers: mappedDeletedMembers, addedOrChangedMethods: MapAddedOrChangedMethods(baseline.AddedOrChangedMethods), debugInformationProvider: baseline.DebugInformationProvider, localSignatureProvider: baseline.LocalSignatureProvider)); }
public IEnumerable <INamespaceTypeDefinition> GetTopLevelTypes(EmitContext context) { CommonPEModuleBuilder module = (CommonPEModuleBuilder)context.Module; foreach (INamespaceTypeDefinition type in module.GetAnonymousTypes()) { yield return(type); } foreach (ISymbol symbol in _changes.Keys) { INamespaceTypeDefinition namespaceTypeDef = (symbol as ITypeDefinition)?.AsNamespaceTypeDefinition(context); if (namespaceTypeDef != null) { yield return(namespaceTypeDef); } } }
public EmitBaseline MapBaselineToCompilation( EmitBaseline baseline, Compilation targetCompilation, CommonPEModuleBuilder targetModuleBuilder, ImmutableDictionary <Cci.ITypeDefinition, ImmutableArray <Cci.ITypeDefinitionMember> > mappedSynthesizedMembers) { // Map all definitions to this compilation. var typesAdded = MapDefinitions(baseline.TypesAdded); var eventsAdded = MapDefinitions(baseline.EventsAdded); var fieldsAdded = MapDefinitions(baseline.FieldsAdded); var methodsAdded = MapDefinitions(baseline.MethodsAdded); var propertiesAdded = MapDefinitions(baseline.PropertiesAdded); return(baseline.With( targetCompilation, targetModuleBuilder, baseline.Ordinal, baseline.EncId, typesAdded, eventsAdded, fieldsAdded, methodsAdded, propertiesAdded, eventMapAdded: baseline.EventMapAdded, propertyMapAdded: baseline.PropertyMapAdded, methodImplsAdded: baseline.MethodImplsAdded, tableEntriesAdded: baseline.TableEntriesAdded, blobStreamLengthAdded: baseline.BlobStreamLengthAdded, stringStreamLengthAdded: baseline.StringStreamLengthAdded, userStringStreamLengthAdded: baseline.UserStringStreamLengthAdded, guidStreamLengthAdded: baseline.GuidStreamLengthAdded, anonymousTypeMap: MapAnonymousTypes(baseline.AnonymousTypeMap), synthesizedMembers: mappedSynthesizedMembers, addedOrChangedMethods: MapAddedOrChangedMethods(baseline.AddedOrChangedMethods), debugInformationProvider: baseline.DebugInformationProvider, localSignatureProvider: baseline.LocalSignatureProvider)); }
private EmitBaseline( EmitBaseline initialBaseline, ModuleMetadata module, Compilation compilation, CommonPEModuleBuilder moduleBuilder, Guid moduleVersionId, int ordinal, Guid encId, IReadOnlyDictionary <Cci.ITypeDefinition, uint> typesAdded, IReadOnlyDictionary <Cci.IEventDefinition, uint> eventsAdded, IReadOnlyDictionary <Cci.IFieldDefinition, uint> fieldsAdded, IReadOnlyDictionary <Cci.IMethodDefinition, uint> methodsAdded, IReadOnlyDictionary <Cci.IPropertyDefinition, uint> propertiesAdded, IReadOnlyDictionary <uint, uint> eventMapAdded, IReadOnlyDictionary <uint, uint> propertyMapAdded, IReadOnlyDictionary <MethodImplKey, uint> methodImplsAdded, ImmutableArray <int> tableEntriesAdded, int blobStreamLengthAdded, int stringStreamLengthAdded, int userStringStreamLengthAdded, int guidStreamLengthAdded, IReadOnlyDictionary <AnonymousTypeKey, AnonymousTypeValue> anonymousTypeMap, ImmutableDictionary <Cci.ITypeDefinition, ImmutableArray <Cci.ITypeDefinitionMember> > synthesizedMembers, IReadOnlyDictionary <uint, AddedOrChangedMethodInfo> methodsAddedOrChanged, Func <MethodDefinitionHandle, EditAndContinueMethodDebugInformation> debugInformationProvider, IReadOnlyDictionary <uint, uint> typeToEventMap, IReadOnlyDictionary <uint, uint> typeToPropertyMap, IReadOnlyDictionary <MethodImplKey, uint> methodImpls) { Debug.Assert(module != null); Debug.Assert((ordinal == 0) == (encId == default(Guid))); Debug.Assert((ordinal == 0) == (initialBaseline == null)); Debug.Assert(encId != module.GetModuleVersionId()); Debug.Assert(debugInformationProvider != null); Debug.Assert(typeToEventMap != null); Debug.Assert(typeToPropertyMap != null); Debug.Assert(moduleVersionId != default(Guid)); Debug.Assert(moduleVersionId == module.GetModuleVersionId()); Debug.Assert(synthesizedMembers != null); Debug.Assert(tableEntriesAdded.Length == MetadataTokens.TableCount); // The size of each table is the total number of entries added in all previous // generations after the initial generation. Depending on the table, some of the // entries may not be available in the current generation (say, a synthesized type // from a method that was not recompiled for instance) Debug.Assert(tableEntriesAdded[(int)TableIndex.TypeDef] >= typesAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.Event] >= eventsAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.Field] >= fieldsAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.MethodDef] >= methodsAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.Property] >= propertiesAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.EventMap] >= eventMapAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.PropertyMap] >= propertyMapAdded.Count); var reader = module.Module.MetadataReader; this.InitialBaseline = initialBaseline ?? this; this.OriginalMetadata = module; this.Compilation = compilation; this.PEModuleBuilder = moduleBuilder; this.ModuleVersionId = moduleVersionId; this.Ordinal = ordinal; this.EncId = encId; this.TypesAdded = typesAdded; this.EventsAdded = eventsAdded; this.FieldsAdded = fieldsAdded; this.MethodsAdded = methodsAdded; this.PropertiesAdded = propertiesAdded; this.EventMapAdded = eventMapAdded; this.PropertyMapAdded = propertyMapAdded; this.MethodImplsAdded = methodImplsAdded; this.TableEntriesAdded = tableEntriesAdded; this.BlobStreamLengthAdded = blobStreamLengthAdded; this.StringStreamLengthAdded = stringStreamLengthAdded; this.UserStringStreamLengthAdded = userStringStreamLengthAdded; this.GuidStreamLengthAdded = guidStreamLengthAdded; this._anonymousTypeMap = anonymousTypeMap; this.SynthesizedMembers = synthesizedMembers; this.AddedOrChangedMethods = methodsAddedOrChanged; this.DebugInformationProvider = debugInformationProvider; this.TableSizes = CalculateTableSizes(reader, this.TableEntriesAdded); this.TypeToEventMap = typeToEventMap; this.TypeToPropertyMap = typeToPropertyMap; this.MethodImpls = methodImpls; }
public EmitContext(CommonPEModuleBuilder module, SyntaxNode?syntaxNode, DiagnosticBag diagnostics, bool metadataOnly, bool includePrivateMembers) : this(module, diagnostics, metadataOnly, includePrivateMembers, syntaxNode, rebuildData : null) { }
private EmitBaseline( ModuleMetadata module, Compilation compilation, CommonPEModuleBuilder moduleBuilder, Guid moduleVersionId, int ordinal, Guid encId, IReadOnlyDictionary <ITypeDefinition, uint> typesAdded, IReadOnlyDictionary <IEventDefinition, uint> eventsAdded, IReadOnlyDictionary <IFieldDefinition, uint> fieldsAdded, IReadOnlyDictionary <IMethodDefinition, uint> methodsAdded, IReadOnlyDictionary <IPropertyDefinition, uint> propertiesAdded, IReadOnlyDictionary <uint, uint> eventMapAdded, IReadOnlyDictionary <uint, uint> propertyMapAdded, ImmutableArray <int> tableEntriesAdded, int blobStreamLengthAdded, int stringStreamLengthAdded, int userStringStreamLengthAdded, int guidStreamLengthAdded, IReadOnlyDictionary <AnonymousTypeKey, AnonymousTypeValue> anonymousTypeMap, IReadOnlyDictionary <uint, ImmutableArray <EncLocalInfo> > localsForMethodsAddedOrChanged, LocalVariableNameProvider localNames, IReadOnlyDictionary <uint, uint> typeToEventMap, IReadOnlyDictionary <uint, uint> typeToPropertyMap) { Debug.Assert(module != null); Debug.Assert((ordinal == 0) == (encId == default(Guid))); Debug.Assert(encId != module.GetModuleVersionId()); Debug.Assert(localNames != null); Debug.Assert(typeToEventMap != null); Debug.Assert(typeToPropertyMap != null); Debug.Assert(tableEntriesAdded.Length == MetadataTokens.TableCount); // The size of each table is the total number of entries added in all previous // generations after the initial generation. Depending on the table, some of the // entries may not be available in the current generation (say, a synthesized type // from a method that was not recompiled for instance) Debug.Assert(tableEntriesAdded[(int)TableIndex.TypeDef] >= typesAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.Event] >= eventsAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.Field] >= fieldsAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.MethodDef] >= methodsAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.Property] >= propertiesAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.EventMap] >= eventMapAdded.Count); Debug.Assert(tableEntriesAdded[(int)TableIndex.PropertyMap] >= propertyMapAdded.Count); var reader = module.Module.MetadataReader; this.OriginalMetadata = module; this.Compilation = compilation; this.PEModuleBuilder = moduleBuilder; this.ModuleVersionId = moduleVersionId; this.Ordinal = ordinal; this.EncId = encId; this.TypesAdded = typesAdded; this.EventsAdded = eventsAdded; this.FieldsAdded = fieldsAdded; this.MethodsAdded = methodsAdded; this.PropertiesAdded = propertiesAdded; this.EventMapAdded = eventMapAdded; this.PropertyMapAdded = propertyMapAdded; this.TableEntriesAdded = tableEntriesAdded; this.BlobStreamLengthAdded = blobStreamLengthAdded; this.StringStreamLengthAdded = stringStreamLengthAdded; this.UserStringStreamLengthAdded = userStringStreamLengthAdded; this.GuidStreamLengthAdded = guidStreamLengthAdded; this.AnonymousTypeMap = anonymousTypeMap; this.LocalsForMethodsAddedOrChanged = localsForMethodsAddedOrChanged; this.LocalNames = localNames; this.TableSizes = CalculateTableSizes(reader, this.TableEntriesAdded); this.TypeToEventMap = typeToEventMap; this.TypeToPropertyMap = typeToPropertyMap; }