Exemplo n.º 1
0
        private TypeNameSet GetVisibleMembers(NamespaceDependencyRule allowRule, Namespace targetNamespace)
        {
            TypeNameSet allowedTypeNameSet;

            if (_allowRules.TryGetValue(allowRule, out allowedTypeNameSet) &&
                allowedTypeNameSet != null &&
                allowedTypeNameSet.Any())
            {
                return(allowedTypeNameSet);
            }

            if (_visibleTypesPerNamespaces.TryGetValue(targetNamespace, out allowedTypeNameSet))
            {
                return(allowedTypeNameSet);
            }

            return(null);
        }
Exemplo n.º 2
0
        private static TypeNameSet ParseVisibleMembersInsideAllowedRule(XElement xElement, NamespaceDependencyRule allowedRule)
        {
            var visibleMembersChild = xElement.Element(VisibleMembersElementName);

            if (visibleMembersChild == null)
            {
                return(null);
            }

            if (allowedRule.To is NamespaceTree)
            {
                throw new Exception($"{GetLineInfo(xElement)}The target namespace '{allowedRule.To}' must be a single namespace.");
            }

            if (visibleMembersChild.Attribute(OfNamespaceAttributeName) != null)
            {
                throw new Exception($"{GetLineInfo(xElement)}If {VisibleMembersElementName} is embedded in a dependency specification then '{OfNamespaceAttributeName}' attribute must not be defined.");
            }

            return(ParseTypeNameSet(visibleMembersChild, TypeElementName));
        }
Exemplo n.º 3
0
 public AnalyzerConfigBuilder AddDisallowRule(NamespaceDependencyRule namespaceDependencyRule)
 {
     DisallowRules.Add(namespaceDependencyRule);
     return(this);
 }
Exemplo n.º 4
0
 public AnalyzerConfigBuilder AddAllowRule(NamespaceDependencyRule namespaceDependencyRule, TypeNameSet typeNameSet = null)
 {
     AllowRules.AddOrUnion <NamespaceDependencyRule, TypeNameSet, string>(namespaceDependencyRule, typeNameSet);
     return(this);
 }