dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.93k stars 786 forks source link

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

Open viktorvan opened 5 years ago

viktorvan commented 5 years ago

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

///

/// This is my type /// 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"

3. Setup the project to generate doc-comments, in fsproj, add:
true

4. Build the project and verify that xml-comments are generated correctly in /bin/Debug/netstandard2.0/FSharpProject.xml

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

6. 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`

5. Add a class that uses the function from the F# project:
```csharp
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

inosik commented 5 years ago

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.

inosik commented 5 years ago

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

image

dsyme commented 4 years ago

Thanks, this should be an easy fix