private IEnumerable <ISymbol> GetMembersForRequiredInit(ITypeSymbol type, ObjectCreationExpressionSyntax objectCreation, SemanticModel semanticModel) { var membersExtractor = new MembersExtractor(semanticModel, objectCreation); if (IsInsideInitBlockWithFullInit(objectCreation) || SymbolHelper.IsMarkedWithAttribute(type, SmartAnnotations.InitRequired) || SymbolHelper.IsMarkedWithAttribute(type, SmartAnnotations.InitOnly)) { return(membersExtractor.GetAllMembersThatCanBeInitialized(type)); } var symbolCache = new SymbolHelperCache(); return(membersExtractor.GetAllMembersThatCanBeInitialized(type).Where(memberSymbol => SymbolHelper.IsMarkedWithAttribute(memberSymbol, SmartAnnotations.InitRequired) || SymbolHelper.IsMarkedWithAttribute(memberSymbol, SmartAnnotations.InitOnly) || NonNullableShouldBeInitialized(memberSymbol, symbolCache))); }
private static bool NonNullableShouldBeInitialized(ISymbol member, SymbolHelperCache symbolHelperCache) => symbolHelperCache.IsMarkedWithAttribute(member.ContainingAssembly, SmartAnnotations.InitRequiredForNotNull) && IsNotNullableReference(member);