private ProblemCollection CheckForProblems(AttributeNode attribute)
        {
            if (SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute))
            {
                // reset the hasUnmatchedMessageHandler flag for each new type
                hasUnmatchedMessageHandler = false;
                return(base.Problems);
            }

            string action = SemanticRulesUtilities.GetAttributeValue <String>(attribute, "Action");

            if (SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(attribute) &&
                !string.IsNullOrEmpty(action) &&
                action.Equals("*", StringComparison.OrdinalIgnoreCase))
            {
                // check if we already inspected another operation with unmatched message handler
                if (hasUnmatchedMessageHandler)
                {
                    Resolution resolution = base.GetResolution();
                    Problem    problem    = new Problem(resolution, attribute.SourceContext);
                    base.Problems.Add(problem);
                    return(base.Problems);
                }
                hasUnmatchedMessageHandler = true;
            }
            return(base.Problems);
        }
예제 #2
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute);

            if (SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute))
            {
                List <string> duplicated = new List <string>();
                foreach (Member member in type.Members)
                {
                    if (SemanticRulesUtilities.GetAttribute(member, OperationContractAttribute) != null)
                    {
                        if (duplicated.Contains(member.Name.Name))
                        {
                            Resolution resolution = base.GetResolution(member.FullName);
                            Problem    problem    = new Problem(resolution, type.SourceContext);
                            base.Problems.Add(problem);
                        }
                        else
                        {
                            duplicated.Add(member.Name.Name);
                        }
                    }
                }
            }
            return(base.Problems);
        }
예제 #3
0
        /// <summary>
        /// Checks the specified member.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <returns></returns>
        public override ProblemCollection Check(Member member)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(member, ServiceContractAttribute) ??
                                      SemanticRulesUtilities.GetAttribute(member, OperationContractAttribute);

            return(CheckForProblems(attribute, member));
        }
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
            AttributeNode attribute =
                SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute) ??
                SemanticRulesUtilities.GetAttribute(type, OperationContractAttribute);

            return(CheckForProblems(attribute));
        }
예제 #5
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
            // reset the class vars for each new type
            hasSessionMode = false;
            sessionMode    = SessionMode.Allowed; // Set to default value

            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute) ??
                                      SemanticRulesUtilities.GetAttribute(type, OperationContractAttribute);

            return(CheckForProblems(attribute, null));
        }
예제 #6
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(Member member)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(member, OperationBehaviorAttribute);

            if (SemanticRulesUtilities.HasAttribute <OperationBehaviorAttribute>(attribute) &&
                member.DeclaringType.NodeType != NodeType.Class)
            {
                Resolution resolution = base.GetResolution();
                Problem    problem    = new Problem(resolution, member.SourceContext);
                base.Problems.Add(problem);
            }
            return(base.Problems);
        }
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(Member member)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(member, OperationContractAttribute);

            if (SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(attribute) &&
                IsMixingMessageContractParams((Method)member))
            {
                Resolution resolution = base.GetResolution(member.Name.Name);
                Problem    problem    = new Problem(resolution, member.SourceContext);
                base.Problems.Add(problem);
            }
            return(base.Problems);
        }
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute);

            if (SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute) &&
                !IsValidCallbackContract(SemanticRulesUtilities.GetAttributeValue <TypeNode>(attribute, "CallbackContract")))
            {
                Resolution resolution = base.GetResolution();
                Problem    problem    = new Problem(resolution, attribute.SourceContext);
                base.Problems.Add(problem);
                return(base.Problems);
            }
            return(base.Problems);
        }
예제 #9
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(Member member)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(member, OperationContractAttribute);

            if (SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(attribute) &&
                SemanticRulesUtilities.GetAttributeValue <Boolean>(attribute, "IsOneWay") &&
                !string.IsNullOrEmpty(SemanticRulesUtilities.GetAttributeValue <String>(attribute, "ReplyAction")))
            {
                Resolution resolution = base.GetResolution();
                Problem    problem    = new Problem(resolution, member.SourceContext);
                base.Problems.Add(problem);
            }
            return(base.Problems);
        }
예제 #10
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute);

            if (SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute) &&
                attribute.Expressions.Count == 0)
            {
                Resolution resolution = base.GetResolution();
                Problem    problem    = new Problem(resolution, attribute.SourceContext);
                base.Problems.Add(problem);
                return(base.Problems);
            }
            return(base.Problems);
        }
예제 #11
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(Member member)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(member, OperationContractAttribute);

            if (SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(attribute) &&
                SemanticRulesUtilities.GetAttributeValue <Boolean>(attribute, "IsOneWay") &&
                HasOutParams(((Method)member)))
            {
                Resolution resolution = base.GetResolution();
                Problem    problem    = new Problem(resolution, member.SourceContext);
                base.Problems.Add(problem);
            }
            return(base.Problems);
        }
예제 #12
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute);

            if (SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute) &&
                string.IsNullOrEmpty(SemanticRulesUtilities.GetAttributeValue <string>(attribute, "Name")))
            {
                Resolution resolution = base.GetResolution();
                Problem    problem    = new Problem(resolution, attribute.SourceContext);
                base.Problems.Add(problem);
                return(base.Problems);
            }
            return(base.Problems);
        }
예제 #13
0
 /// <summary>
 /// Evaluates the rule.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="attribute">The attribute.</param>
 /// <param name="binding">The binding.</param>
 public override void EvaluateRule(TypeNode type,
                                   AttributeNode attribute, string binding)
 {
     // for further info on Sessions and bindings,
     // read: http://msdn2.microsoft.com/en-us/library/ms730879.aspx
     if ((SemanticRulesUtilities.GetAttributeValue <SessionMode>(attribute, "SessionMode") == SessionMode.Required &&
          IsSessionlessBinding(binding)) ||
         (SemanticRulesUtilities.GetAttributeValue <SessionMode>(attribute, "SessionMode") == SessionMode.NotAllowed &&
          IsSessionfullBinding(binding)))
     {
         Resolution resolution = base.GetResolution(type.FullName, binding);
         Problem    problem    = new Problem(resolution);
         base.Problems.Add(problem);
     }
 }
예제 #14
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(Member member)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(member, OperationContractAttribute);

            if (SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(attribute) &&
                SemanticRulesUtilities.GetAttributeValue <Boolean>(attribute, "IsOneWay") &&
                member.NodeType == NodeType.Method &&
                !((Method)member).ReturnType.FullName.Equals("System.Void", StringComparison.Ordinal))
            {
                Resolution resolution = base.GetResolution();
                Problem    problem    = new Problem(resolution, member.SourceContext);
                base.Problems.Add(problem);
            }
            return(base.Problems);
        }
예제 #15
0
        public override ProblemCollection Check(ModuleNode module)
        {
            if (configurationManager == null)
            {
                base.Check(module);
            }

            SemanticRulesUtilities.EvaluateContracts(
                configurationManager,
                module,
                delegate(TypeNode node, ServiceEndpointElement endpoint)
            {
                this.EvaluateTypeNode(node, endpoint.Binding);
            });

            return(base.Problems);
        }
 public override ProblemCollection Check(TypeNode type)
 {
     if (SemanticRulesUtilities.GetAttribute(type, serviceContractAttribute) != null)
     {
         // traverse each method and check if contains the OperationContractAttribute
         foreach (Member member in type.Members)
         {
             if (member.NodeType == NodeType.Method &&
                 SemanticRulesUtilities.GetAttribute(member, operationContractAttribute) == null)
             {
                 Resolution resolution = base.GetResolution(member.Name.Name);
                 Problem    problem    = new Problem(resolution, type.SourceContext);
                 base.Problems.Add(problem);
             }
         }
     }
     return(base.Problems);
 }
예제 #17
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute);

            if (SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute, "CallbackContract"))
            {
                TypeNode callbackContract = SemanticRulesUtilities.GetAttributeValue <TypeNode>(attribute, "CallbackContract");
                foreach (Member member in callbackContract.Members)
                {
                    if (member.NodeType == NodeType.Method &&
                        !SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(member))
                    {
                        Resolution resolution = base.GetResolution(member.FullName, callbackContract.FullName);
                        Problem    problem    = new Problem(resolution, attribute.SourceContext);
                        base.Problems.Add(problem);
                    }
                }
                return(base.Problems);
            }
            return(base.Problems);
        }
예제 #18
0
        protected virtual void EvaluateTypeNode(TypeNode type, string binding)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }

            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, typeof(ServiceContractAttribute));

            if (configurationManager != null)
            {
                if (SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute))
                {
                    EvaluateRule(type, attribute, binding);
                }
            }
        }
예제 #19
0
        private ProblemCollection CheckForProblems(AttributeNode attribute, Member member)
        {
            if (SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute))
            {
                // store state for check member analysis overload.
                hasSessionMode = SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute, "SessionMode");
                if (hasSessionMode)
                {
                    sessionMode = SemanticRulesUtilities.GetAttributeValue <SessionMode>(attribute, "SessionMode");
                }
                return(base.Problems);
            }

            if (SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(attribute) &&
                IsRuleViolated(attribute))
            {
                Resolution resolution = base.GetResolution(CustomizeDescription(attribute), member.Name.Name);
                Problem    problem    = new Problem(resolution, attribute.SourceContext);
                base.Problems.Add(problem);
                return(base.Problems);
            }
            return(base.Problems);
        }
예제 #20
0
 private bool HasInitiatingOrTerminatingValuesDeclared(AttributeNode attribute)
 {
     return(SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(attribute, "IsInitiating") ||
            SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(attribute, "IsTerminating"));
 }
 private bool HasMessageContractAttribute(AttributeNodeCollection attributes)
 {
     return(SemanticRulesUtilities.GetAttribute(attributes, typeof(MessageContractAttribute)) != null);
 }