Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public override bool Equals(object? obj)

public override int GetHashCode()
{
return this.Data.GetHashCode();
// JsonElement does not provide a structural hash code. ValueKind is necessarily equal
// whenever DeepEquals returns true, preserving the equality contract without recursively
// reimplementing JsonElement.DeepEquals semantics.
return this.Data.ValueKind.GetHashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@

private static EdgeId TakeEdgeId() => new(Interlocked.Increment(ref s_nextEdgeId));

[Fact]
public void Test_JsonWireSerializedValue_EqualValuesHaveEqualHashCodes()
{
// Arrange
JsonMarshaller marshaller = new();
using JsonDocument firstDocument = JsonDocument.Parse("""{"a":1,"b":[true,null]}""");
using JsonDocument secondDocument = JsonDocument.Parse("""{"a":1,"b":[true,null]}""");
JsonWireSerializedValue first = new(marshaller, firstDocument.RootElement);
JsonWireSerializedValue second = new(marshaller, secondDocument.RootElement);

// Act
bool areEqual = first.Equals(second);

// Assert
areEqual.Should().BeTrue();

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net472, windows-latest, Release, true, integration)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net472, windows-latest, Release, true, integration)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net10.0, ubuntu-latest, Release, true, integration)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net10.0, ubuntu-latest, Release, true, integration)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 50 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

'bool' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)
first.GetHashCode().Should().Be(second.GetHashCode());

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net472, windows-latest, Release, true, integration)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net472, windows-latest, Release, true, integration)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net10.0, ubuntu-latest, Release, true, integration)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net10.0, ubuntu-latest, Release, true, integration)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/JsonSerializationTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

'int' does not contain a definition for 'Should' and no accessible extension method 'Should' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)
}

internal static T RunJsonRoundtrip<T>(T value, JsonSerializerOptions? externalOptions = null, Expression<Func<T, bool>>? predicate = null)
{
JsonMarshaller marshaller = new(externalOptions);
Expand Down
Loading