@@ -26,8 +26,6 @@ public static string GeneratePublicApi(this Assembly assembly, ApiGeneratorOptio
2626 {
2727 options ??= new ApiGeneratorOptions ( ) ;
2828
29- var attributeFilter = new AttributeFilter ( options . ExcludeAttributes ) ;
30-
3129 using ( var assemblyResolver = new DefaultAssemblyResolver ( ) )
3230 {
3331 var assemblyPath = assembly . Location ;
@@ -43,14 +41,11 @@ public static string GeneratePublicApi(this Assembly assembly, ApiGeneratorOptio
4341 {
4442 return CreatePublicApiForAssembly (
4543 asm ,
44+ options ,
4645 typeDefinition => ! typeDefinition . IsNested &&
4746 ShouldIncludeType ( typeDefinition , options . DenyNamespacePrefixes , options . AllowNamespacePrefixes , options . UseDenyNamespacePrefixesForExtensionMethods ) &&
48- ( options . IncludeTypes == null || options . IncludeTypes . Any ( type => type . FullName == typeDefinition . FullName && type . Assembly . FullName == typeDefinition . Module . Assembly . FullName ) ) ,
49- options . IncludeAssemblyAttributes ,
50- options . DenyNamespacePrefixes ,
51- options . AllowNamespacePrefixes ,
52- options . UseDenyNamespacePrefixesForExtensionMethods ,
53- attributeFilter ) ;
47+ ( options . IncludeTypes == null || options . IncludeTypes . Any ( type => type . FullName == typeDefinition . FullName && type . Assembly . FullName == typeDefinition . Module . Assembly . FullName ) )
48+ ) ;
5449 }
5550 }
5651 }
@@ -86,12 +81,14 @@ public static string GeneratePublicApi(this Type type, ApiGeneratorOptions? opti
8681
8782 // TODO: Assembly references?
8883 // TODO: Better handle namespaces - using statements? - requires non-qualified type names
89- private static string CreatePublicApiForAssembly ( AssemblyDefinition assembly , Func < TypeDefinition , bool > shouldIncludeType , bool shouldIncludeAssemblyAttributes , string [ ] denyNamespacePrefixes , string [ ] allowNamespacePrefixes , bool useDenyNamespacePrefixesForExtensionMethods , AttributeFilter attributeFilter )
84+ private static string CreatePublicApiForAssembly ( AssemblyDefinition assembly , ApiGeneratorOptions options , Func < TypeDefinition , bool > shouldIncludeType )
9085 {
86+ var attributeFilter = new AttributeFilter ( options . ExcludeAttributes ) ;
87+
9188 using var provider = new CSharpCodeProvider ( ) ;
9289
9390 var compileUnit = new CodeCompileUnit ( ) ;
94- if ( shouldIncludeAssemblyAttributes && assembly . HasCustomAttributes )
91+ if ( options . IncludeAssemblyAttributes && assembly . HasCustomAttributes )
9592 {
9693 PopulateCustomAttributes ( assembly , compileUnit . AssemblyCustomAttributes , attributeFilter ) ;
9794 }
@@ -110,7 +107,7 @@ private static string CreatePublicApiForAssembly(AssemblyDefinition assembly, Fu
110107
111108 using ( NullableContext . Push ( publicType ) )
112109 {
113- var typeDeclaration = CreateTypeDeclaration ( publicType , denyNamespacePrefixes , allowNamespacePrefixes , useDenyNamespacePrefixesForExtensionMethods , attributeFilter ) ;
110+ var typeDeclaration = CreateTypeDeclaration ( publicType , options . DenyNamespacePrefixes , options . AllowNamespacePrefixes , options . UseDenyNamespacePrefixesForExtensionMethods , attributeFilter ) ;
114111 @namespace . Types . Add ( typeDeclaration ) ;
115112 }
116113 }
@@ -119,10 +116,10 @@ private static string CreatePublicApiForAssembly(AssemblyDefinition assembly, Fu
119116 {
120117 var cgo = new CodeGeneratorOptions
121118 {
122- BracingStyle = "C" ,
119+ BracingStyle = options . BracingStyle ,
123120 BlankLinesBetweenMembers = false ,
124121 VerbatimOrder = false ,
125- IndentString = " "
122+ IndentString = options . IndentString
126123 } ;
127124
128125 provider . GenerateCodeFromCompileUnit ( compileUnit , writer , cgo ) ;
0 commit comments