1414 using NServiceBus . Features ;
1515 using NServiceBus . Hosting . Helpers ;
1616 using NServiceBus . Logging . Loggers . NLogAdapter ;
17- using ServiceControl . MessageAuditing ;
1817 using TransportIntegration ;
1918
2019 public class DefaultServerWithoutAudit : DefaultServer
@@ -102,20 +101,32 @@ static void SetupLogging(EndpointConfiguration endpointConfiguration)
102101
103102 static IEnumerable < Type > GetTypesToUse ( EndpointConfiguration endpointConfiguration )
104103 {
105- var assemblies = new AssemblyScanner ( ) . GetScannableAssemblies ( ) . Assemblies
106- . Where ( a => a != typeof ( ProcessedMessage ) . Assembly ) . ToList ( ) ;
107-
108-
109- var types = assemblies
110- . SelectMany ( a => a . GetTypes ( ) )
111- . Where (
112- t =>
113- t . Assembly != Assembly . GetExecutingAssembly ( ) || //exclude all test types by default
114- t . DeclaringType == endpointConfiguration . BuilderType . DeclaringType ||
115- //but include types on the test level
116- t . DeclaringType == endpointConfiguration . BuilderType ) ;
117- //and the specific types for this endpoint
118- return types ;
104+ var assemblies = new AssemblyScanner ( ) . GetScannableAssemblies ( ) ;
105+
106+ var types = assemblies . Assemblies
107+ //exclude all test types by default
108+ . Where ( a => a != Assembly . GetExecutingAssembly ( ) )
109+ . Where ( a => a . GetName ( ) . Name != "ServiceControl" )
110+ . SelectMany ( a => a . GetTypes ( ) ) ;
111+
112+ types = types . Union ( GetNestedTypeRecursive ( endpointConfiguration . BuilderType . DeclaringType , endpointConfiguration . BuilderType ) ) ;
113+
114+ types = types . Union ( endpointConfiguration . TypesToInclude ) ;
115+
116+ return types . Where ( t => ! endpointConfiguration . TypesToExclude . Contains ( t ) ) . ToList ( ) ;
117+ }
118+
119+ static IEnumerable < Type > GetNestedTypeRecursive ( Type rootType , Type builderType )
120+ {
121+ yield return rootType ;
122+
123+ if ( typeof ( IEndpointConfigurationFactory ) . IsAssignableFrom ( rootType ) && rootType != builderType )
124+ yield break ;
125+
126+ foreach ( var nestedType in rootType . GetNestedTypes ( BindingFlags . Instance | BindingFlags . Static | BindingFlags . Public | BindingFlags . NonPublic ) . SelectMany ( t => GetNestedTypeRecursive ( t , builderType ) ) )
127+ {
128+ yield return nestedType ;
129+ }
119130 }
120131 }
121132}
0 commit comments