Пример #1
0
        protected Accessibility ComputeAccessibility(Accessibility accessibility, ITypeSymbol type)
        {
            var computedAccessibility = accessibility;

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

            var returnTypeAccessibility = type.DetermineMinimalAccessibility();

            return(AccessibilityUtilities.Minimum(computedAccessibility, returnTypeAccessibility));
        }
Пример #2
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      = AccessibilityUtilities.Minimum(
                    containingTypeAccessibility, accessibility);

                var returnTypeAccessibility = state.TypeMemberType.DetermineMinimalAccessibility();

                if (AccessibilityUtilities.Minimum(effectiveAccessibility, returnTypeAccessibility) !=
                    effectiveAccessibility)
                {
                    return(returnTypeAccessibility);
                }

                return(accessibility);
            }