public void GetMemberNameForProperty_ReturnsCorrectXmlCommentMemberName_ForGivenMemberInfo(
            Type declaringType,
            string fieldOrPropertyName,
            string expectedMemberName
            )
        {
            var memberInfo = declaringType.GetMember(fieldOrPropertyName)[0];

            var memberName = XmlCommentsMemberNameHelper.GetMemberNameForMember(memberInfo);

            _output.WriteLine(expectedMemberName);
            _output.WriteLine(memberName);
            Assert.Equal(expectedMemberName, memberName);
        }
示例#2
0
 private void ApplyPropertiesXmlToPropertyParameters(IList <IParameter> parameters, ApiDescription apiDescription)
 {
     if (parameters == null)
     {
         return;
     }
     foreach (IParameter parameter1 in (IEnumerable <IParameter>)parameters)
     {
         IParameter parameter = parameter1;
         ApiParameterDescription parameterDescription = apiDescription.ParameterDescriptions.Where <ApiParameterDescription>((Func <ApiParameterDescription, bool>)(p =>
         {
             if (p.ModelMetadata?.ContainerType != (Type)null)
             {
                 return(p.ModelMetadata?.PropertyName != null);
             }
             return(false);
         })).FirstOrDefault <ApiParameterDescription>((Func <ApiParameterDescription, bool>)(p => parameter.Name.Equals(p.Name, StringComparison.OrdinalIgnoreCase)));
         if (parameterDescription != null)
         {
             ModelMetadata modelMetadata = parameterDescription.ModelMetadata;
             MemberInfo    memberInfo    = ((IEnumerable <MemberInfo>)modelMetadata.ContainerType.GetMember(modelMetadata.PropertyName)).FirstOrDefault <MemberInfo>();
             if (!(memberInfo == (MemberInfo)null))
             {
                 XPathNavigator xpathNavigator1 = this._xmlNavigator.SelectSingleNode(string.Format("/doc/members/member[@name='{0}']", (object)XmlCommentsMemberNameHelper.GetMemberNameForMember(memberInfo)));
                 if (xpathNavigator1 != null)
                 {
                     XPathNavigator xpathNavigator2 = xpathNavigator1.SelectSingleNode("summary");
                     if (xpathNavigator2 != null)
                     {
                         parameter.Description = XmlCommentsTextHelper.Humanize(xpathNavigator2.InnerXml);
                     }
                 }
             }
         }
     }
 }