Exemple #1
0
        /// <summary>
        /// Returns a value representing the access modifiers and the presense of the static modifier of the specified member.
        /// </summary>
        public static AccessAndStaticModifiers GetAccessAndStaticModifiers(this IMemberDefinition member)
        {
            if (member == null)
            {
                throw new ArgumentNullException(nameof(member));
            }

            AccessAndStaticModifiers accessFlags = member switch
            {
                MethodDefinition method => (AccessAndStaticModifiers)method.Attributes,
                PropertyDefinition property => property.GetMethod?.GetAccessAndStaticModifiers() ?? 0 | property.SetMethod?.GetAccessAndStaticModifiers() ?? 0,
                EventDefinition @event => @event.AddMethod?.GetAccessAndStaticModifiers() ?? 0 | @event.RemoveMethod?.GetAccessAndStaticModifiers() ?? 0,
                FieldDefinition field => (AccessAndStaticModifiers)field.Attributes,
                TypeDefinition type => (type.Attributes & TypeAttributes.VisibilityMask) switch
                {
                    TypeAttributes.NotPublic => AccessAndStaticModifiers.Assembly,
                    TypeAttributes.Public => AccessAndStaticModifiers.Public,
                    TypeAttributes.NestedPublic => AccessAndStaticModifiers.Public,
                    TypeAttributes.NestedPrivate => AccessAndStaticModifiers.Private,
                    TypeAttributes.NestedFamily => AccessAndStaticModifiers.Family,
                    TypeAttributes.NestedAssembly => AccessAndStaticModifiers.Assembly,
                    TypeAttributes.NestedFamANDAssem => AccessAndStaticModifiers.FamANDAssem,
                    TypeAttributes.NestedFamORAssem => AccessAndStaticModifiers.FamORAssem,
                    _ => throw new Exception(),
                } | (type.IsStatic() ? AccessAndStaticModifiers.Static : 0),
Exemple #2
0
        public MemberAccessibilityReducedIssue(IMemberDefinition member, AccessAndStaticModifiers from, AccessAndStaticModifiers to)
        {
            if (member == null)
            {
                throw new ArgumentNullException(nameof(member));
            }

            this.Member = member;
            this.From   = from;
            this.To     = to;
        }
Exemple #3
0
 public static AccessAndStaticModifiers GetAccessibilityAndStatic(this IMemberDefinition member, out AccessAndStaticModifiers directAccessibility)
 {
     directAccessibility = member.GetAccessAndStaticModifiers();
     return(member.GetAccessibilityAndStatic());
 }