Beispiel #1
0
        public static string ToAccessibilityModifier(this Microsoft.CodeAnalysis.Accessibility accessibility, Microsoft.CodeAnalysis.Accessibility?containingAccessibility)
        {
            if (containingAccessibility != null && containingAccessibility.Value == accessibility)
            {
                return(string.Empty);
            }
            switch (accessibility)
            {
            case Microsoft.CodeAnalysis.Accessibility.Private:
                return(string.Empty);

            case Microsoft.CodeAnalysis.Accessibility.Protected:
                return("protected ");

            case Microsoft.CodeAnalysis.Accessibility.Internal:
                return("internal ");

            case Microsoft.CodeAnalysis.Accessibility.ProtectedOrInternal:
                return("protected internal ");

            case Microsoft.CodeAnalysis.Accessibility.Public:
                return("public ");

            default:
                throw new InvalidOperationException();
            }
        }
Beispiel #2
0
            private static Accessibility getAccessibility(Microsoft.CodeAnalysis.Accessibility access)
            {
                switch (access)
                {
                case Microsoft.CodeAnalysis.Accessibility.NotApplicable:
                    return(Accessibility.None);

                case Microsoft.CodeAnalysis.Accessibility.Private:
                    return(Accessibility.Private);

                case Microsoft.CodeAnalysis.Accessibility.Protected:
                    return(Accessibility.Protected);

                case Microsoft.CodeAnalysis.Accessibility.Public:
                    return(Accessibility.Public);

                case Microsoft.CodeAnalysis.Accessibility.Internal:
                    return(Accessibility.Internal);

                case Microsoft.CodeAnalysis.Accessibility.ProtectedAndInternal:
                    return(Accessibility.Protected | Accessibility.Internal);

                default:
                    throw new ArgumentOutOfRangeException(nameof(access), $"Type accessibility {access.ToString()} is not supported.");
                }
            }
Beispiel #3
0
        internal static string GetAccess(Microsoft.CodeAnalysis.Accessibility accessibility)
        {
            switch (accessibility)
            {
            case Microsoft.CodeAnalysis.Accessibility.NotApplicable:
                return("");

            case Microsoft.CodeAnalysis.Accessibility.Private:
                return("private-");

            case Microsoft.CodeAnalysis.Accessibility.ProtectedAndInternal:
                return("ProtectedOrInternal-");

            case Microsoft.CodeAnalysis.Accessibility.Protected:
                return("protected-");

            case Microsoft.CodeAnalysis.Accessibility.Internal:
                return("internal-");

            case Microsoft.CodeAnalysis.Accessibility.ProtectedOrInternal:
                return("ProtectedOrInternal-");

            case Microsoft.CodeAnalysis.Accessibility.Public:
                return("");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public static MemberVisibility VisibilityFromAccessibility(Microsoft.CodeAnalysis.Accessibility accessibility)
        {
            if (roslynToNetprintsVisibility.TryGetValue(accessibility, out var visibility))
            {
                return(visibility);
            }

            // TODO: Do this correctly (eg. internal protected, private protected etc.)
            // https://stackoverflow.com/a/585869/4332314
            return(MemberVisibility.Public);
        }
        public static Accessabilty ToInternalType(this Microsoft.CodeAnalysis.Accessibility accessibility)
        {
            switch (accessibility)
            {
            case Microsoft.CodeAnalysis.Accessibility.Public:
                return(Accessabilty.Public);

            case Microsoft.CodeAnalysis.Accessibility.Private:
                return(Accessabilty.Private);

            case Microsoft.CodeAnalysis.Accessibility.Internal:
                return(Accessabilty.Internal);

            case Microsoft.CodeAnalysis.Accessibility.Protected:
                return(Accessabilty.Protected);

            default:
                throw new NotImplementedException();
            }
        }