private bool CanVisitCore(IEnumerable <ConfigFilterRuleItemUnion> ruleItems, ISymbol symbol, bool wantProtectedMember, IFilterVisitor outer) { var current = symbol; var parent = symbol.ContainingSymbol; while (!(current is INamespaceSymbol) && parent != null) { if (!outer.CanVisitApi(parent, wantProtectedMember, outer)) { return(false); } current = parent; parent = parent.ContainingSymbol; } foreach (var ruleUnion in ruleItems) { ConfigFilterRuleItem rule = ruleUnion.Rule; if (rule != null && rule.IsMatch(symbol)) { return(rule.CanVisit); } } return(true); }
private static bool CanVisitCore(IEventSymbol symbol, bool wantProtectedMember, IFilterVisitor outer) { switch (symbol.DeclaredAccessibility) { case Accessibility.Public: return(true); case Accessibility.Protected: case Accessibility.ProtectedOrInternal: return(wantProtectedMember); default: break; } if (symbol.ExplicitInterfaceImplementations.Length > 0) { for (int i = 0; i < symbol.ExplicitInterfaceImplementations.Length; i++) { if (outer.CanVisitApi(symbol.ExplicitInterfaceImplementations[i].ContainingType, false, outer)) { return(true); } } } return(false); }
private static bool CanVisitCore(INamedTypeSymbol symbol, bool wantProtectedMember, IFilterVisitor outer) { if (symbol.ContainingType != null) { switch (symbol.DeclaredAccessibility) { case Accessibility.Public: return(outer.CanVisitApi(symbol.ContainingType, wantProtectedMember, outer)); case Accessibility.Protected: case Accessibility.ProtectedOrInternal: return(wantProtectedMember && outer.CanVisitApi(symbol.ContainingType, wantProtectedMember, outer)); default: return(false); } } return(symbol.DeclaredAccessibility == Accessibility.Public); }
private static string GetEiiContainerTypeName(IPropertySymbol symbol, IFilterVisitor filterVisitor) { if (symbol.ExplicitInterfaceImplementations.Length == 0) { return null; } for (int i = 0; i < symbol.ExplicitInterfaceImplementations.Length; i++) { if (filterVisitor.CanVisitApi(symbol.ExplicitInterfaceImplementations[i])) { return NameVisitorCreator.GetCSharp(NameOptions.UseAlias | NameOptions.WithGenericParameter).GetName(symbol.ExplicitInterfaceImplementations[i].ContainingType); } } Debug.Fail("Should not be here!"); return null; }
private static string GetMemberName(IPropertySymbol symbol, IFilterVisitor filterVisitor) { string name = symbol.Name; if (symbol.ExplicitInterfaceImplementations.Length == 0) { return symbol.Name; } for (int i = 0; i < symbol.ExplicitInterfaceImplementations.Length; i++) { if (filterVisitor.CanVisitApi(symbol.ExplicitInterfaceImplementations[i])) { return symbol.ExplicitInterfaceImplementations[i].Name; } } Debug.Fail("Should not be here!"); return symbol.Name; }
private static bool CanVisitCore(ISymbol symbol, bool wantProtectedMember, IFilterVisitor outer) { if (symbol.DeclaredAccessibility == Accessibility.NotApplicable) { return(true); } if (symbol.IsImplicitlyDeclared) { return(false); } var methodSymbol = symbol as IMethodSymbol; if (methodSymbol != null) { return(CanVisitCore(methodSymbol, wantProtectedMember, outer)); } var propertySymbol = symbol as IPropertySymbol; if (propertySymbol != null) { return(CanVisitCore(propertySymbol, wantProtectedMember, outer)); } var eventSymbol = symbol as IEventSymbol; if (eventSymbol != null) { return(CanVisitCore(eventSymbol, wantProtectedMember, outer)); } var fieldSymbol = symbol as IFieldSymbol; if (fieldSymbol != null) { return(CanVisitCore(fieldSymbol, wantProtectedMember, outer)); } var namedTypeSymbol = symbol as INamedTypeSymbol; if (namedTypeSymbol != null) { return(CanVisitCore(namedTypeSymbol, wantProtectedMember, outer)); } var ts = symbol as ITypeSymbol; if (ts != null) { switch (ts.TypeKind) { case TypeKind.Dynamic: case TypeKind.TypeParameter: return(true); case TypeKind.Unknown: case TypeKind.Error: return(false); case TypeKind.Array: return(outer.CanVisitApi(((IArrayTypeSymbol)ts).ElementType, wantProtectedMember, outer)); case TypeKind.Pointer: return(outer.CanVisitApi(((IPointerTypeSymbol)ts).PointedAtType, wantProtectedMember, outer)); default: break; } } if (symbol.DeclaredAccessibility != Accessibility.Public) { return(false); } return(true); }
private ImplementsClauseSyntax GetImplementsClause(IPropertySymbol symbol, IFilterVisitor filterVisitor) { if (symbol.ExplicitInterfaceImplementations.Length == 0) { return null; } var list = (from eii in symbol.ExplicitInterfaceImplementations where filterVisitor.CanVisitApi(eii) select SyntaxFactory.QualifiedName(GetQualifiedNameSyntax(eii.ContainingType), (SimpleNameSyntax)SyntaxFactory.ParseName(eii.Name))).ToList(); if (list.Count == 0) { return null; } return SyntaxFactory.ImplementsClause(SyntaxFactory.SeparatedList(list.ToArray())); }