Exemple #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);
        }
Exemple #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));
        }
 public AnalyzerConfigBuilder AddDisallowRule(NamespaceDependencyRule namespaceDependencyRule)
 {
     DisallowRules.Add(namespaceDependencyRule);
     return(this);
 }
 public AnalyzerConfigBuilder AddAllowRule(NamespaceDependencyRule namespaceDependencyRule, TypeNameSet typeNameSet = null)
 {
     AllowRules.AddOrUnion <NamespaceDependencyRule, TypeNameSet, string>(namespaceDependencyRule, typeNameSet);
     return(this);
 }