/// <summary> /// Returns all top-level (not nested) types defined in the module. /// </summary> public override IEnumerable <Cci.INamespaceTypeDefinition> GetTopLevelTypes(EmitContext context) { Cci.TypeReferenceIndexer typeReferenceIndexer = null; HashSet <string> names; // First time through, we need to collect emitted names of all top level types. if (_namesOfTopLevelTypes == null) { names = new HashSet <string>(); } else { names = null; } // First time through, we need to push things through TypeReferenceIndexer // to make sure we collect all to be embedded NoPia types and members. if (EmbeddedTypesManagerOpt != null && !EmbeddedTypesManagerOpt.IsFrozen) { typeReferenceIndexer = new Cci.TypeReferenceIndexer(context); Debug.Assert(names != null); // Run this reference indexer on the assembly- and module-level attributes first. // We'll run it on all other types below. // The purpose is to trigger Translate on all types. this.Dispatch(typeReferenceIndexer); } AddTopLevelType(names, _rootModuleType); VisitTopLevelType(typeReferenceIndexer, _rootModuleType); yield return(_rootModuleType); foreach (var type in this.GetAnonymousTypes(context)) { AddTopLevelType(names, type); VisitTopLevelType(typeReferenceIndexer, type); yield return(type); } foreach (var type in this.GetTopLevelTypesCore(context)) { AddTopLevelType(names, type); VisitTopLevelType(typeReferenceIndexer, type); yield return(type); } var privateImpl = this.PrivateImplClass; if (privateImpl != null) { AddTopLevelType(names, privateImpl); VisitTopLevelType(typeReferenceIndexer, privateImpl); yield return(privateImpl); } if (EmbeddedTypesManagerOpt != null) { foreach (var embedded in EmbeddedTypesManagerOpt.GetTypes(context.Diagnostics, names)) { AddTopLevelType(names, embedded); yield return(embedded); } } if (names != null) { Debug.Assert(_namesOfTopLevelTypes == null); _namesOfTopLevelTypes = names; } }
private IEnumerable <Cci.INamespaceTypeDefinition> GetTopLevelTypes(EmitContext context) { Cci.NoPiaReferenceIndexer noPiaIndexer = null; HashSet <string> names; // First time through, we need to collect emitted names of all top level types. if (_namesOfTopLevelTypes == null) { names = new HashSet <string>(); } else { names = null; } // First time through, we need to push things through NoPiaReferenceIndexer // to make sure we collect all to be embedded NoPia types and members. if (EmbeddedTypesManagerOpt != null && !EmbeddedTypesManagerOpt.IsFrozen) { noPiaIndexer = new Cci.NoPiaReferenceIndexer(context); Debug.Assert(names != null); this.Dispatch(noPiaIndexer); } AddTopLevelType(names, _rootModuleType); VisitTopLevelType(noPiaIndexer, _rootModuleType); yield return(_rootModuleType); foreach (var type in this.GetAnonymousTypes()) { AddTopLevelType(names, type); VisitTopLevelType(noPiaIndexer, type); yield return(type); } foreach (var type in this.GetTopLevelTypesCore(context)) { AddTopLevelType(names, type); VisitTopLevelType(noPiaIndexer, type); yield return(type); } var privateImpl = this.PrivateImplClass; if (privateImpl != null) { AddTopLevelType(names, privateImpl); VisitTopLevelType(noPiaIndexer, privateImpl); yield return(privateImpl); } if (EmbeddedTypesManagerOpt != null) { foreach (var embedded in EmbeddedTypesManagerOpt.GetTypes(context.Diagnostics, names)) { AddTopLevelType(names, embedded); yield return(embedded); } } if (names != null) { Debug.Assert(_namesOfTopLevelTypes == null); _namesOfTopLevelTypes = names; } }
/// <summary> /// Returns all top-level (not nested) types defined in the module. /// </summary> public override IEnumerable <Cci.INamespaceTypeDefinition> GetTopLevelTypes(EmitContext context) { Cci.NoPiaReferenceIndexer noPiaIndexer = null; HashSet <string> names; // First time through, we need to collect emitted names of all top level types. if (_namesOfTopLevelTypes == null) { names = new HashSet <string>(); } else { names = null; } // First time through, we need to push things through NoPiaReferenceIndexer // to make sure we collect all to be embedded NoPia types and members. if (EmbeddedTypesManagerOpt != null && !EmbeddedTypesManagerOpt.IsFrozen) { noPiaIndexer = new Cci.NoPiaReferenceIndexer(context); Debug.Assert(names != null); this.Dispatch(noPiaIndexer); } #if XSHARP // Replace generation of the _rootModule with the generated // <Module> class when available Cci.INamespaceTypeDefinition topType = null; foreach (var type in this.GetTopLevelTypesCore(context)) { if (String.Equals(type.Name, _rootModuleType.Name)) { topType = type; AddTopLevelType(names, type); VisitTopLevelType(noPiaIndexer, type); yield return(type); } } if (topType == null) { AddTopLevelType(names, _rootModuleType); VisitTopLevelType(noPiaIndexer, _rootModuleType); yield return(_rootModuleType); } #else AddTopLevelType(names, _rootModuleType); VisitTopLevelType(noPiaIndexer, _rootModuleType); yield return(_rootModuleType); #endif foreach (var type in this.GetAnonymousTypes(context)) { AddTopLevelType(names, type); VisitTopLevelType(noPiaIndexer, type); yield return(type); } foreach (var type in this.GetTopLevelTypesCore(context)) { #if XSHARP // Skip when class has been included as top level if (type != topType) { AddTopLevelType(names, type); VisitTopLevelType(noPiaIndexer, type); yield return(type); } #else AddTopLevelType(names, type); VisitTopLevelType(noPiaIndexer, type); yield return(type); #endif } var privateImpl = this.PrivateImplClass; if (privateImpl != null) { AddTopLevelType(names, privateImpl); VisitTopLevelType(noPiaIndexer, privateImpl); yield return(privateImpl); } if (EmbeddedTypesManagerOpt != null) { foreach (var embedded in EmbeddedTypesManagerOpt.GetTypes(context.Diagnostics, names)) { AddTopLevelType(names, embedded); yield return(embedded); } } if (names != null) { Debug.Assert(_namesOfTopLevelTypes == null); _namesOfTopLevelTypes = names; } }