This is an automated email from the ASF dual-hosted git repository.
hgruszecki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iggy.git
The following commit(s) were added to refs/heads/master by this push:
new 6a6f15533 refactor(csharp): implement SDK version handling in login
requests (#2937)
6a6f15533 is described below
commit 6a6f15533cd0e737830a472f4134c0da15f7157a
Author: Ćukasz Zborek <[email protected]>
AuthorDate: Sun Mar 15 14:18:39 2026 +0100
refactor(csharp): implement SDK version handling in login requests (#2937)
---
.../Implementations/HttpMessageStream.cs | 8 +++---
.../IggyClient/Implementations/TcpMessageStream.cs | 3 +-
foreign/csharp/Iggy_SDK/Iggy_SDK.csproj | 2 +-
foreign/csharp/Iggy_SDK/Utils/SdkVersion.cs | 27 ++++++++++++++++++
.../Iggy_SDK_Tests/UtilityTests/SdkVersionTests.cs | 32 ++++++++++++++++++++++
5 files changed, 66 insertions(+), 6 deletions(-)
diff --git
a/foreign/csharp/Iggy_SDK/IggyClient/Implementations/HttpMessageStream.cs
b/foreign/csharp/Iggy_SDK/IggyClient/Implementations/HttpMessageStream.cs
index 6f1c5a0ce..0f1a9191b 100644
--- a/foreign/csharp/Iggy_SDK/IggyClient/Implementations/HttpMessageStream.cs
+++ b/foreign/csharp/Iggy_SDK/IggyClient/Implementations/HttpMessageStream.cs
@@ -176,8 +176,8 @@ public class HttpMessageStream : IIggyClient
ulong maxTopicSize = 0, TimeSpan? messageExpiry = null, byte?
replicationFactor = null,
CancellationToken token = default)
{
- var json = JsonSerializer.Serialize(
- new UpdateTopicRequest(name, compressionAlgorithm, maxTopicSize,
DurationHelpers.ToDuration(messageExpiry),
+ var json = JsonSerializer.Serialize(new UpdateTopicRequest(name,
compressionAlgorithm, maxTopicSize,
+ DurationHelpers.ToDuration(messageExpiry),
replicationFactor),
_jsonSerializerOptions);
var data = new StringContent(json, Encoding.UTF8, "application/json");
@@ -690,8 +690,8 @@ public class HttpMessageStream : IIggyClient
/// <inheritdoc />
public async Task<AuthResponse?> LoginUser(string userName, string
password, CancellationToken token = default)
{
- // TODO: get version
- var json = JsonSerializer.Serialize(new LoginUserRequest(userName,
password, "", Context),
+ // TODO: Add binary protocol version
+ var json = JsonSerializer.Serialize(new LoginUserRequest(userName,
password, SdkVersion.Value, Context),
_jsonSerializerOptions);
var data = new StringContent(json, Encoding.UTF8, "application/json");
diff --git
a/foreign/csharp/Iggy_SDK/IggyClient/Implementations/TcpMessageStream.cs
b/foreign/csharp/Iggy_SDK/IggyClient/Implementations/TcpMessageStream.cs
index 93a85e13e..88cfe0472 100644
--- a/foreign/csharp/Iggy_SDK/IggyClient/Implementations/TcpMessageStream.cs
+++ b/foreign/csharp/Iggy_SDK/IggyClient/Implementations/TcpMessageStream.cs
@@ -728,7 +728,8 @@ public sealed class TcpMessageStream : IIggyClient
throw new NotConnectedException();
}
- var message = TcpContracts.LoginUser(userName, password, "0.5.0",
"csharp-sdk");
+ // TODO: Add binary protocol version
+ var message = TcpContracts.LoginUser(userName, password,
SdkVersion.Value, "csharp-sdk");
var payload = new byte[4 + BufferSizes.INITIAL_BYTES_LENGTH +
message.Length];
TcpMessageStreamHelpers.CreatePayload(payload, message,
CommandCodes.LOGIN_USER_CODE);
diff --git a/foreign/csharp/Iggy_SDK/Iggy_SDK.csproj
b/foreign/csharp/Iggy_SDK/Iggy_SDK.csproj
index fc2daf430..5f58609e8 100644
--- a/foreign/csharp/Iggy_SDK/Iggy_SDK.csproj
+++ b/foreign/csharp/Iggy_SDK/Iggy_SDK.csproj
@@ -7,7 +7,7 @@
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<AssemblyName>Apache.Iggy</AssemblyName>
<RootNamespace>Apache.Iggy</RootNamespace>
- <PackageVersion>0.7.1-edge.1</PackageVersion>
+ <Version>0.7.1-edge.2</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
diff --git a/foreign/csharp/Iggy_SDK/Utils/SdkVersion.cs
b/foreign/csharp/Iggy_SDK/Utils/SdkVersion.cs
new file mode 100644
index 000000000..df3563513
--- /dev/null
+++ b/foreign/csharp/Iggy_SDK/Utils/SdkVersion.cs
@@ -0,0 +1,27 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.Reflection;
+
+namespace Apache.Iggy.Utils;
+
+internal static class SdkVersion
+{
+ internal static readonly string Value = (typeof(SdkVersion).Assembly
+ .GetCustomAttribute<AssemblyInformationalVersionAttribute>()
+ ?.InformationalVersion ?? "unknown").Split('+')[0];
+}
diff --git a/foreign/csharp/Iggy_SDK_Tests/UtilityTests/SdkVersionTests.cs
b/foreign/csharp/Iggy_SDK_Tests/UtilityTests/SdkVersionTests.cs
new file mode 100644
index 000000000..d7eebb30d
--- /dev/null
+++ b/foreign/csharp/Iggy_SDK_Tests/UtilityTests/SdkVersionTests.cs
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using Apache.Iggy.Utils;
+
+namespace Apache.Iggy.Tests.UtilityTests;
+
+public sealed class SdkVersionTests
+{
+ [Fact]
+ public void SdkVersion_ShouldNotBeNullOrUnknown()
+ {
+ var version = SdkVersion.Value;
+
+ Assert.NotNull(version);
+ Assert.NotEqual("unknown", version);
+ }
+}