Skip to content

Problem consuming C# API with default value for parameter #13519

@wallymathieu

Description

@wallymathieu

Please provide a succinct description of the issue.

Repro steps

Provide the steps required to reproduce the problem:

  1. Load a C# library that defines a method that takes a default value
  2. From F# call the method without specifying the value3.

Expected behavior

Expects that the following snippet compiles:

#r "nuget: FluentAssertions.Json, 6.1.0"
open FluentAssertions.Json
open Newtonsoft.Json.Linq
let assertJsonEqual expected actual =
    let expectedToken = JToken.Parse expected
    let actualToken = JToken.Parse actual
    actualToken.Should().BeEquivalentTo(expectedToken) |> ignore

Actual behavior

The member or object constructor 'BeEquivalentTo' does not take 1 argument(s). An overload was found taking 3 arguments.F# Compiler505

Known workarounds

A workaround is to specify the default values explicitly:

#r "nuget: FluentAssertions.Json, 6.1.0"
open FluentAssertions.Json
open Newtonsoft.Json.Linq
let assertJsonEqual expected actual =
    let expectedToken = JToken.Parse expected
    let actualToken = JToken.Parse actual
    actualToken.Should().BeEquivalentTo(expected = expectedToken, because = "") |> ignore

Related information

Provide any related information (optional):

  • Operating systems: Windows 11, macOS Monterey 12.4
  • .NET Runtime kinds: .NET Core 6.0.300 , 3.1.421
  • Editing Tools: Rider 2022.1.2, Visual Studio Community 2022 for Mac Preview (17.3 build 198), Visual Studio Code and Ionide

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

New

Relationships

None yet

Development

No branches or pull requests

Issue actions