public override Accessibility VisitNamedType(INamedTypeSymbol symbol) { var accessibility = symbol.DeclaredAccessibility; foreach (var arg in symbol.TypeArguments) { accessibility = CommonAccessibilityUtilities.Minimum(accessibility, arg.Accept(this)); } if (symbol.ContainingType != null) { accessibility = CommonAccessibilityUtilities.Minimum(accessibility, symbol.ContainingType.Accept(this)); } return(accessibility); }
private Accessibility DetermineMaximalAccessibility(State state) { if (state.TypeToGenerateIn.TypeKind == TypeKind.Interface) { return(Accessibility.NotApplicable); } var accessibility = Accessibility.Public; // Ensure that we're not overly exposing a type. var containingTypeAccessibility = state.TypeToGenerateIn.DetermineMinimalAccessibility(); var effectiveAccessibility = CommonAccessibilityUtilities.Minimum( containingTypeAccessibility, accessibility); var returnTypeAccessibility = state.TypeMemberType.DetermineMinimalAccessibility(); if (CommonAccessibilityUtilities.Minimum(effectiveAccessibility, returnTypeAccessibility) != effectiveAccessibility) { return(returnTypeAccessibility); } return(accessibility); }