@@ -26,8 +26,6 @@ public static string GeneratePublicApi(this Assembly assembly, ApiGeneratorOptio
26
26
{
27
27
options ??= new ApiGeneratorOptions ( ) ;
28
28
29
- var attributeFilter = new AttributeFilter ( options . ExcludeAttributes ) ;
30
-
31
29
using ( var assemblyResolver = new DefaultAssemblyResolver ( ) )
32
30
{
33
31
var assemblyPath = assembly . Location ;
@@ -43,14 +41,11 @@ public static string GeneratePublicApi(this Assembly assembly, ApiGeneratorOptio
43
41
{
44
42
return CreatePublicApiForAssembly (
45
43
asm ,
44
+ options ,
46
45
typeDefinition => ! typeDefinition . IsNested &&
47
46
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
+ ) ;
54
49
}
55
50
}
56
51
}
@@ -86,12 +81,14 @@ public static string GeneratePublicApi(this Type type, ApiGeneratorOptions? opti
86
81
87
82
// TODO: Assembly references?
88
83
// 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 )
90
85
{
86
+ var attributeFilter = new AttributeFilter ( options . ExcludeAttributes ) ;
87
+
91
88
using var provider = new CSharpCodeProvider ( ) ;
92
89
93
90
var compileUnit = new CodeCompileUnit ( ) ;
94
- if ( shouldIncludeAssemblyAttributes && assembly . HasCustomAttributes )
91
+ if ( options . IncludeAssemblyAttributes && assembly . HasCustomAttributes )
95
92
{
96
93
PopulateCustomAttributes ( assembly , compileUnit . AssemblyCustomAttributes , attributeFilter ) ;
97
94
}
@@ -110,7 +107,7 @@ private static string CreatePublicApiForAssembly(AssemblyDefinition assembly, Fu
110
107
111
108
using ( NullableContext . Push ( publicType ) )
112
109
{
113
- var typeDeclaration = CreateTypeDeclaration ( publicType , denyNamespacePrefixes , allowNamespacePrefixes , useDenyNamespacePrefixesForExtensionMethods , attributeFilter ) ;
110
+ var typeDeclaration = CreateTypeDeclaration ( publicType , options . DenyNamespacePrefixes , options . AllowNamespacePrefixes , options . UseDenyNamespacePrefixesForExtensionMethods , attributeFilter ) ;
114
111
@namespace . Types . Add ( typeDeclaration ) ;
115
112
}
116
113
}
@@ -119,10 +116,10 @@ private static string CreatePublicApiForAssembly(AssemblyDefinition assembly, Fu
119
116
{
120
117
var cgo = new CodeGeneratorOptions
121
118
{
122
- BracingStyle = "C" ,
119
+ BracingStyle = options . BracingStyle ,
123
120
BlankLinesBetweenMembers = false ,
124
121
VerbatimOrder = false ,
125
- IndentString = " "
122
+ IndentString = options . IndentString
126
123
} ;
127
124
128
125
provider . GenerateCodeFromCompileUnit ( compileUnit , writer , cgo ) ;
0 commit comments