Beispiel #1
0
            private void AddTypeForward(Assembly assembly, INamedTypeDefinition seedType)
            {
                var alias = new NamespaceAliasForType();

                alias.AliasedType = ConvertDefinitionToReferenceIfTypeIsNested(seedType, _seedHost);
                alias.IsPublic    = true;

                if (assembly.ExportedTypes == null)
                {
                    assembly.ExportedTypes = new List <IAliasForType>();
                }
                // Make sure that the typeforward doesn't already exist in the ExportedTypes
                if (!assembly.ExportedTypes.Any(t => t.AliasedType.RefDocId() == alias.AliasedType.RefDocId()))
                {
                    assembly.ExportedTypes.Add(alias);
                }
                else
                {
                    throw new FacadeGenerationException($"{seedType.FullName()} typeforward already exists");
                }
            }
Beispiel #2
0
            private void AddTypeForward(Assembly assembly, INamedTypeDefinition seedType)
            {
                var alias = new NamespaceAliasForType();
                alias.AliasedType = ConvertDefinitionToReferenceIfTypeIsNested(seedType, _seedHost);
                alias.IsPublic = true;

                if (assembly.ExportedTypes == null)
                    assembly.ExportedTypes = new List<IAliasForType>();
                assembly.ExportedTypes.Add(alias);
            }
Beispiel #3
0
            private void AddTypeForward(Assembly assembly, INamedTypeDefinition seedType)
            {
                var alias = new NamespaceAliasForType();
                alias.AliasedType = ConvertDefinitionToReferenceIfTypeIsNested(seedType, _seedHost);
                alias.IsPublic = true;

                if (assembly.ExportedTypes == null)
                    assembly.ExportedTypes = new List<IAliasForType>();
                // Make sure that the typeforward doesn't already exist in the ExportedTypes
                if (!assembly.ExportedTypes.Any(t => t.AliasedType.RefDocId() == alias.AliasedType.RefDocId()))
                    assembly.ExportedTypes.Add(alias);
                else
                    throw new FacadeGenerationException($"{seedType.FullName()} typeforward already exists");
            }
Beispiel #4
0
            private void AddTypeForward(Assembly assembly, INamedTypeDefinition seedType)
            {
                var alias = new NamespaceAliasForType();
                alias.AliasedType = ConvertDefinitionToReferenceIfTypeIsNested(seedType, _seedHost);
                alias.IsPublic = true;

                if (assembly.ExportedTypes == null)
                    assembly.ExportedTypes = new List<IAliasForType>();
                assembly.ExportedTypes.Add(alias);

                // Recursively add forwarders for all nested types regardless of their accessibility. This is
                // how the C# compiler emits type forwarders for nested types. We might not need them for
                // nested types that are not visible outside the assembly, but it is safer to replicate how
                // the C# compiler works. Plus, it helps when diffing the output from ildasm for facades
                // that were built from source vs. those that were produced by this tool.
                //
                // NOTE: Some design-time tools can resolve forwarded nested types with only the top-level forwarder,
                //       but the runtime currently throws a TypeLoadException without explicit forwarders for the nested
                //       types.
                foreach (var nestedType in seedType.NestedTypes.OrderBy(t => t.Name.Value))
                    AddTypeForward(assembly, nestedType);
            }