diff --git a/.editorconfig b/.editorconfig index 50c3fec..53b19ae 100644 --- a/.editorconfig +++ b/.editorconfig @@ -135,6 +135,12 @@ resharper_redundant_argument_default_value_highlighting=do_not_show resharper_redundant_type_arguments_of_method_highlighting=do_not_show resharper_switch_expression_handles_some_known_enum_values_with_exception_in_default_highlighting=error +resharper_arrange_type_member_modifiers_highlighting=none; + +[src/api/Elastic.Transport/Components/Serialization/**.cs] +dotnet_diagnostic.IL3050.severity = none +dotnet_diagnostic.IL2026.severity = none + [Jenkinsfile] indent_style = space indent_size = 2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00658a2..5287498 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: run: dotnet publish examples/transport-aot-example - name: Invoke AOT - run: ./examples/transport-aot-example/bin/Release/net8.0/${{ matrix.os.folder }}/${{ matrix.os.binary }} + run: .artifacts/publish/transport-aot-example/release/${{ matrix.os.binary }} build: runs-on: ubuntu-latest diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 1330bdc..15e3724 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -36,7 +36,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 1 @@ -55,7 +55,7 @@ jobs: ${{ runner.os }}-nuget - name: Setup dotnet - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: global-json-file: ./global.json @@ -63,14 +63,4 @@ jobs: name: Build - run: ./build.bat test -s true - name: Test - - - name: Test Results - if: success() || failure() - uses: mikepenz/action-junit-report@v4 - with: - report_paths: 'build/output/junit-*.xml' - github_token: ${{ secrets.GITHUB_TOKEN }} - fail_on_failure: true - require_tests: true - check_name: Test Results \ No newline at end of file + name: Test \ No newline at end of file diff --git a/.gitignore b/.gitignore index f5250c7..dc977d9 100644 --- a/.gitignore +++ b/.gitignore @@ -80,4 +80,5 @@ src/packages/ BenchmarkDotNet.Artifacts *.received.* -/.ionide/symbolCache.db \ No newline at end of file +/.ionide/symbolCache.db +.artifacts \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index e08e7f0..d81e267 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,8 +4,8 @@ $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat)) - canary - 0.1 + canary.0 + 0.2 latest true @@ -13,11 +13,14 @@ false true $(SolutionRoot)\build\keys\keypair.snk + true + $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.sh)) + $(MSBuildThisFileDirectory).artifacts - + all runtime; build; native; contentfiles; analyzers diff --git a/Elastic.Transport.sln b/Elastic.Transport.sln deleted file mode 100644 index 411c7c5..0000000 --- a/Elastic.Transport.sln +++ /dev/null @@ -1,123 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.4.33213.308 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "scripts", "build\scripts\scripts.fsproj", "{4779DD6F-AE49-4A80-9F67-D9F2DB05E557}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7610B796-BB3E-4CB2-8296-79BBFF6D23FC}" - ProjectSection(SolutionItems) = preProject - src\Directory.Build.props = src\Directory.Build.props - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{3582B07D-C2B0-49CC-B676-EAF806EB010E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{441B3323-3651-4B6E-95B3-7CD43E5E223A}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - .gitattributes = .gitattributes - .gitignore = .gitignore - build.bat = build.bat - build.sh = build.sh - .github\workflows\ci.yml = .github\workflows\ci.yml - Directory.Build.props = Directory.Build.props - global.json = global.json - license.txt = license.txt - README.md = README.md - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Transport", "src\Elastic.Transport\Elastic.Transport.csproj", "{AEA02F7D-682E-4124-B12B-3543938C1A03}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Transport.VirtualizedCluster", "src\Elastic.Transport.VirtualizedCluster\Elastic.Transport.VirtualizedCluster.csproj", "{9B54DFFE-2B86-4F04-A9C4-5DE12FBADD77}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Transport.Tests", "tests\Elastic.Transport.Tests\Elastic.Transport.Tests.csproj", "{79EAF3D6-87AE-49F0-8928-07EBA2876A75}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{BBB0AC81-F09D-4895-84E2-7E933D608E78}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Transport.Benchmarks", "benchmarks\Elastic.Transport.Benchmarks\Elastic.Transport.Benchmarks.csproj", "{DABC7F0B-6174-4B2D-8F17-5E36C1CE43EF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Transport.IntegrationTests", "tests\Elastic.Transport.IntegrationTests\Elastic.Transport.IntegrationTests.csproj", "{3B27DE76-1188-4078-8828-67AFD39BAC10}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Transport.Profiling", "benchmarks\Elastic.Transport.Profiling\Elastic.Transport.Profiling.csproj", "{ED4E89BE-FBE9-4876-979C-63A0E3BC5419}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Playground", "Playground\Playground.csproj", "{5EE4DC72-B337-448B-802A-6158F4D90667}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Elasticsearch.IntegrationTests", "tests\Elastic.Elasticsearch.IntegrationTests\Elastic.Elasticsearch.IntegrationTests.csproj", "{317C118F-FA1E-499A-B7F2-DC932DE66CB8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Transport.Tests.Shared", "tests\Elastic.Transport.Tests.Shared\Elastic.Transport.Tests.Shared.csproj", "{13A2597D-F50C-4D7F-ADA9-716991C8E9DE}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{54C8CB5B-11E4-48CB-8055-D8ACE8EFF0AB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "transport-aot-example", "examples\transport-aot-example\transport-aot-example.csproj", "{29D5F68D-BABF-4738-9A9E-F2FE2DFFBEA8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4779DD6F-AE49-4A80-9F67-D9F2DB05E557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4779DD6F-AE49-4A80-9F67-D9F2DB05E557}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4779DD6F-AE49-4A80-9F67-D9F2DB05E557}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4779DD6F-AE49-4A80-9F67-D9F2DB05E557}.Release|Any CPU.Build.0 = Release|Any CPU - {AEA02F7D-682E-4124-B12B-3543938C1A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AEA02F7D-682E-4124-B12B-3543938C1A03}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AEA02F7D-682E-4124-B12B-3543938C1A03}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AEA02F7D-682E-4124-B12B-3543938C1A03}.Release|Any CPU.Build.0 = Release|Any CPU - {9B54DFFE-2B86-4F04-A9C4-5DE12FBADD77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9B54DFFE-2B86-4F04-A9C4-5DE12FBADD77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9B54DFFE-2B86-4F04-A9C4-5DE12FBADD77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9B54DFFE-2B86-4F04-A9C4-5DE12FBADD77}.Release|Any CPU.Build.0 = Release|Any CPU - {79EAF3D6-87AE-49F0-8928-07EBA2876A75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {79EAF3D6-87AE-49F0-8928-07EBA2876A75}.Debug|Any CPU.Build.0 = Debug|Any CPU - {79EAF3D6-87AE-49F0-8928-07EBA2876A75}.Release|Any CPU.ActiveCfg = Release|Any CPU - {79EAF3D6-87AE-49F0-8928-07EBA2876A75}.Release|Any CPU.Build.0 = Release|Any CPU - {DABC7F0B-6174-4B2D-8F17-5E36C1CE43EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DABC7F0B-6174-4B2D-8F17-5E36C1CE43EF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DABC7F0B-6174-4B2D-8F17-5E36C1CE43EF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DABC7F0B-6174-4B2D-8F17-5E36C1CE43EF}.Release|Any CPU.Build.0 = Release|Any CPU - {3B27DE76-1188-4078-8828-67AFD39BAC10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B27DE76-1188-4078-8828-67AFD39BAC10}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B27DE76-1188-4078-8828-67AFD39BAC10}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B27DE76-1188-4078-8828-67AFD39BAC10}.Release|Any CPU.Build.0 = Release|Any CPU - {ED4E89BE-FBE9-4876-979C-63A0E3BC5419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED4E89BE-FBE9-4876-979C-63A0E3BC5419}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED4E89BE-FBE9-4876-979C-63A0E3BC5419}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED4E89BE-FBE9-4876-979C-63A0E3BC5419}.Release|Any CPU.Build.0 = Release|Any CPU - {5EE4DC72-B337-448B-802A-6158F4D90667}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5EE4DC72-B337-448B-802A-6158F4D90667}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5EE4DC72-B337-448B-802A-6158F4D90667}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5EE4DC72-B337-448B-802A-6158F4D90667}.Release|Any CPU.Build.0 = Release|Any CPU - {317C118F-FA1E-499A-B7F2-DC932DE66CB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {317C118F-FA1E-499A-B7F2-DC932DE66CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {317C118F-FA1E-499A-B7F2-DC932DE66CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {317C118F-FA1E-499A-B7F2-DC932DE66CB8}.Release|Any CPU.Build.0 = Release|Any CPU - {13A2597D-F50C-4D7F-ADA9-716991C8E9DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {13A2597D-F50C-4D7F-ADA9-716991C8E9DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {13A2597D-F50C-4D7F-ADA9-716991C8E9DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {13A2597D-F50C-4D7F-ADA9-716991C8E9DE}.Release|Any CPU.Build.0 = Release|Any CPU - {29D5F68D-BABF-4738-9A9E-F2FE2DFFBEA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {29D5F68D-BABF-4738-9A9E-F2FE2DFFBEA8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {29D5F68D-BABF-4738-9A9E-F2FE2DFFBEA8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {29D5F68D-BABF-4738-9A9E-F2FE2DFFBEA8}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {4779DD6F-AE49-4A80-9F67-D9F2DB05E557} = {441B3323-3651-4B6E-95B3-7CD43E5E223A} - {AEA02F7D-682E-4124-B12B-3543938C1A03} = {7610B796-BB3E-4CB2-8296-79BBFF6D23FC} - {9B54DFFE-2B86-4F04-A9C4-5DE12FBADD77} = {7610B796-BB3E-4CB2-8296-79BBFF6D23FC} - {79EAF3D6-87AE-49F0-8928-07EBA2876A75} = {3582B07D-C2B0-49CC-B676-EAF806EB010E} - {DABC7F0B-6174-4B2D-8F17-5E36C1CE43EF} = {BBB0AC81-F09D-4895-84E2-7E933D608E78} - {3B27DE76-1188-4078-8828-67AFD39BAC10} = {3582B07D-C2B0-49CC-B676-EAF806EB010E} - {ED4E89BE-FBE9-4876-979C-63A0E3BC5419} = {BBB0AC81-F09D-4895-84E2-7E933D608E78} - {5EE4DC72-B337-448B-802A-6158F4D90667} = {7610B796-BB3E-4CB2-8296-79BBFF6D23FC} - {317C118F-FA1E-499A-B7F2-DC932DE66CB8} = {3582B07D-C2B0-49CC-B676-EAF806EB010E} - {13A2597D-F50C-4D7F-ADA9-716991C8E9DE} = {3582B07D-C2B0-49CC-B676-EAF806EB010E} - {29D5F68D-BABF-4738-9A9E-F2FE2DFFBEA8} = {54C8CB5B-11E4-48CB-8055-D8ACE8EFF0AB} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7F60C4BB-6216-4E50-B1E4-9C38EB484843} - EndGlobalSection -EndGlobal diff --git a/Elastic.Transport.slnx b/Elastic.Transport.slnx new file mode 100644 index 0000000..586462f --- /dev/null +++ b/Elastic.Transport.slnx @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Playground/Playground.csproj b/Playground/Playground.csproj index 9279f59..b4f838b 100644 --- a/Playground/Playground.csproj +++ b/Playground/Playground.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 enable enable true diff --git a/benchmarks/Elastic.Transport.Benchmarks/Elastic.Transport.Benchmarks.csproj b/benchmarks/Elastic.Transport.Benchmarks/Elastic.Transport.Benchmarks.csproj index 9020580..2ca1095 100644 --- a/benchmarks/Elastic.Transport.Benchmarks/Elastic.Transport.Benchmarks.csproj +++ b/benchmarks/Elastic.Transport.Benchmarks/Elastic.Transport.Benchmarks.csproj @@ -3,11 +3,11 @@ Exe false - net8.0 + net10.0 - + diff --git a/benchmarks/Elastic.Transport.Benchmarks/Program.cs b/benchmarks/Elastic.Transport.Benchmarks/Program.cs index f511b65..83490a7 100644 --- a/benchmarks/Elastic.Transport.Benchmarks/Program.cs +++ b/benchmarks/Elastic.Transport.Benchmarks/Program.cs @@ -2,11 +2,11 @@ // 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 BenchmarkDotNet.Columns; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Diagnosers; using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; +using Perfolizer.Metrology; namespace Elastic.Transport.Benchmarks { diff --git a/benchmarks/Elastic.Transport.Profiling/Elastic.Transport.Profiling.csproj b/benchmarks/Elastic.Transport.Profiling/Elastic.Transport.Profiling.csproj index 64bebbe..5673d91 100644 --- a/benchmarks/Elastic.Transport.Profiling/Elastic.Transport.Profiling.csproj +++ b/benchmarks/Elastic.Transport.Profiling/Elastic.Transport.Profiling.csproj @@ -2,11 +2,11 @@ Exe - net8.0 + net10.0 - + diff --git a/build/scripts/Paths.fs b/build/scripts/Paths.fs index c0b858e..4d797c7 100644 --- a/build/scripts/Paths.fs +++ b/build/scripts/Paths.fs @@ -18,7 +18,7 @@ let GenerateApiChanges = false let Root = let mutable dir = DirectoryInfo(".") - while dir.GetFiles("*.sln").Length = 0 do dir <- dir.Parent + while dir.GetFiles("*.slnx").Length = 0 do dir <- dir.Parent Environment.CurrentDirectory <- dir.FullName dir diff --git a/build/scripts/Program.fs b/build/scripts/Program.fs index a574d9a..f7a2341 100644 --- a/build/scripts/Program.fs +++ b/build/scripts/Program.fs @@ -30,7 +30,8 @@ let main argv = Targets.Setup parsed arguments let swallowTypes = [typeof; typeof] - Targets.RunTargetsAndExit - ([target], (fun e -> swallowTypes |> List.contains (e.GetType()) ), ":") + task { + return! Targets.RunTargetsAndExitAsync([ target ], (fun e -> swallowTypes |> List.contains (e.GetType())), (fun _ -> ":"), null, null) + } |> Async.AwaitTask |> Async.RunSynchronously 0 diff --git a/build/scripts/Targets.fs b/build/scripts/Targets.fs index 3b490f6..a7a00ae 100644 --- a/build/scripts/Targets.fs +++ b/build/scripts/Targets.fs @@ -25,25 +25,20 @@ let getOS = | _ -> Windows let execWithTimeout binary args timeout = - let opts = - ExecArguments(binary, args |> List.map (sprintf "\"%s\"") |> List.toArray) + let opts = ExecArguments(binary, args |> List.toArray, Timeout=timeout) let options = args |> String.concat " " printfn ":: Running command: %s %s" binary options - let r = Proc.Exec(opts, timeout) - - match r.HasValue with - | true -> r.Value - | false -> failwithf "invocation of `%s` timed out" binary + Proc.Exec(opts) let exec binary args = - execWithTimeout binary args (TimeSpan.FromMinutes 10) + execWithTimeout binary args (Nullable(TimeSpan.FromMinutes 10.)) let private restoreTools = lazy(exec "dotnet" ["tool"; "restore"]) let private currentVersion = lazy( restoreTools.Value |> ignore - let r = Proc.Start("dotnet", "minver", "--default-pre-release-phase", "canary", "-m", "0.1") - let o = r.ConsoleOut |> Seq.find (fun l -> not(l.Line.StartsWith("MinVer:"))) + let r = Proc.Start("dotnet", "minver", "-p", "canary.0", "-m", "0.1") + let o = r.ConsoleOut |> Seq.find (fun l -> not(l.Line.StartsWith "MinVer:")) o.Line ) let private currentVersionInformational = @@ -67,11 +62,9 @@ let private pristineCheck (arguments:ParseResults) = | _ -> failwithf "The checkout folder has pending changes, aborting" let private test (arguments:ParseResults) = - let junitOutput = Path.Combine(Paths.Output.FullName, "junit-{assembly}-{framework}-test-results.xml") - let loggerPathArgs = sprintf "LogFilePath=%s" junitOutput - let loggerArg = sprintf "--logger:\"junit;%s\"" loggerPathArgs + let loggerArg = "--logger:GithubActions" let tfmArgs = - if getOS = OS.Windows then [] else ["-f"; "net8.0"] + if getOS = OS.Windows then [] else ["-f"; "net10.0"] exec "dotnet" (["test"; "-c"; "Release"; loggerArg] @ tfmArgs) |> ignore let private generatePackages (arguments:ParseResults) = @@ -101,11 +94,16 @@ let private generateApiChanges (arguments:ParseResults) = let outputFile = let f = sprintf "breaking-changes-%s.md" p Path.Combine(output, f) + let directory = + match p with + | "Elastic.Transport.VirtualizedCluster" -> $".artifacts/bin/%s{p}/release" + | _ -> $".artifacts/bin/%s{p}/release_%s{Paths.MainTFM}" + let args = [ "assembly-differ" (sprintf "previous-nuget|%s|%s|%s" p currentVersion Paths.MainTFM); - (sprintf "directory|src/%s/bin/Release/%s" p Paths.MainTFM); + (sprintf "directory|%s" directory); "-a"; "true"; "--target"; p; "-f"; "github-comment"; "--output"; outputFile ] diff --git a/build/scripts/scripts.fsproj b/build/scripts/scripts.fsproj index 6adfd3b..fe26d10 100644 --- a/build/scripts/scripts.fsproj +++ b/build/scripts/scripts.fsproj @@ -2,13 +2,13 @@ Exe - net8.0 + net10.0 false - - + + diff --git a/dotnet-tools.json b/dotnet-tools.json index 9348a47..6a2e0b1 100644 --- a/dotnet-tools.json +++ b/dotnet-tools.json @@ -3,28 +3,32 @@ "isRoot": true, "tools": { "minver-cli": { - "version": "2.5.0", + "version": "6.0.0", "commands": [ "minver" - ] + ], + "rollForward": false }, "assembly-differ": { - "version": "0.15.0", + "version": "0.17.0", "commands": [ "assembly-differ" - ] + ], + "rollForward": false }, "release-notes": { - "version": "0.6.0", + "version": "0.10.0", "commands": [ "release-notes" - ] + ], + "rollForward": false }, "nupkg-validator": { - "version": "0.6.0", + "version": "0.10.1", "commands": [ "nupkg-validator" - ] + ], + "rollForward": false } } } \ No newline at end of file diff --git a/examples/transport-aot-example/transport-aot-example.csproj b/examples/transport-aot-example/transport-aot-example.csproj index ef021e3..1e3b068 100644 --- a/examples/transport-aot-example/transport-aot-example.csproj +++ b/examples/transport-aot-example/transport-aot-example.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 transport_aot_example enable enable diff --git a/global.json b/global.json index 60b4c02..69e101b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100", + "version": "10.0.100", "rollForward": "latestMinor", "allowPrerelease": false } diff --git a/src/Elastic.Transport.VirtualizedCluster/Elastic.Transport.VirtualizedCluster.csproj b/src/Elastic.Transport.VirtualizedCluster/Elastic.Transport.VirtualizedCluster.csproj index 7527c3d..729a371 100644 --- a/src/Elastic.Transport.VirtualizedCluster/Elastic.Transport.VirtualizedCluster.csproj +++ b/src/Elastic.Transport.VirtualizedCluster/Elastic.Transport.VirtualizedCluster.csproj @@ -17,7 +17,4 @@ - - - diff --git a/src/Elastic.Transport/Configuration/RequestConfigurationDescriptor.cs b/src/Elastic.Transport/Configuration/RequestConfigurationDescriptor.cs index 33bb302..7dfbcd6 100644 --- a/src/Elastic.Transport/Configuration/RequestConfigurationDescriptor.cs +++ b/src/Elastic.Transport/Configuration/RequestConfigurationDescriptor.cs @@ -5,6 +5,8 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.IO; +using System.Net; using System.Security.Cryptography.X509Certificates; using Elastic.Transport.Extensions; @@ -70,7 +72,7 @@ public RequestConfigurationDescriptor(IRequestConfiguration config) private bool? _enableHttpCompression; private Uri? _forceNode; private int? _maxRetries; - private TimeSpan? _maxRetryTimeout; + private TimeSpan? _maxRetryTimeout; private string? _opaqueId; private bool? _parseAllHeaders; private TimeSpan? _pingTimeout; @@ -232,7 +234,11 @@ public RequestConfigurationDescriptor ClientCertificate(X509Certificate certific /// public RequestConfigurationDescriptor ClientCertificate(string certificatePath) => +#if NET10_0_OR_GREATER + ClientCertificates(new X509Certificate2Collection { X509CertificateLoader.LoadCertificateFromFile(certificatePath) }); +#else ClientCertificates(new X509Certificate2Collection { new X509Certificate(certificatePath) }); +#endif /// public RequestConfigurationDescriptor TransferEncodingChunked(bool transferEncodingChunked = true) diff --git a/src/Elastic.Transport/Configuration/TransportConfigurationDescriptor.cs b/src/Elastic.Transport/Configuration/TransportConfigurationDescriptor.cs index b634711..3933ee9 100644 --- a/src/Elastic.Transport/Configuration/TransportConfigurationDescriptor.cs +++ b/src/Elastic.Transport/Configuration/TransportConfigurationDescriptor.cs @@ -8,6 +8,7 @@ using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; +using System.IO; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.Threading; @@ -506,7 +507,11 @@ public T ClientCertificate(X509Certificate certificate) => /// public T ClientCertificate(string certificatePath) => +#if NET10_0_OR_GREATER + Assign(new X509Certificate2Collection { X509CertificateLoader.LoadCertificateFromFile(certificatePath) }, static (a, v) => a._clientCertificates = v); +#else Assign(new X509Certificate2Collection { new X509Certificate(certificatePath) }, static (a, v) => a._clientCertificates = v); +#endif /// public T SkipDeserializationForStatusCodes(params int[] statusCodes) => diff --git a/src/Elastic.Transport/Elastic.Transport.csproj b/src/Elastic.Transport/Elastic.Transport.csproj index 2483422..7e5cf82 100644 --- a/src/Elastic.Transport/Elastic.Transport.csproj +++ b/src/Elastic.Transport/Elastic.Transport.csproj @@ -11,15 +11,14 @@ annotations true true - netstandard2.0;netstandard2.1;net462;net8.0 + netstandard2.0;netstandard2.1;net462;net8.0;net10.0 false - + true - + true @@ -39,13 +38,12 @@ - + - diff --git a/src/Elastic.Transport/Responses/Dynamic/DynamicValue.cs b/src/Elastic.Transport/Responses/Dynamic/DynamicValue.cs index 4ec018d..0fca65a 100644 --- a/src/Elastic.Transport/Responses/Dynamic/DynamicValue.cs +++ b/src/Elastic.Transport/Responses/Dynamic/DynamicValue.cs @@ -704,6 +704,7 @@ public override bool Equals(object compareValue) /// /// The result of the binary operation. [UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode", Justification = "Manually verified")] + [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "We always provide a static JsonTypeInfoResolver")] public override bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result) { result = null; diff --git a/tests/Elastic.Elasticsearch.IntegrationTests/Elastic.Elasticsearch.IntegrationTests.csproj b/tests/Elastic.Elasticsearch.IntegrationTests/Elastic.Elasticsearch.IntegrationTests.csproj index 791914f..86e7ad4 100644 --- a/tests/Elastic.Elasticsearch.IntegrationTests/Elastic.Elasticsearch.IntegrationTests.csproj +++ b/tests/Elastic.Elasticsearch.IntegrationTests/Elastic.Elasticsearch.IntegrationTests.csproj @@ -1,7 +1,7 @@ - net8.0 + net10.0 enable enable false @@ -9,20 +9,19 @@ - - - - runtime; build; native; contentfiles; analyzers; buildtransitive + all + runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - + + + diff --git a/tests/Elastic.Transport.IntegrationTests/Elastic.Transport.IntegrationTests.csproj b/tests/Elastic.Transport.IntegrationTests/Elastic.Transport.IntegrationTests.csproj index 1778621..5f6dfb4 100644 --- a/tests/Elastic.Transport.IntegrationTests/Elastic.Transport.IntegrationTests.csproj +++ b/tests/Elastic.Transport.IntegrationTests/Elastic.Transport.IntegrationTests.csproj @@ -1,30 +1,29 @@ - net8.0 + net10.0 True false CS8002;xUnit1041 - - - - runtime; build; native; contentfiles; analyzers; buildtransitive + all + runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - + + + + + diff --git a/tests/Elastic.Transport.IntegrationTests/Http/ApiCompatibilityHeaderTests.cs b/tests/Elastic.Transport.IntegrationTests/Http/ApiCompatibilityHeaderTests.cs index fd8c162..60d8331 100644 --- a/tests/Elastic.Transport.IntegrationTests/Http/ApiCompatibilityHeaderTests.cs +++ b/tests/Elastic.Transport.IntegrationTests/Http/ApiCompatibilityHeaderTests.cs @@ -13,10 +13,8 @@ namespace Elastic.Transport.IntegrationTests.Http; -public class ApiCompatibilityHeaderTests : AssemblyServerTestsBase +public class ApiCompatibilityHeaderTests(TestServerFixture instance) : AssemblyServerTestsBase(instance) { - public ApiCompatibilityHeaderTests(TransportTestServer instance) : base(instance) { } - [Fact] public async Task AddsExpectedVendorInformationForRestApiCompaitbility() { @@ -38,7 +36,7 @@ public async Task AddsExpectedVendorInformationForRestApiCompaitbility() var config = new TransportConfiguration(nodePool, requestInvoker, productRegistration: new ElasticsearchProductRegistration(typeof(Clients.Elasticsearch.ElasticsearchClient))); var transport = new DistributedTransport(config); - var response = await transport.PostAsync("/metaheader", PostData.String("{}")); + var response = await transport.PostAsync("/metaheader", PostData.String("{}"), cancellationToken: TestContext.Current.CancellationToken); } } diff --git a/tests/Elastic.Transport.IntegrationTests/Http/TransferEncodingChunckedTests.cs b/tests/Elastic.Transport.IntegrationTests/Http/TransferEncodingChunckedTests.cs index b3491c3..d51ec20 100644 --- a/tests/Elastic.Transport.IntegrationTests/Http/TransferEncodingChunckedTests.cs +++ b/tests/Elastic.Transport.IntegrationTests/Http/TransferEncodingChunckedTests.cs @@ -21,7 +21,9 @@ public class ChunkedController : ControllerBase public Task Post([FromBody]JsonElement body) => Task.FromResult(body); } - public class TransferEncodingChunkedTests(TransportTestServer instance) : AssemblyServerTestsBase(instance) + public class NonParallelCollection { } + [CollectionDefinition(nameof(NonParallelCollection), DisableParallelization = true)] + public class TransferEncodingChunkedTests(TestServerFixture instance) : AssemblyServerTestsBase(instance) { private const string BodyString = "{\"query\":{\"match_all\":{}}}"; private static readonly PostData Body = PostData.String(BodyString); @@ -44,8 +46,7 @@ private ITransport Setup( config = disableAutomaticProxyDetection.HasValue ? config with { DisableAutomaticProxyDetection = disableAutomaticProxyDetection.Value } - //make sure we the requests in debugging proxy - : TransportTestServer.RerouteToProxyIfNeeded(config); + : config; return new DistributedTransport(config); } diff --git a/tests/Elastic.Transport.IntegrationTests/OpenTelemetry/OpenTelemetryTests.cs b/tests/Elastic.Transport.IntegrationTests/OpenTelemetry/OpenTelemetryTests.cs index 87fbc26..9a55231 100644 --- a/tests/Elastic.Transport.IntegrationTests/OpenTelemetry/OpenTelemetryTests.cs +++ b/tests/Elastic.Transport.IntegrationTests/OpenTelemetry/OpenTelemetryTests.cs @@ -26,7 +26,7 @@ public class OpenTelemetryTests : AssemblyServerTestsBase internal const string Cluster = "e9106fc68e3044f0b1475b04bf4ffd5f"; internal const string Instance = "instance-0000000001"; - public OpenTelemetryTests(TransportTestServer instance) : base(instance) { } + public OpenTelemetryTests(TestServerFixture instance) : base(instance) { } [Fact] public async Task ElasticsearchTagsShouldBeSet_WhenUsingTheElasticsearchRegistration() @@ -57,7 +57,7 @@ public async Task ElasticsearchTagsShouldBeSet_WhenUsingTheElasticsearchRegistra }; ActivitySource.AddActivityListener(listener); - _ = await transport.GetAsync("/opentelemetry"); + _ = await transport.GetAsync("/opentelemetry", cancellationToken: TestContext.Current.CancellationToken); mre.WaitOne(TimeSpan.FromSeconds(1)).Should().BeTrue(); diff --git a/tests/Elastic.Transport.IntegrationTests/Plumbing/AssemblyServerTestsBase.cs b/tests/Elastic.Transport.IntegrationTests/Plumbing/AssemblyServerTestsBase.cs index d7a14d7..6150357 100644 --- a/tests/Elastic.Transport.IntegrationTests/Plumbing/AssemblyServerTestsBase.cs +++ b/tests/Elastic.Transport.IntegrationTests/Plumbing/AssemblyServerTestsBase.cs @@ -2,21 +2,23 @@ // 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 Elastic.Transport.IntegrationTests.Plumbing; +using Elastic.Transport.IntegrationTests.Plumbing.Examples; using Xunit; -using Xunit.Extensions.Ordering; + +[assembly: CaptureConsole, AssemblyFixture(typeof(TestServerFixture))] +[assembly: AssemblyFixture(typeof(BufferedServerFixture))] namespace Elastic.Transport.IntegrationTests.Plumbing { public class AssemblyServerTestsBase(TServer instance) - : IAssemblyFixture, IClassFixture where TServer : class, HttpTransportTestServer + : IClassFixture where TServer : class, IHttpTransportTestServer { protected TServer Server { get; } = instance; protected ITransport RequestHandler => Server.DefaultRequestHandler; } - public class AssemblyServerTestsBase(TransportTestServer instance) - : AssemblyServerTestsBase(instance) - { - } + public class AssemblyServerTestsBase(TestServerFixture instance) + : AssemblyServerTestsBase(instance); } diff --git a/tests/Elastic.Transport.IntegrationTests/Plumbing/ClassServerTestsBase.cs b/tests/Elastic.Transport.IntegrationTests/Plumbing/ClassServerTestsBase.cs index cba6c9e..2ff908c 100644 --- a/tests/Elastic.Transport.IntegrationTests/Plumbing/ClassServerTestsBase.cs +++ b/tests/Elastic.Transport.IntegrationTests/Plumbing/ClassServerTestsBase.cs @@ -6,7 +6,8 @@ namespace Elastic.Transport.IntegrationTests.Plumbing { - public class ClassServerTestsBase(TServer instance) : IClassFixture where TServer : class, HttpTransportTestServer + public class ClassServerTestsBase(TServer instance) + where TServer : class, IHttpTransportTestServer { protected TServer Server { get; } = instance; diff --git a/tests/Elastic.Transport.IntegrationTests/Plumbing/DefaultStartup.cs b/tests/Elastic.Transport.IntegrationTests/Plumbing/DefaultStartup.cs index f4de166..60b499d 100644 --- a/tests/Elastic.Transport.IntegrationTests/Plumbing/DefaultStartup.cs +++ b/tests/Elastic.Transport.IntegrationTests/Plumbing/DefaultStartup.cs @@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -23,13 +22,9 @@ public class DefaultStartup public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) - { app.UseDeveloperExceptionPage(); - } else - { app.UseHsts(); - } app.UseHttpsRedirection(); app.UseRouting(); diff --git a/tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/ControllerIntegrationTests.cs b/tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/ControllerIntegrationTests.cs index de8b77c..3687a1e 100644 --- a/tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/ControllerIntegrationTests.cs +++ b/tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/ControllerIntegrationTests.cs @@ -19,14 +19,13 @@ namespace Elastic.Transport.IntegrationTests.Plumbing.Examples /// Tests that the test framework loads a controller and the exposed transport can talk to its endpoints. /// Tests runs against a server that started up once and its server instance shared among many test classes /// - public class ControllerIntegrationTests : AssemblyServerTestsBase + public class ControllerIntegrationTests(BufferedServerFixture instance) + : AssemblyServerTestsBase(instance) { - public ControllerIntegrationTests(TransportTestServer instance) : base(instance) { } - [Fact] public async Task CanCallIntoController() { - var response = await RequestHandler.GetAsync("/dummy/20"); + var response = await RequestHandler.GetAsync("/dummy/20", cancellationToken: TestContext.Current.CancellationToken); response.ApiCallDetails.HasSuccessfulStatusCode.Should().BeTrue("{0}", response.ApiCallDetails.DebugInformation); } } diff --git a/tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/EndpointIntegrationTests.cs b/tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/EndpointIntegrationTests.cs index 17ff5c6..2399c88 100644 --- a/tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/EndpointIntegrationTests.cs +++ b/tests/Elastic.Transport.IntegrationTests/Plumbing/Examples/EndpointIntegrationTests.cs @@ -17,21 +17,21 @@ namespace Elastic.Transport.IntegrationTests.Plumbing.Examples /// Since it extends it server is only shared between the tests inside this class. /// The server is also started and stopped after all the tests in this class run. /// - public class EndpointIntegrationTests : ClassServerTestsBase> + public class EndpointIntegrationTests(BufferedServerFixture instance) + : ClassServerTestsBase(instance) { - public EndpointIntegrationTests(TransportTestServer instance) : base(instance) { } - [Fact] public async Task CanCallIntoEndpoint() { - var response = await RequestHandler.GetAsync(DummyStartup.Endpoint); + var response = await RequestHandler.GetAsync(BufferedStartup.Endpoint, cancellationToken: TestContext.Current.CancellationToken); response.ApiCallDetails.HasSuccessfulStatusCode.Should().BeTrue("{0}", response.ApiCallDetails.DebugInformation); } } - public class DummyStartup : DefaultStartup + public class BufferedServerFixture : TransportTestServer; + public class BufferedStartup : DefaultStartup { - public DummyStartup(IConfiguration configuration) : base(configuration) { } + public BufferedStartup(IConfiguration configuration) : base(configuration) { } public static string Endpoint { get; } = "buffered"; diff --git a/tests/Elastic.Transport.IntegrationTests/Plumbing/TransportTestServer.cs b/tests/Elastic.Transport.IntegrationTests/Plumbing/TransportTestServer.cs index fd89584..973d877 100644 --- a/tests/Elastic.Transport.IntegrationTests/Plumbing/TransportTestServer.cs +++ b/tests/Elastic.Transport.IntegrationTests/Plumbing/TransportTestServer.cs @@ -9,45 +9,32 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Xunit; -[assembly: TestFramework("Xunit.Extensions.Ordering.TestFramework", "Xunit.Extensions.Ordering")] - namespace Elastic.Transport.IntegrationTests.Plumbing { - public interface HttpTransportTestServer + public interface IHttpTransportTestServer { Uri Uri { get; } ITransport DefaultRequestHandler { get; } } - public class TransportTestServer : TransportTestServer - { - private static readonly bool RunningMitmProxy = Process.GetProcessesByName("mitmproxy").Any(); - private static readonly bool RunningFiddler = Process.GetProcessesByName("fiddler").Any(); - private static string Localhost => "127.0.0.1"; - public static string LocalOrProxyHost => RunningFiddler || RunningMitmProxy ? "ipv4.fiddler" : Localhost; - public static TransportConfiguration RerouteToProxyIfNeeded(TransportConfiguration config) - { - if (!RunningMitmProxy) return config; - - return config with { ProxyAddress = "http://127.0.0.1:8080" }; - } - } + public class TestServerFixture : TransportTestServer; - public class TransportTestServer : HttpTransportTestServer, IDisposable, IAsyncDisposable, IAsyncLifetime + public abstract class TransportTestServer : IHttpTransportTestServer, IDisposable, IAsyncLifetime where TStartup : class { - private readonly IWebHost _host; - private Uri _uri; - private ITransport _defaultRequestHandler; + private readonly IHost _host; + private readonly IServer _server; public TransportTestServer() { - var url = $"http://{TransportTestServer.LocalOrProxyHost}:0"; + var url = $"http://127.0.0.1:0"; var configuration = new ConfigurationBuilder() @@ -55,49 +42,54 @@ public TransportTestServer() .Build(); _host = - new WebHostBuilder() - .UseKestrel() - .UseConfiguration(configuration) - .UseStartup() - .Build(); + new HostBuilder() + .ConfigureWebHost(builder => + builder.UseKestrel() + .UseConfiguration(configuration) + .UseStartup() + ) + .Build(); + _server = _host.Services.GetRequiredService(); } public Uri Uri { - get => _uri ?? throw new Exception($"{nameof(Uri)} is not available until {nameof(StartAsync)} is called"); - private set => _uri = value; + get => field ?? throw new Exception($"{nameof(Uri)} is not available until {nameof(StartAsync)} is called"); + private set; } public ITransport DefaultRequestHandler { - get => _defaultRequestHandler ?? throw new Exception($"{nameof(DefaultRequestHandler)} is not available until {nameof(StartAsync)} is called"); - private set => _defaultRequestHandler = value; + get => field ?? throw new Exception($"{nameof(DefaultRequestHandler)} is not available until {nameof(StartAsync)} is called"); + private set; } - public async Task> StartAsync(CancellationToken token = default) + public async ValueTask StartAsync(CancellationToken token = default) { await _host.StartAsync(token); - var port = _host.GetServerPort(); - var url = $"http://{TransportTestServer.LocalOrProxyHost}:{port}"; + var port = _server.GetServerPort(); + var url = $"http://127.0.0.1:{port}"; Uri = new Uri(url); DefaultRequestHandler = CreateTransport(c => new DistributedTransport(c)); - return this; } public ITransport CreateTransport(Func create) => - create(TransportTestServer.RerouteToProxyIfNeeded(new TransportConfiguration(Uri))); + create(new TransportConfiguration(Uri)); public void Dispose() => _host?.Dispose(); - public Task InitializeAsync() => StartAsync(); - - Task IAsyncLifetime.DisposeAsync() => DisposeAsync().AsTask(); - + public ValueTask InitializeAsync() => StartAsync(); public ValueTask DisposeAsync() { Dispose(); return ValueTask.CompletedTask; } + + /// + public string FailureTestOutput() => string.Empty; + + /// + public int? MaxConcurrency => 1; } } diff --git a/tests/Elastic.Transport.IntegrationTests/Plumbing/WebHostExtensions.cs b/tests/Elastic.Transport.IntegrationTests/Plumbing/WebHostExtensions.cs index 7f86306..7a02452 100644 --- a/tests/Elastic.Transport.IntegrationTests/Plumbing/WebHostExtensions.cs +++ b/tests/Elastic.Transport.IntegrationTests/Plumbing/WebHostExtensions.cs @@ -6,15 +6,17 @@ using System.Linq; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Hosting.Server.Features; +using Microsoft.Extensions.Hosting; namespace Elastic.Transport.IntegrationTests.Plumbing { internal static class WebHostExtensions { - internal static int GetServerPort(this IWebHost server) + internal static int GetServerPort(this IServer server) { - var address = server.ServerFeatures.Get().Addresses.First(); + var address = server.Features.Get().Addresses.First(); var match = Regex.Match(address, @"^.+:(\d+)$"); if (!match.Success) throw new Exception($"Unable to parse port from address: {address}"); diff --git a/tests/Elastic.Transport.IntegrationTests/Responses/SpecialisedResponseTests.cs b/tests/Elastic.Transport.IntegrationTests/Responses/SpecialisedResponseTests.cs index d386361..d02034a 100644 --- a/tests/Elastic.Transport.IntegrationTests/Responses/SpecialisedResponseTests.cs +++ b/tests/Elastic.Transport.IntegrationTests/Responses/SpecialisedResponseTests.cs @@ -16,7 +16,7 @@ namespace Elastic.Transport.IntegrationTests.Responses; -public class SpecialisedResponseTests(TransportTestServer instance) : AssemblyServerTestsBase(instance) +public class SpecialisedResponseTests(TestServerFixture instance) : AssemblyServerTestsBase(instance) { private const string Path = "/specialresponse"; private const string EmptyJson = "{}"; @@ -132,7 +132,7 @@ public async Task VoidResponse_ShouldReturnExpectedResponse() var payload = new Payload { ResponseString = EmptyJson, StatusCode = 200 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -164,7 +164,7 @@ public async Task DynamicResponse_WhenContentIsJson_AndNotDisableDirectStreaming var json = "{\"propertyOne\":\"value1\",\"propertyTwo\":100}"; var payload = new Payload { ResponseString = json, StatusCode = 200 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -201,7 +201,7 @@ public async Task DynamicResponse_WhenContentIsNotJson_AndContentIsChunked_AndNo var payload = new Payload { ResponseString = stringValue, StatusCode = 200, ContentType = "text/plain", IsChunked = true }; var requestConfig = new RequestConfiguration { Accept = "text/plain" }; - var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig); + var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig, TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response, stringValue); @@ -237,7 +237,7 @@ public async Task DynamicResponse_WhenContentIsJson_AndDisableDirectStreaming_Sh var json = "{\"propertyOne\":\"value1\",\"propertyTwo\":100}"; var payload = new Payload { ResponseString = json, StatusCode = 200 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -274,7 +274,7 @@ public async Task DynamicResponse_WhenContentIsNotJson_AndNotDisableDirectStream var payload = new Payload { ResponseString = stringValue, StatusCode = 200, ContentType = "text/plain" }; var requestConfig = new RequestConfiguration { Accept = "text/plain" }; - var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig); + var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig, TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response, stringValue); @@ -311,7 +311,7 @@ public async Task DynamicResponse_WhenContentIsNotJson_AndDisableDirectStreaming var payload = new Payload { ResponseString = stringValue, StatusCode = 200, ContentType = "text/plain" }; var requestConfig = new RequestConfiguration { Accept = "text/plain" }; - var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig); + var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig, TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -345,7 +345,7 @@ public async Task BytesResponse_WithoutDisableDirectStreaming_ShouldReturnExpect var payload = new Payload { ResponseString = EmptyJson, StatusCode = 200 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -358,7 +358,7 @@ static void Validate(TrackingMemoryStreamFactory memoryStreamFactory, BytesRespo { response.Body.AsSpan().SequenceEqual(EmptyJsonBytes); // Even when not using DisableDirectStreaming, we have a byte[] so the builder sets ResponseBodyInBytes too - response.ApiCallDetails.ResponseBodyInBytes.Should().NotBeNull(); + response.ApiCallDetails.ResponseBodyInBytes.Should().NotBeNull(); memoryStreamFactory.Created.Count.Should().Be(2); // One required for setting request content and one to buffer the stream foreach (var memoryStream in memoryStreamFactory.Created) memoryStream.IsDisposed.Should().BeTrue(); @@ -380,7 +380,7 @@ public async Task BytesResponse_WithDisableDirectStreaming_ShouldReturnExpectedR var payload = new Payload { ResponseString = EmptyJson, StatusCode = 200 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -413,7 +413,7 @@ public async Task StreamResponse_WithoutDisableDirectStreaming_BodyShouldBeSet_N var payload = new Payload { ResponseString = EmptyJson, StatusCode = 200 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); await ValidateAsync(memoryStreamFactory, response); @@ -448,7 +448,7 @@ public async Task StreamResponse_WithDisableDirectStreaming_BodyShouldBeSet_NotD var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = EmptyJson, StatusCode = 200 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); await ValidateAsync(memoryStreamFactory, response); @@ -489,7 +489,7 @@ public async Task StringResponse_WithoutDisableDirectStreaming_MemoryStreamShoul var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = EmptyJson, StatusCode = 200 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -527,7 +527,7 @@ public async Task StringResponse_WithContentLongerThan1024_WithoutDisableDirectS var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = LargeJson, StatusCode = 200 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -566,7 +566,7 @@ public async Task WhenInvalidJson_WithDisableDirectStreaming_MemoryStreamShouldB var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = " " }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -603,7 +603,7 @@ public async Task WhenInvalidJson_WithoutDisableDirectStreaming_MemoryStreamShou var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = " " }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -640,7 +640,7 @@ public async Task WhenNoContent_MemoryStreamShouldBeDisposed() var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = "", StatusCode = 204 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -678,7 +678,7 @@ public async Task WhenNoContent_WithDisableDirectStreaming_MemoryStreamShouldBeD var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = "", StatusCode = 204 }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -721,7 +721,7 @@ public async Task PlainText_WithoutCustomResponseBuilder_WithDisableDirectStream var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = expectedString, ContentType = "text/plain" }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -762,7 +762,7 @@ public async Task PlainText_WithoutCustomResponseBuilder_WithoutDisableDirectStr var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = expectedString, ContentType = "text/plain" }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -830,7 +830,7 @@ public async Task PlainText_WithoutCustomResponseBuilder_WithoutDisableDirectStr var transport = new DistributedTransport(config); var payload = new Payload { ResponseString = expectedString, ContentType = "text/plain", IsChunked = true }; - var response = await transport.PostAsync(Path, PostData.Serializable(payload)); + var response = await transport.PostAsync(Path, PostData.Serializable(payload), cancellationToken: TestContext.Current.CancellationToken); Validate(memoryStreamFactory, response); @@ -871,7 +871,7 @@ public async Task PlainText_WithCustomResponseBuilder_WithDisableDirectStreaming var requestConfig = new RequestConfiguration { Accept = "text/plain" }; var payload = new Payload { ResponseString = expectedString, ContentType = "text/plain" }; - var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig); + var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig, TestContext.Current.CancellationToken); memoryStreamFactory.Created.Count.Should().Be(3); foreach (var memoryStream in memoryStreamFactory.Created) @@ -915,7 +915,7 @@ public async Task PlainText_WithCustomResponseBuilder_WithoutDisableDirectStream var requestConfig = new RequestConfiguration { Accept = "text/plain" }; var payload = new Payload { ResponseString = expectedString, ContentType = "text/plain" }; - var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig); + var response = await transport.RequestAsync(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig, TestContext.Current.CancellationToken); memoryStreamFactory.Created.Count.Should().Be(1); response.ApiCallDetails.ResponseBodyInBytes.Should().BeNull(); @@ -924,7 +924,7 @@ public async Task PlainText_WithCustomResponseBuilder_WithoutDisableDirectStream memoryStreamFactory.Reset(); response = transport.Request(new EndpointPath(HttpMethod.POST, Path), PostData.Serializable(payload), default, requestConfig); - + memoryStreamFactory.Created.Count.Should().Be(1); response.ApiCallDetails.ResponseBodyInBytes.Should().BeNull(); response.Value.Should().Be(expectedString); diff --git a/tests/Elastic.Transport.Tests.Shared/Elastic.Transport.Tests.Shared.csproj b/tests/Elastic.Transport.Tests.Shared/Elastic.Transport.Tests.Shared.csproj index 8123f2e..3c0ee8a 100644 --- a/tests/Elastic.Transport.Tests.Shared/Elastic.Transport.Tests.Shared.csproj +++ b/tests/Elastic.Transport.Tests.Shared/Elastic.Transport.Tests.Shared.csproj @@ -1,7 +1,7 @@ - net8.0;net481 + net10.0;net481 false CS8002 enable @@ -12,4 +12,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/tests/Elastic.Transport.Tests/Elastic.Transport.Tests.csproj b/tests/Elastic.Transport.Tests/Elastic.Transport.Tests.csproj index 2c439d6..1286273 100644 --- a/tests/Elastic.Transport.Tests/Elastic.Transport.Tests.csproj +++ b/tests/Elastic.Transport.Tests/Elastic.Transport.Tests.csproj @@ -1,26 +1,25 @@ - net8.0;net481 + net10.0;net481 True false CS8002 - - - - runtime; build; native; contentfiles; analyzers; buildtransitive + all + runtime; build; native; contentfiles; analyzers; buildtransitive - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - +