Skip to content
Merged
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 @@ -16,7 +16,8 @@ public class HandleNestTypesOnSourceJsonConverter : JsonConverter
typeof(CompletionField),
typeof(Attachment),
typeof(ILazyDocument),
typeof(GeoCoordinate)
typeof(GeoCoordinate),
typeof(GeoLocation)
};

private readonly IElasticsearchSerializer _builtInSerializer;
Expand Down
31 changes: 31 additions & 0 deletions src/Tests/Tests.Reproduce/GitHubIssue3981.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Text;
using Elastic.Xunit.XunitPlumbing;
using FluentAssertions;
using Nest;
using Tests.Core.Client;

namespace Tests.Reproduce
{
public class GitHubIssue3981
{
// This test always passes because the JsonPropertyAttribute on
// the GeoLocation type are recognized by the JsonNetSerializer when used in tests, because the
// IL rewriting to internalize Json.NET in the client happens *after* tests are run.
[U]
public void JsonNetSerializerSerializesGeoLocation()
{
var document = new Document
{
Location = new GeoLocation(45, 45)
};

var indexResponse = TestClient.InMemoryWithJsonNetSerializer.IndexDocument(document);
Encoding.UTF8.GetString(indexResponse.ApiCall.RequestBodyInBytes).Should().Contain("\"lat\"").And.Contain("\"lon\"");
}

private class Document
{
public GeoLocation Location { get; set; }
}
}
}