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
1 change: 1 addition & 0 deletions .buildkite/DockerFile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ COPY ./tests/*.Build.props ./tests/
COPY src/*/*.?sproj ./src/
COPY tests/*/*.?sproj ./tests/
COPY benchmarks/*/*.?sproj ./benchmarks/
COPY examples/*/*.?sproj ./examples/

# this puts the project files back into original location since COPY flattens
RUN for file in $(find . -name "*.?sproj"); do echo mkdir -p $(dirname $file)/$(basename ${file%.*})/ && echo mv $file $(dirname $file)/$(basename ${file%.*})/; done
Expand Down
1 change: 1 addition & 0 deletions .ci/DockerFile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ COPY ./tests/*.Build.props ./tests/
COPY src/*/*.?sproj ./src/
COPY tests/*/*.?sproj ./tests/
COPY benchmarks/*/*.?sproj ./benchmarks/
COPY examples/*/*.?sproj ./examples/

# this puts the project files back into original location since COPY flattens
RUN for file in $(find . -name "*.?sproj"); do echo mkdir -p $(dirname $file)/$(basename ${file%.*})/ && echo mv $file $(dirname $file)/$(basename ${file%.*})/; done
Expand Down
9 changes: 9 additions & 0 deletions Elasticsearch.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.ClusterLauncher", "te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "tests\Tests\Tests.csproj", "{6FD804B2-CE80-41CB-A411-2023F34C18FE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aot", "examples\aot\aot.csproj", "{3FA9C99A-7DA0-4DF2-89C0-BDDFC97E2CB7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -103,6 +107,10 @@ Global
{6FD804B2-CE80-41CB-A411-2023F34C18FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FD804B2-CE80-41CB-A411-2023F34C18FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FD804B2-CE80-41CB-A411-2023F34C18FE}.Release|Any CPU.Build.0 = Release|Any CPU
{3FA9C99A-7DA0-4DF2-89C0-BDDFC97E2CB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FA9C99A-7DA0-4DF2-89C0-BDDFC97E2CB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FA9C99A-7DA0-4DF2-89C0-BDDFC97E2CB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FA9C99A-7DA0-4DF2-89C0-BDDFC97E2CB7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -118,6 +126,7 @@ Global
{68D1BFDC-F447-4D2C-AF81-537807636610} = {1FE49D14-216A-41EE-A177-E42BFF53E0DC}
{F6162603-D134-4121-8106-2BA4DAD7350B} = {362B2776-4B29-46AB-B237-56776B5372B6}
{6FD804B2-CE80-41CB-A411-2023F34C18FE} = {362B2776-4B29-46AB-B237-56776B5372B6}
{3FA9C99A-7DA0-4DF2-89C0-BDDFC97E2CB7} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CE74F821-B001-4C69-A58D-CF81F8B0B632}
Expand Down
59 changes: 59 additions & 0 deletions examples/aot/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;
using System.Text.Json.Serialization;

using Elastic.Clients.Elasticsearch;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;

namespace AOT;

public static class Program
{
public static void Main(string[] args)
{
var nodePool = new SingleNodePool(new Uri("http://localhost:9200"));
var settings = new ElasticsearchClientSettings(
nodePool,
sourceSerializer: (_, settings) =>
new DefaultSourceSerializer(settings, UserTypeSerializerContext.Default)
)
.DefaultMappingFor<Person>(x => x.IndexName("index"));

var client = new ElasticsearchClient(settings);

var person = new Person
{
Id = 1234,
FirstName = "Florian",
LastName = "Bernd"
};

Trace.Assert(client.Infer.Id(person) == "1234");

var indexRequest = new IndexRequest<Person>(person);
var indexRequestBody = client.ElasticsearchClientSettings.RequestResponseSerializer.SerializeToString(indexRequest);
var indexRequest2 = client.ElasticsearchClientSettings.RequestResponseSerializer.Deserialize<IndexRequest<Person>>(indexRequestBody)!;

Trace.Assert(indexRequest.Document == indexRequest2.Document);
}
}

internal sealed record Person
{
public long? Id { get; init; }
public required string FirstName { get; init; }
public required string LastName { get; init; }
public DateTimeOffset? BirthDate { get; init; }
}

[JsonSerializable(typeof(Person), GenerationMode = JsonSourceGenerationMode.Default)]
internal sealed partial class UserTypeSerializerContext :
JsonSerializerContext
{
}
17 changes: 17 additions & 0 deletions examples/aot/aot.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>

<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Elastic.Clients.Elasticsearch\Elastic.Clients.Elasticsearch.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Elastic.Transport" Version="0.9.2" />
<PackageReference Include="Elastic.Transport" Version="0.10.0" />
<PackageReference Include="PolySharp" Version="1.15.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ internal static class DynamicPropertyAccessor

// Build compiled getter delegate.

#pragma warning disable IL3050
#pragma warning disable IL2060
#pragma warning disable IL3050, IL2060
var getterDelegateFactory = MakeDelegateMethodInfo.MakeGenericMethod(type, getterMethod.ReturnType);
#pragma warning restore IL3050
#pragma warning restore IL2060
#pragma warning restore IL3050, IL2060
var genericGetterDelegate = (Func<object, object>)getterDelegateFactory.Invoke(null, [getterMethod])!;

return instance => retrieverFunc(genericGetterDelegate, instance);
Expand Down
3 changes: 3 additions & 0 deletions src/Playground/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Runtime.Serialization;
using Elastic.Clients.Elasticsearch;
using Elastic.Clients.Elasticsearch.QueryDsl;

namespace Playground
{
Expand All @@ -30,6 +31,8 @@ public class Person
public string Data { get; init; } = "NOTHING";

public DateTimeKind Enum { get; init; }

public Query? Q { get; init; }
}

public class PersonV3
Expand Down
4 changes: 2 additions & 2 deletions src/Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Elastic.Transport" Version="0.9.2" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="Elastic.Transport" Version="0.10.0" />
<PackageReference Include="System.Text.Json" Version="9.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading