private static IEnumerable <DeclarationTuple <IPropertySymbol> > GetInitializedPropertyDeclarations(TypeDeclarationSyntax declaration, SemanticModel semanticModel) { return(declaration.Members .OfType <PropertyDeclarationSyntax>() .Where(p => !p.Modifiers.Any(IsStaticOrConst) && p.Initializer != null && MemberInitializedToDefault.IsAutoProperty(p)) .Select(p => new DeclarationTuple <IPropertySymbol> { Initializer = p.Initializer, SemanticModel = semanticModel, Symbol = semanticModel.GetDeclaredSymbol(p) }) .Where(t => t.Symbol != null && !MemberInitializedToDefault.IsDefaultValueInitializer(t.Initializer, t.Symbol.Type))); }
private static IEnumerable <DeclarationTuple <TSymbol> > GetInitializedFieldLikeDeclarations <TDeclarationType, TSymbol>(TypeDeclarationSyntax declaration, SemanticModel semanticModel, Func <TSymbol, ITypeSymbol> typeSelector) where TDeclarationType : BaseFieldDeclarationSyntax where TSymbol : class, ISymbol { return(declaration.Members .OfType <TDeclarationType>() .Where(fd => !fd.Modifiers.Any(IsStaticOrConst)) .SelectMany(fd => fd.Declaration.Variables .Where(v => v.Initializer != null) .Select(v => new DeclarationTuple <TSymbol> { Initializer = v.Initializer, SemanticModel = semanticModel, Symbol = semanticModel.GetDeclaredSymbol(v) as TSymbol })) .Where(t => t.Symbol != null && !MemberInitializedToDefault.IsDefaultValueInitializer(t.Initializer, typeSelector(t.Symbol)))); }