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);
        }
        /// <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);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
     }
 }
Beispiel #7
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);
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }