Пример #1
0
 public AnalyzerScope(AssemblyList assemblyList, IEntity entity)
 {
     AssemblyList   = assemblyList;
     AnalyzedSymbol = entity;
     if (entity is ITypeDefinition type)
     {
         typeScope = type;
         effectiveAccessibility = DetermineEffectiveAccessibility(ref typeScope);
     }
     else
     {
         typeScope = entity.DeclaringTypeDefinition;
         effectiveAccessibility = DetermineEffectiveAccessibility(ref typeScope, entity.Accessibility);
     }
     IsLocal = effectiveAccessibility.LessThanOrEqual(Accessibility.Private);
 }
Пример #2
0
 internal bool ShouldDecodeNullableAttributes(IEntity entity)
 {
     if ((options & TypeSystemOptions.NullabilityAnnotations) == 0)
     {
         return(false);
     }
     if (minAccessibilityForNRT == Accessibility.None || entity == null)
     {
         return(true);
     }
     return(minAccessibilityForNRT.LessThanOrEqual(entity.EffectiveAccessibility()));
 }
Пример #3
0
        static Accessibility DetermineEffectiveAccessibility(ref ITypeDefinition typeScope, Accessibility memberAccessibility = Accessibility.Public)
        {
            Accessibility accessibility = memberAccessibility;

            while (typeScope.DeclaringTypeDefinition != null && !accessibility.LessThanOrEqual(Accessibility.Private))
            {
                accessibility = accessibility.Intersect(typeScope.Accessibility);
                typeScope     = typeScope.DeclaringTypeDefinition;
            }
            // Once we reach a private entity, we leave the loop with typeScope set to the class that
            // contains the private entity = the scope that needs to be searched.
            // Otherwise (if we don't find a private entity) we return the top-level class.
            return(accessibility);
        }