Skip to content

Recieving CS0121: The call is ambiguous... compilation error with release 8.7.0 #3103

@JSkimming

Description

@JSkimming

Description

The latest release 8.7.0, which introduces specialisations for JsonNode and JsonArray, unfortunately introduces a compile error where existing assertions were made against JsonObject and potentially any class derived from JsonNode.

I've raised PR #3102 to initially demonstrate the issue in the first commit, as well as a proposed solution in the second commit of the same PR.

Reproduction Steps

// Arrange
JsonObject jsonObject = null;

// Act & Assert
jsonObject.Should().BeNull();

Expected behavior

The code should compile.

Actual behavior

Receiving the compile error.

error CS0121: The call is ambiguous between the following methods or properties: 'AssertionExtensions.Should<TKey, TValue>(IDictionary<TKey, TValue>)' and 'AssertionExtensions.Should(JsonNode)'

Regression?

Yes, it compiled before the introduction of the JsonNode specialisations in release 8.7.0.

Known Workarounds

Downcasting will probably work.

Configuration

Using v8.7.0 on .NET 9.0

Other information

No response

Are you willing to help with a pull-request?

Yes, please assign this issue to me.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions