Exemplo n.º 1
0
        protected Accessibility ComputeAccesibility(Accessibility accessibility, ITypeSymbol type)
        {
            var computedAccessbility = accessibility;

            if (accessibility == Accessibility.NotApplicable || accessibility == Accessibility.Private)
            {
                computedAccessbility = Accessibility.Public;
            }

            var returnTypeAccessibility = type.DetermineMinimalAccessibility();

            return(CommonAccessibilityUtilities.Minimum(computedAccessbility, returnTypeAccessibility));
        }
            public override Accessibility VisitNamedType(INamedTypeSymbol symbol)
            {
                Accessibility accessibility = symbol.DeclaredAccessibility;

                foreach (ITypeSymbol 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);
            }
Exemplo n.º 3
0
            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);
            }