public void TypeFinder_Benchmark_Findings() { var scanner = new DefaultTypeScanner( new ModuleCatalog(), NullLogger.Instance, typeof(ISomeInterface).Assembly); var type = scanner.FindTypes <ISomeInterface>(); type.Count().ShouldEqual(1); typeof(ISomeInterface).IsAssignableFrom(type.FirstOrDefault()).ShouldBeTrue(); }
public IReadOnlyList <ClusterMethodBindings> DoExtraction( ITypeInfoContainer typeInfoContainer ) { if (typeInfoContainer is null) { throw new ArgumentNullException(nameof(typeInfoContainer)); } var scanner = new DefaultTypeScanner( ); var clusterTypes = scanner.ScanForClusterTypes( typeInfoContainer ); var stepResults = new List <ClusterMethodBindings>(); for (var clusterTypeIndex = 0; clusterTypeIndex < clusterTypes.Count; clusterTypeIndex++) { var clusterType = clusterTypes[clusterTypeIndex]; clusterType.ScanForRequiredSyntaxes( out List <MethodDeclarationSyntax> bindMethodSyntaxes, out List <CompilationUnitSyntax> compilationUnitSyntaxes ); if (compilationUnitSyntaxes.Count == 0) { throw new DpdtException( DpdtExceptionTypeEnum.InternalError, $"Unknown problem to access to compilation unit syntax" ); } var semanticModels = new List <SemanticModel>(); var moduleUnitUsings = new List <UsingDirectiveSyntax>(); foreach (var compilationUnitSyntax in compilationUnitSyntaxes) { var moduleUnitUsing = compilationUnitSyntax .DescendantNodes() .OfType <UsingDirectiveSyntax>() .ToList(); moduleUnitUsings.AddRange(moduleUnitUsing); var semanticModel = typeInfoContainer.GetSemanticModel(compilationUnitSyntax.SyntaxTree); semanticModels.Add(semanticModel); } var semanticModelDecorator = new SemanticModelDecorator( semanticModels ); var stepResult = new ClusterMethodBindings( clusterType, moduleUnitUsings ); foreach (var bindMethodSyntax in bindMethodSyntaxes) { var bindExtractor = new BindClauseExtractor( semanticModelDecorator, new DetermineBindExpressionFactory( new ExplicitBindExpressionFactory( typeInfoContainer, semanticModelDecorator, new ConstructorArgumentFromSyntaxExtractor( semanticModelDecorator ), new ConstructorArgumentDetector( BindConstructorChooser.Instance ) ), new ConventionalBindExpressionFactory( typeInfoContainer, new ConstructorArgumentFromSyntaxExtractor( semanticModelDecorator ), new ConstructorArgumentDetector( BindConstructorChooser.Instance ), _diagnosticReporter ) ) ); bindExtractor.Visit(bindMethodSyntax); stepResult.AddMethodBindings( bindMethodSyntax, bindExtractor.BindingContainers ); } stepResults.Add(stepResult); } return(stepResults); }