From 34d6e3d65a77eaecc65ebe31714f6fded2bc964e Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Thu, 10 Oct 2024 18:31:27 +0200 Subject: [PATCH] Update dependencies and configurations (#66) * Update dependencies and configurations Upgraded several package references and configurations across multiple projects to ensure compatibility and performance. Replaced deprecated syntax, optimized namespaces, and enhanced directory structures for better maintainability. * Simplify EphemeralCluster configuration Removed unnecessary commented-out configuration options for clarity. The change ensures the code is more readable and maintainable by using a clean, straightforward cluster configuration. --- build/scripts/CommandLine.fs | 8 ++++---- examples/Elastic.Ephemeral.Example/Program.cs | 2 +- examples/Elastic.Managed.Example/Program.cs | 14 +++++++++----- .../Elastic.Xunit.ExampleComplex/Clusters.cs | 17 ++++++----------- .../Elastic.Xunit.ExampleComplex.csproj | 4 ++-- examples/Elastic.Xunit.ExampleComplex/Tests.cs | 2 -- .../Elastic.Xunit.ExampleMinimal.csproj | 4 ++-- .../Elastic.Xunit.ExampleMinimal/ExampleTest.cs | 2 +- global.json | 2 +- src/Directory.Build.props | 2 +- .../Elastic.Elasticsearch.Ephemeral.csproj | 5 ++++- .../ClusterBase.cs | 8 ++------ .../Elastic.Elasticsearch.Managed.csproj | 2 -- .../ElasticsearchCluster.cs | 13 ++++--------- .../Elastic.Elasticsearch.Xunit.csproj | 2 +- .../Elastic.Stack.ArtifactsApi.csproj | 7 ++++++- .../Resolvers/SnapshotApiResolver.cs | 4 ++-- .../Nest.TypescriptExporter.csproj | 2 +- 18 files changed, 47 insertions(+), 53 deletions(-) diff --git a/build/scripts/CommandLine.fs b/build/scripts/CommandLine.fs index d94108f..a69c4f9 100644 --- a/build/scripts/CommandLine.fs +++ b/build/scripts/CommandLine.fs @@ -27,10 +27,10 @@ with interface IArgParserTemplate with member this.Usage = match this with - | Clean _ -> "clean known output locations" - | Build _ -> "Run build and tests" - | Release _ -> "runs build, and create an validates the packages shy of publishing them" - | Publish _ -> "Runs the full release" + | Clean -> "clean known output locations" + | Build -> "Run build and tests" + | Release -> "runs build, and create an validates the packages shy of publishing them" + | Publish -> "Runs the full release" | SingleTarget _ -> "Runs the provided sub command without running their dependencies" | Token _ -> "Token to be used to authenticate with github" diff --git a/examples/Elastic.Ephemeral.Example/Program.cs b/examples/Elastic.Ephemeral.Example/Program.cs index ffe89e1..f5c8fb1 100644 --- a/examples/Elastic.Ephemeral.Example/Program.cs +++ b/examples/Elastic.Ephemeral.Example/Program.cs @@ -11,7 +11,7 @@ using HttpMethod = Elastic.Transport.HttpMethod; -var config = new EphemeralClusterConfiguration("8.7.0", XPack | Security | SSL); +var config = new EphemeralClusterConfiguration("8.15.0"); using var cluster = new EphemeralCluster(config); var exitEvent = new ManualResetEvent(false); diff --git a/examples/Elastic.Managed.Example/Program.cs b/examples/Elastic.Managed.Example/Program.cs index 5a00083..f569037 100644 --- a/examples/Elastic.Managed.Example/Program.cs +++ b/examples/Elastic.Managed.Example/Program.cs @@ -3,9 +3,12 @@ // See the LICENSE file in the project root for more information using System; +using System.IO; using Elastic.Elasticsearch.Managed; using Elastic.Elasticsearch.Managed.Configuration; using Elastic.Elasticsearch.Managed.ConsoleWriters; +using Elastic.Stack.ArtifactsApi; +using Elastic.Stack.ArtifactsApi.Products; namespace Elastic.Managed.Example { @@ -13,12 +16,13 @@ public static class Program { public static void Main(string[] args) { - var version = "6.3.0"; - var esHome = - Environment.ExpandEnvironmentVariables( - $@"%LOCALAPPDATA%\ElasticManaged\{version}\elasticsearch-{version}"); + ElasticVersion version = "latest-8"; + var folderName = version.Artifact(Product.Elasticsearch).LocalFolderName; - var clusterConfiguration = new ClusterConfiguration(version, esHome, 2); + var temp = Path.Combine(Path.GetTempPath(), "elastic", folderName, "my-cluster"); + var home = Path.Combine(temp, "home"); + + var clusterConfiguration = new ClusterConfiguration(version, home, 2); using (var cluster = new ElasticsearchCluster(clusterConfiguration)) cluster.Start(new ConsoleLineWriter(), TimeSpan.FromMinutes(2)); diff --git a/examples/Elastic.Xunit.ExampleComplex/Clusters.cs b/examples/Elastic.Xunit.ExampleComplex/Clusters.cs index 9d5b146..7e51c93 100644 --- a/examples/Elastic.Xunit.ExampleComplex/Clusters.cs +++ b/examples/Elastic.Xunit.ExampleComplex/Clusters.cs @@ -12,11 +12,10 @@ namespace Elastic.Xunit.ExampleComplex { internal static class EphemeralClusterExtensions { - private static readonly ConcurrentDictionary Clients = - new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Clients = new(); public static IElasticClient GetOrAddClient(this IEphemeralCluster cluster) => - Clients.GetOrAdd(cluster, (c) => + Clients.GetOrAdd(cluster, c => { var connectionPool = new StaticConnectionPool(c.NodesUris()); var settings = new ConnectionSettings(connectionPool); @@ -30,15 +29,11 @@ public interface IMyCluster IElasticClient Client { get; } } - public abstract class MyClusterBase : XunitClusterBase, IMyCluster + public abstract class MyClusterBase() : XunitClusterBase(new XunitClusterConfiguration(MyRunOptions.TestVersion) + { + ShowElasticsearchOutputAfterStarted = false, + }), IMyCluster { - protected MyClusterBase() : base(new XunitClusterConfiguration(MyRunOptions.TestVersion) - { - ShowElasticsearchOutputAfterStarted = false, - }) - { - } - public IElasticClient Client => this.GetOrAddClient(); } diff --git a/examples/Elastic.Xunit.ExampleComplex/Elastic.Xunit.ExampleComplex.csproj b/examples/Elastic.Xunit.ExampleComplex/Elastic.Xunit.ExampleComplex.csproj index c93541b..ddda97c 100644 --- a/examples/Elastic.Xunit.ExampleComplex/Elastic.Xunit.ExampleComplex.csproj +++ b/examples/Elastic.Xunit.ExampleComplex/Elastic.Xunit.ExampleComplex.csproj @@ -5,8 +5,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/examples/Elastic.Xunit.ExampleComplex/Tests.cs b/examples/Elastic.Xunit.ExampleComplex/Tests.cs index 8a97d8d..1035a56 100644 --- a/examples/Elastic.Xunit.ExampleComplex/Tests.cs +++ b/examples/Elastic.Xunit.ExampleComplex/Tests.cs @@ -2,11 +2,9 @@ // 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.Elasticsearch.Managed; using Elastic.Elasticsearch.Xunit.XunitPlumbing; using Elasticsearch.Net; using FluentAssertions; -using Xunit; namespace Elastic.Xunit.ExampleComplex { diff --git a/examples/Elastic.Xunit.ExampleMinimal/Elastic.Xunit.ExampleMinimal.csproj b/examples/Elastic.Xunit.ExampleMinimal/Elastic.Xunit.ExampleMinimal.csproj index a67762d..71630d4 100644 --- a/examples/Elastic.Xunit.ExampleMinimal/Elastic.Xunit.ExampleMinimal.csproj +++ b/examples/Elastic.Xunit.ExampleMinimal/Elastic.Xunit.ExampleMinimal.csproj @@ -4,8 +4,8 @@ False - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/examples/Elastic.Xunit.ExampleMinimal/ExampleTest.cs b/examples/Elastic.Xunit.ExampleMinimal/ExampleTest.cs index 493522c..ca861a1 100644 --- a/examples/Elastic.Xunit.ExampleMinimal/ExampleTest.cs +++ b/examples/Elastic.Xunit.ExampleMinimal/ExampleTest.cs @@ -21,7 +21,7 @@ public class MyTestCluster : XunitClusterBase /// We pass our configuration instance to the base class. /// We only configure it to run version 6.2.3 here but lots of additional options are available. /// - public MyTestCluster() : base(new XunitClusterConfiguration("latest-8") { }) + public MyTestCluster() : base(new XunitClusterConfiguration("latest-8")) { } } diff --git a/global.json b/global.json index c317b00..789bff3 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.302", + "version": "8.0.100", "rollForward": "latestFeature", "allowPrerelease": false } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 3f90319..7384c98 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -33,6 +33,6 @@ - + diff --git a/src/Elastic.Elasticsearch.Ephemeral/Elastic.Elasticsearch.Ephemeral.csproj b/src/Elastic.Elasticsearch.Ephemeral/Elastic.Elasticsearch.Ephemeral.csproj index 2a1477a..01c4de8 100644 --- a/src/Elastic.Elasticsearch.Ephemeral/Elastic.Elasticsearch.Ephemeral.csproj +++ b/src/Elastic.Elasticsearch.Ephemeral/Elastic.Elasticsearch.Ephemeral.csproj @@ -7,9 +7,12 @@ - + + + + \ No newline at end of file diff --git a/src/Elastic.Elasticsearch.Managed/ClusterBase.cs b/src/Elastic.Elasticsearch.Managed/ClusterBase.cs index 110bf31..54b22f2 100644 --- a/src/Elastic.Elasticsearch.Managed/ClusterBase.cs +++ b/src/Elastic.Elasticsearch.Managed/ClusterBase.cs @@ -53,12 +53,8 @@ public interface ICluster : ICluster,IDisposable } - public abstract class ClusterBase : ClusterBase - { - protected ClusterBase(ClusterConfiguration clusterConfiguration) : base(clusterConfiguration) - { - } - } + public abstract class ClusterBase(ClusterConfiguration clusterConfiguration) + : ClusterBase(clusterConfiguration); public abstract class ClusterBase : ICluster where TConfiguration : IClusterConfiguration diff --git a/src/Elastic.Elasticsearch.Managed/Elastic.Elasticsearch.Managed.csproj b/src/Elastic.Elasticsearch.Managed/Elastic.Elasticsearch.Managed.csproj index 5dd1bbb..06f70f1 100644 --- a/src/Elastic.Elasticsearch.Managed/Elastic.Elasticsearch.Managed.csproj +++ b/src/Elastic.Elasticsearch.Managed/Elastic.Elasticsearch.Managed.csproj @@ -10,8 +10,6 @@ - - diff --git a/src/Elastic.Elasticsearch.Managed/ElasticsearchCluster.cs b/src/Elastic.Elasticsearch.Managed/ElasticsearchCluster.cs index 4288773..40f5f5b 100644 --- a/src/Elastic.Elasticsearch.Managed/ElasticsearchCluster.cs +++ b/src/Elastic.Elasticsearch.Managed/ElasticsearchCluster.cs @@ -4,12 +4,7 @@ using Elastic.Elasticsearch.Managed.Configuration; -namespace Elastic.Elasticsearch.Managed -{ - public class ElasticsearchCluster : ClusterBase - { - public ElasticsearchCluster(ClusterConfiguration clusterConfiguration) : base(clusterConfiguration) - { - } - } -} +namespace Elastic.Elasticsearch.Managed; + +public class ElasticsearchCluster(ClusterConfiguration clusterConfiguration) + : ClusterBase(clusterConfiguration); diff --git a/src/Elastic.Elasticsearch.Xunit/Elastic.Elasticsearch.Xunit.csproj b/src/Elastic.Elasticsearch.Xunit/Elastic.Elasticsearch.Xunit.csproj index 6015f45..0f66301 100644 --- a/src/Elastic.Elasticsearch.Xunit/Elastic.Elasticsearch.Xunit.csproj +++ b/src/Elastic.Elasticsearch.Xunit/Elastic.Elasticsearch.Xunit.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Elastic.Stack.ArtifactsApi/Elastic.Stack.ArtifactsApi.csproj b/src/Elastic.Stack.ArtifactsApi/Elastic.Stack.ArtifactsApi.csproj index 38f2c33..5cc40ff 100644 --- a/src/Elastic.Stack.ArtifactsApi/Elastic.Stack.ArtifactsApi.csproj +++ b/src/Elastic.Stack.ArtifactsApi/Elastic.Stack.ArtifactsApi.csproj @@ -7,7 +7,12 @@ - + + + + + + diff --git a/src/Elastic.Stack.ArtifactsApi/Resolvers/SnapshotApiResolver.cs b/src/Elastic.Stack.ArtifactsApi/Resolvers/SnapshotApiResolver.cs index 8269ddd..cf42be5 100644 --- a/src/Elastic.Stack.ArtifactsApi/Resolvers/SnapshotApiResolver.cs +++ b/src/Elastic.Stack.ArtifactsApi/Resolvers/SnapshotApiResolver.cs @@ -18,8 +18,8 @@ namespace Elastic.Stack.ArtifactsApi.Resolvers { public static class SnapshotApiResolver { - public static readonly System.Lazy> AvailableVersions = - new System.Lazy>(LoadVersions, LazyThreadSafetyMode.ExecutionAndPublication); + public static readonly Lazy> AvailableVersions = + new(LoadVersions, LazyThreadSafetyMode.ExecutionAndPublication); private static Regex PackageProductRegex { get; } = new Regex(@"(.*?)-(\d+\.\d+\.\d+(?:-(?:SNAPSHOT|alpha\d+|beta\d+|rc\d+))?)"); diff --git a/src/Nest.TypescriptExporter/Nest.TypescriptExporter.csproj b/src/Nest.TypescriptExporter/Nest.TypescriptExporter.csproj index da98198..e534a8d 100644 --- a/src/Nest.TypescriptExporter/Nest.TypescriptExporter.csproj +++ b/src/Nest.TypescriptExporter/Nest.TypescriptExporter.csproj @@ -11,6 +11,6 @@ - + \ No newline at end of file