From 4ae97e190aca0fb48f7b81011041db31400c4f76 Mon Sep 17 00:00:00 2001
From: shacharPash <shachar.pashchur@redis.com>
Date: Sun, 5 Nov 2023 17:25:03 +0200
Subject: [PATCH 1/4] change setinfo process

---
 src/NRedisStack/Auxiliary.cs                      | 8 ++++----
 src/NRedisStack/CoreCommands/CoreCommands.cs      | 3 +++
 src/NRedisStack/CoreCommands/CoreCommandsAsync.cs | 5 +++++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/NRedisStack/Auxiliary.cs b/src/NRedisStack/Auxiliary.cs
index d5555fb7..512276b8 100644
--- a/src/NRedisStack/Auxiliary.cs
+++ b/src/NRedisStack/Auxiliary.cs
@@ -61,8 +61,8 @@ private static void SetInfoInPipeline(this IDatabase db)
 
         public static RedisResult Execute(this IDatabase db, SerializedCommand command)
         {
-            var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));
-            if (_setInfo && compareVersions >= 0)
+            // var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 2, 0));
+            if (_setInfo /*&& compareVersions >= 0*/)
             {
                 _setInfo = false;
                 db.SetInfoInPipeline();
@@ -72,8 +72,8 @@ public static RedisResult Execute(this IDatabase db, SerializedCommand command)
 
         public async static Task<RedisResult> ExecuteAsync(this IDatabaseAsync db, SerializedCommand command)
         {
-            var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));
-            if (_setInfo && compareVersions >= 0)
+            // var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));
+            if (_setInfo /*&& compareVersions >= 0*/)
             {
                 _setInfo = false;
                 ((IDatabase)db).SetInfoInPipeline();
diff --git a/src/NRedisStack/CoreCommands/CoreCommands.cs b/src/NRedisStack/CoreCommands/CoreCommands.cs
index 0040c2bc..e170585e 100644
--- a/src/NRedisStack/CoreCommands/CoreCommands.cs
+++ b/src/NRedisStack/CoreCommands/CoreCommands.cs
@@ -14,6 +14,9 @@ public static class CoreCommands
         /// <remarks><seealso href="https://redis.io/commands/client-setinfo/"/></remarks>
         public static bool ClientSetInfo(this IDatabase db, SetInfoAttr attr, string value)
         {
+            var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 2, 0));
+            if (compareVersions < 0) // the server does not support the CLIENT SETNAME command
+                return false;
             return db.Execute(CoreCommandBuilder.ClientSetInfo(attr, value)).OKtoBoolean();
         }
     }
diff --git a/src/NRedisStack/CoreCommands/CoreCommandsAsync.cs b/src/NRedisStack/CoreCommands/CoreCommandsAsync.cs
index 688d30db..cad552ab 100644
--- a/src/NRedisStack/CoreCommands/CoreCommandsAsync.cs
+++ b/src/NRedisStack/CoreCommands/CoreCommandsAsync.cs
@@ -14,6 +14,11 @@ public static class CoreCommandsAsync //: ICoreCommandsAsync
         /// <remarks><seealso href="https://redis.io/commands/client-setinfo/"/></remarks>
         public static async Task<bool> ClientSetInfoAsync(this IDatabaseAsync db, SetInfoAttr attr, string value)
         {
+            var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 2, 0));
+            if (compareVersions < 0) // the server does not support the CLIENT SETNAME command
+            {
+                return false;
+            }
             return (await db.ExecuteAsync(CoreCommandBuilder.ClientSetInfo(attr, value))).OKtoBoolean();
         }
     }

From 386a0fcdec11d2cc356240b4e9373968aec58996 Mon Sep 17 00:00:00 2001
From: shacharPash <shachar.pashchur@redis.com>
Date: Sun, 5 Nov 2023 17:42:03 +0200
Subject: [PATCH 2/4] change version to 7, 1, 242

---
 src/NRedisStack/Auxiliary.cs                      | 2 +-
 src/NRedisStack/CoreCommands/CoreCommands.cs      | 2 +-
 src/NRedisStack/CoreCommands/CoreCommandsAsync.cs | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/NRedisStack/Auxiliary.cs b/src/NRedisStack/Auxiliary.cs
index 512276b8..035a55d7 100644
--- a/src/NRedisStack/Auxiliary.cs
+++ b/src/NRedisStack/Auxiliary.cs
@@ -61,7 +61,7 @@ private static void SetInfoInPipeline(this IDatabase db)
 
         public static RedisResult Execute(this IDatabase db, SerializedCommand command)
         {
-            // var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 2, 0));
+            // var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));
             if (_setInfo /*&& compareVersions >= 0*/)
             {
                 _setInfo = false;
diff --git a/src/NRedisStack/CoreCommands/CoreCommands.cs b/src/NRedisStack/CoreCommands/CoreCommands.cs
index e170585e..4c8917bb 100644
--- a/src/NRedisStack/CoreCommands/CoreCommands.cs
+++ b/src/NRedisStack/CoreCommands/CoreCommands.cs
@@ -14,7 +14,7 @@ public static class CoreCommands
         /// <remarks><seealso href="https://redis.io/commands/client-setinfo/"/></remarks>
         public static bool ClientSetInfo(this IDatabase db, SetInfoAttr attr, string value)
         {
-            var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 2, 0));
+            var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));
             if (compareVersions < 0) // the server does not support the CLIENT SETNAME command
                 return false;
             return db.Execute(CoreCommandBuilder.ClientSetInfo(attr, value)).OKtoBoolean();
diff --git a/src/NRedisStack/CoreCommands/CoreCommandsAsync.cs b/src/NRedisStack/CoreCommands/CoreCommandsAsync.cs
index cad552ab..c091159f 100644
--- a/src/NRedisStack/CoreCommands/CoreCommandsAsync.cs
+++ b/src/NRedisStack/CoreCommands/CoreCommandsAsync.cs
@@ -14,7 +14,7 @@ public static class CoreCommandsAsync //: ICoreCommandsAsync
         /// <remarks><seealso href="https://redis.io/commands/client-setinfo/"/></remarks>
         public static async Task<bool> ClientSetInfoAsync(this IDatabaseAsync db, SetInfoAttr attr, string value)
         {
-            var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 2, 0));
+            var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));
             if (compareVersions < 0) // the server does not support the CLIENT SETNAME command
             {
                 return false;

From 7d2568e61f680f9dca559b7b4fe2ae4ec3d381ad Mon Sep 17 00:00:00 2001
From: shacharPash <shachar.pashchur@redis.com>
Date: Thu, 9 Nov 2023 17:16:22 +0200
Subject: [PATCH 3/4] fix setinfo format

---
 src/NRedisStack/Auxiliary.cs                       | 8 +++-----
 tests/NRedisStack.Tests/Core Commands/CoreTests.cs | 8 ++++----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/NRedisStack/Auxiliary.cs b/src/NRedisStack/Auxiliary.cs
index 035a55d7..7d471ba2 100644
--- a/src/NRedisStack/Auxiliary.cs
+++ b/src/NRedisStack/Auxiliary.cs
@@ -6,12 +6,12 @@ namespace NRedisStack
 {
     public static class Auxiliary
     {
-        private static string? _libraryName = $"NRedisStack;.NET-{Environment.Version}";
+        private static string? _libraryName = $"NRedisStack(.NET_v{Environment.Version})";
         private static bool _setInfo = true;
         public static void ResetInfoDefaults()
         {
             _setInfo = true;
-            _libraryName = $"NRedisStack;.NET-{Environment.Version}";
+            _libraryName = $"NRedisStack(.NET_v{Environment.Version})";
         }
         public static List<object> MergeArgs(RedisKey key, params RedisValue[] items)
         {
@@ -34,8 +34,6 @@ public static object[] AssembleNonNullArguments(params object?[] arguments)
             return args.ToArray();
         }
 
-        // public static IDatabase GetDatabase(this ConnectionMultiplexer redis) => redis.GetDatabase("", "");
-
         // TODO: add all the signatures of GetDatabase
         public static IDatabase GetDatabase(this ConnectionMultiplexer redis,
                                             string? LibraryName)
@@ -45,7 +43,7 @@ public static IDatabase GetDatabase(this ConnectionMultiplexer redis,
                 _setInfo = false;
 
             else // the user set his own the library name
-                _libraryName = $"NRedisStack({LibraryName});.NET-{Environment.Version})";
+                _libraryName = $"NRedisStack({LibraryName};.NET_v{Environment.Version})";
 
             return _db;
         }
diff --git a/tests/NRedisStack.Tests/Core Commands/CoreTests.cs b/tests/NRedisStack.Tests/Core Commands/CoreTests.cs
index d403dec2..9a3d763a 100644
--- a/tests/NRedisStack.Tests/Core Commands/CoreTests.cs	
+++ b/tests/NRedisStack.Tests/Core Commands/CoreTests.cs	
@@ -54,7 +54,7 @@ public void TestSetInfoDefaultValue()
         db.Execute(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version.
 
         var info = db.Execute("CLIENT", "INFO").ToString();
-        Assert.EndsWith($"lib-name=NRedisStack;.NET-{Environment.Version} lib-ver={GetNRedisStackVersion()}\n", info);
+        Assert.EndsWith($"lib-name=NRedisStack(.NET_v{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info);
     }
 
     [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.1.242")]
@@ -68,7 +68,7 @@ public async Task TestSetInfoDefaultValueAsync()
         await db.ExecuteAsync(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version.
 
         var info = (await db.ExecuteAsync("CLIENT", "INFO")).ToString();
-        Assert.EndsWith($"lib-name=NRedisStack;.NET-{Environment.Version} lib-ver={GetNRedisStackVersion()}\n", info);
+        Assert.EndsWith($"lib-name=NRedisStack(.NET_v{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info);
     }
 
     [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.1.242")]
@@ -82,7 +82,7 @@ public void TestSetInfoWithValue()
         db.Execute(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version.
 
         var info = db.Execute("CLIENT", "INFO").ToString();
-        Assert.EndsWith($"NRedisStack(MyLibraryName;v1.0.0);.NET-{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info);
+        Assert.EndsWith($"NRedisStack(MyLibraryName;v1.0.0;.NET_v{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info);
     }
 
     [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.1.242")]
@@ -96,7 +96,7 @@ public async Task TestSetInfoWithValueAsync()
         await db.ExecuteAsync(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version.
 
         var info = (await db.ExecuteAsync("CLIENT", "INFO")).ToString();
-        Assert.EndsWith($"NRedisStack(MyLibraryName;v1.0.0);.NET-{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info);
+        Assert.EndsWith($"NRedisStack(MyLibraryName;v1.0.0;.NET_v{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info);
     }
 
     [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.1.242")]

From 73936f3353780cc9eabb8776762cd2d50fae41eb Mon Sep 17 00:00:00 2001
From: shacharPash <93581407+shacharPash@users.noreply.github.com>
Date: Mon, 18 Dec 2023 15:24:59 +0200
Subject: [PATCH 4/4] delete comment

---
 src/NRedisStack/Auxiliary.cs | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/NRedisStack/Auxiliary.cs b/src/NRedisStack/Auxiliary.cs
index 7d471ba2..3a508c2d 100644
--- a/src/NRedisStack/Auxiliary.cs
+++ b/src/NRedisStack/Auxiliary.cs
@@ -59,8 +59,7 @@ private static void SetInfoInPipeline(this IDatabase db)
 
         public static RedisResult Execute(this IDatabase db, SerializedCommand command)
         {
-            // var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));
-            if (_setInfo /*&& compareVersions >= 0*/)
+            if (_setInfo)
             {
                 _setInfo = false;
                 db.SetInfoInPipeline();
@@ -70,8 +69,7 @@ public static RedisResult Execute(this IDatabase db, SerializedCommand command)
 
         public async static Task<RedisResult> ExecuteAsync(this IDatabaseAsync db, SerializedCommand command)
         {
-            // var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));
-            if (_setInfo /*&& compareVersions >= 0*/)
+            if (_setInfo)
             {
                 _setInfo = false;
                 ((IDatabase)db).SetInfoInPipeline();
@@ -133,4 +131,4 @@ public static string GetNRedisStackVersion()
             return $"{version.Major}.{version.Minor}.{version.Build}";
         }
     }
-}
\ No newline at end of file
+}