private static IEnumerable <IMappingSourceFinder> GetAllPossibleSourceFinders(InitializerExpressionSyntax objectInitializer, SemanticModel semanticModel, SyntaxGenerator syntaxGenerator) { var localSymbols = semanticModel.GetLocalSymbols(objectInitializer); var container = objectInitializer.FindNearestContainer <QueryExpressionSyntax, VariableDeclaratorSyntax>(); switch (container) { case QueryExpressionSyntax queryExpression: yield return(GetMappingSourceFindersForQueryExpression(semanticModel, syntaxGenerator, queryExpression, localSymbols)); yield break; case VariableDeclaratorSyntax vds: { var leftSymbol = semanticModel.GetDeclaredSymbol(vds); localSymbols = localSymbols.Where(ls => ls != leftSymbol).ToList(); break; } } yield return(new LocalScopeMappingSourceFinder(semanticModel, localSymbols)); foreach (var localSymbol in localSymbols) { var symbolType = semanticModel.GetTypeForSymbol(localSymbol); if (symbolType != null && ObjectHelper.IsSimpleType(symbolType) == false) { yield return(new ObjectMembersMappingSourceFinder(symbolType, SyntaxFactory.IdentifierName(localSymbol.Name), syntaxGenerator)); } } }