Fsharp: XML-comments for function with out parameter not visible from C# project

Created on 8 Mar 2019  路  3Comments  路  Source: dotnet/fsharp

XML-comments from an F# project are not showing up in a C# project when the function in question has out parameters.

Repro steps

Github-repo with reproduction https://github.com/viktorvan/FSharpXmlCommentBugRepro

  1. Create a new F# class library dotnet new classlib --language "F#" -n FSharpProject

  2. Add a type with xml-comments:

namespace FSharpProject
open System.Runtime.InteropServices //for OutAttribute

/// <summary>
/// This is my type
/// </summary>
type MyType() =

    /// <summary>
    /// This is a method with an out parameter
    /// </summary>
    /// <param name="s">An input string</param>
    /// <param name="result">An output string</param>
    static member StaticOutParam((s : string), [<Out>] result : string byref) =
        result <- "test"
  1. Setup the project to generate doc-comments, in fsproj, add:
<GenerateDocumentationFile>true</GenerateDocumentationFile>
  1. Build the project and verify that xml-comments are generated correctly in /bin/Debug/netstandard2.0/FSharpProject.xml

  2. At this point intellisense will work from within the F# project, or from another F# project referencing the original F#-project.

  3. Create a new C# class library and reference the F# project. dotnet new classlib -n CSharpProject. dotnet add CSharpProject/CSharpProject.csproj reference FSharpProject/FSharpProject.fsproj

  4. Add a class that uses the function from the F# project:

using FSharpProject;

namespace CSharpProject
{
    public class Class1
    {
        public static void Test() 
        {
            MyType.StaticOutParam("test", out var dummy);
        }
    }
}
  1. Hovering the class MyType will show the expected intellisense documentation. Hovering over the function StaticOutParam will not show any intellisense documentation.

Expected behavior

Intellisense documentation is displayed when hovering the function in the C# project.

Actual behavior

No intellisense documentation is shown.

Known workarounds

None that I have found.

Related information

Provide any related information

  • Operating system: tested on Mac Os X 10.14.3 and Windows 10
  • Branch: N/A
  • .NET Runtime, CoreCLR or Mono Version: dotnet core sdk 2.2.104
  • Editing Tools (e.g. Visual Studio Version): tested in VsCode 1.32.1 with Ionide 3.34.0 and also Visual Studio 2017 (latest)
  • Links to F# RFCs or entries on https://github.com/fsharp/fslang-suggestions
  • Links to performance testing scripts
  • Indications of severity: This is an inconvenience, but not blocking.
Area-IDE Language Service Severity-Low bug

Most helpful comment

This is the output XML documentation:

<?xml version="1.0" encoding="utf-8"?>
<doc>
<assembly><name>FSharpProject</name></assembly>
<members>
<member name="M:FSharpProject.MyType.StaticOutParam(System.String,Microsoft.FSharp.Core.byref{System.String,Microsoft.FSharp.Core.ByRefKinds.InOut})">
 <summary>
 This is a method with an out parameter
 </summary>
 <param name="s">An input string</param>
 <param name="result">An output string</param>
</member>
</members>
</doc>

This is the documentation the C# compiler generates for the same class:

<?xml version="1.0"?>
<doc>
    <assembly>
        <name>CSharpProject</name>
    </assembly>
    <members>
        <member name="M:CSharpProject.MyType.StaticOutParam(System.String,System.String@)">
            <summary>
            This is a method with an out parameter
            </summary>
            <param name="s">An input string.</param>
            <param name="result">An output string</param>
        </member>
    </members>
</doc>

The type of the second parameter is different. The C# tooling probably looks for docs with the signature as seen in the second example.

All 3 comments

This is the output XML documentation:

<?xml version="1.0" encoding="utf-8"?>
<doc>
<assembly><name>FSharpProject</name></assembly>
<members>
<member name="M:FSharpProject.MyType.StaticOutParam(System.String,Microsoft.FSharp.Core.byref{System.String,Microsoft.FSharp.Core.ByRefKinds.InOut})">
 <summary>
 This is a method with an out parameter
 </summary>
 <param name="s">An input string</param>
 <param name="result">An output string</param>
</member>
</members>
</doc>

This is the documentation the C# compiler generates for the same class:

<?xml version="1.0"?>
<doc>
    <assembly>
        <name>CSharpProject</name>
    </assembly>
    <members>
        <member name="M:CSharpProject.MyType.StaticOutParam(System.String,System.String@)">
            <summary>
            This is a method with an out parameter
            </summary>
            <param name="s">An input string.</param>
            <param name="result">An output string</param>
        </member>
    </members>
</doc>

The type of the second parameter is different. The C# tooling probably looks for docs with the signature as seen in the second example.

BTW, it's the same the other way around:

image

Thanks, this should be an easy fix

Was this page helpful?
0 / 5 - 0 ratings