internal static Accessibility GetEffectiveAccessibility(this BaseFieldDeclarationSyntax syntax, SemanticModel semanticModel, CancellationToken cancellationToken)
        {
            Requires.NotNull(syntax, nameof(syntax));
            Requires.NotNull(semanticModel, nameof(semanticModel));

            Accessibility declaredAccessibility = syntax.GetDeclaredAccessibility(semanticModel, cancellationToken);

            if (declaredAccessibility <= Accessibility.Private)
            {
                return(declaredAccessibility);
            }

            if (!(syntax.Parent is BaseTypeDeclarationSyntax enclosingType))
            {
                return(declaredAccessibility);
            }

            Accessibility enclosingAccessibility = enclosingType.GetEffectiveAccessibility(semanticModel, cancellationToken);

            return(CombineEffectiveAccessibility(declaredAccessibility, enclosingAccessibility));
        }
        internal static Accessibility GetEffectiveAccessibility(this BaseFieldDeclarationSyntax syntax, SemanticModel semanticModel, CancellationToken cancellationToken)
        {
            if (syntax == null)
            {
                throw new ArgumentNullException(nameof(syntax));
            }

            if (semanticModel == null)
            {
                throw new ArgumentNullException(nameof(semanticModel));
            }

            Accessibility declaredAccessibility = syntax.GetDeclaredAccessibility(semanticModel, cancellationToken);

            if (declaredAccessibility <= Accessibility.Private)
            {
                return(declaredAccessibility);
            }

            BaseTypeDeclarationSyntax enclosingType          = (BaseTypeDeclarationSyntax)syntax.Parent;
            Accessibility             enclosingAccessibility = enclosingType.GetEffectiveAccessibility(semanticModel, cancellationToken);

            return(CombineEffectiveAccessibility(declaredAccessibility, enclosingAccessibility));
        }