ASP.NET Web API Help Page Generates Incomplete Documentation for F # Post Types

The ASP.NET Web API Help page project does not create complete documentation for the F # record types used as parameters or result types for web API controller actions. Members are listed, but the summary information in the XML comments does not appear in the generated documentation. How to fix it?

Example

Consider the following F # record type, used as a parameter or result type for a Web API action method:

[<CLIMutable>]
type ExampleRecord = {

    /// Example property.
    Prop : int

Expected Result

The generated manual page documentation for this type should include summary information in the description column for this member.

Name β”‚ Description β”‚ Type β”‚ Additional information
═ ═ ═ β•ͺ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ══════════
Prop  β”‚ Example property. β”‚ integer β”‚ None.

, .

Name  β”‚ Description β”‚ Type    β”‚ Additional information
══════β•ͺ═════════════β•ͺ═════════β•ͺ═══════════════════════
Prop  β”‚             β”‚ integer β”‚ None.

:

  • -API Microsoft ASP.NET v5.1.1;
  • Visual Studio Professional 2013 ( 1);
  • F # 3.1.

, , , , .

+4
1

: . , , . , "${namespace}${namespace}${class}" "${namespace}${class}". , !


- , , XML- F #:

Visual Studio 2013 (, , F #), , , post-build, XML. , , . Areas/HelpPage/XmlDocumentationProvider :

public string GetDocumentation(MemberInfo member)

... :

public string GetDocumentation(MemberInfo member)
{
    string selectExpression;
    bool isRecord = FSharpType.IsRecord(member.DeclaringType, FSharpOption<BindingFlags>.None);

    if (isRecord)
    {
        // Workaround for a bug in VS 2013.1: duplicated namespace in documentation for record types.
        Regex matchTypeName = new Regex(@"(?<namespace>(?:[_\p{L}\p{Nl}]+\.)*)(?<class>[_\p{L}\p{Nl}]+)$");
        string classExpression = matchTypeName.Replace(GetTypeName(member.DeclaringType), "${namespace}${namespace}${class}");
        string memberExpression = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", classExpression, member.Name);
        selectExpression = String.Format(CultureInfo.InvariantCulture, FieldExpression, memberExpression);
    }
    else
    {
        string expression = member.MemberType == MemberTypes.Field ? FieldExpression : PropertyExpression;
        string memberName = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", GetTypeName(member.DeclaringType), member.Name);
        selectExpression = String.Format(CultureInfo.InvariantCulture, expression, memberName);
    }

    XPathNavigator propertyNode = _documentNavigator.SelectSingleNode(selectExpression);
    return GetTagValue(propertyNode, "summary");
}

! , -API, , . .

+4

Source: https://habr.com/ru/post/1531217/


All Articles