From c60c9cb7af7c4696dd13c0c01845c57c186eb8e3 Mon Sep 17 00:00:00 2001
From: Wizou <11647984+wiz0u@users.noreply.github.com>
Date: Tue, 3 Feb 2026 02:34:33 +0100
Subject: [PATCH] fix warnings/suggests
---
README.md | 2 +-
src/Client.Helpers.cs | 4 ++--
src/Client.cs | 2 ++
src/Compat.cs | 2 +-
src/WTelegramClient.csproj | 2 +-
5 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 75fd39d..dc55f6f 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[](https://www.nuget.org/packages/WTelegramClient/absoluteLatest)
[](https://buymeacoffee.com/wizou)
-## *_Telegram Client API library written 100% in C# and .NET_*
+## *Telegram Client API library written 100% in C# and .NET*
This library allows you to connect to Telegram and control a user programmatically (or a bot, but [WTelegramBot](https://www.nuget.org/packages/WTelegramBot) is much easier for that).
All the Telegram Client APIs (MTProto) are supported so you can do everything the user could do with a full Telegram GUI client.
diff --git a/src/Client.Helpers.cs b/src/Client.Helpers.cs
index 8a3768f..eb0f8a6 100644
--- a/src/Client.Helpers.cs
+++ b/src/Client.Helpers.cs
@@ -899,8 +899,8 @@ namespace WTelegram
var mc = await this.Channels_GetChannels(new InputChannel(chatId, 0));
if (!mc.chats.TryGetValue(chatId, out chat))
throw new WTException($"Channel {chatId} not found");
- else if (chats != null)
- chats[chatId] = chat;
+ else
+ chats?[chatId] = chat;
}
}
else
diff --git a/src/Client.cs b/src/Client.cs
index ce16017..316dfc0 100644
--- a/src/Client.cs
+++ b/src/Client.cs
@@ -391,7 +391,9 @@ namespace WTelegram
_reactorReconnects = 0;
if (_reactorReconnects == 0)
throw;
+#pragma warning disable CA2016
await Task.Delay(5000);
+#pragma warning restore CA2016
if (_networkStream == null) return; // Dispose has been called in-between
await ConnectAsync(); // start a new reactor after 5 secs
lock (_pendingRpcs) // retry all pending requests
diff --git a/src/Compat.cs b/src/Compat.cs
index 4e9f9dc..31f26d8 100644
--- a/src/Compat.cs
+++ b/src/Compat.cs
@@ -75,7 +75,7 @@ namespace WTelegram
static class Convert
{
internal static string ToHexString(byte[] data) => BitConverter.ToString(data).Replace("-", "");
- internal static byte[] FromHexString(string hex) => Enumerable.Range(0, hex.Length / 2).Select(i => System.Convert.ToByte(hex.Substring(i * 2, 2), 16)).ToArray();
+ internal static byte[] FromHexString(string hex) => [.. Enumerable.Range(0, hex.Length / 2).Select(i => System.Convert.ToByte(hex.Substring(i * 2, 2), 16))];
}
public class RandomNumberGenerator
{
diff --git a/src/WTelegramClient.csproj b/src/WTelegramClient.csproj
index 524af21..02e519b 100644
--- a/src/WTelegramClient.csproj
+++ b/src/WTelegramClient.csproj
@@ -28,7 +28,7 @@ $(ReleaseNotes)
Telegram;MTProto;Client;Api;UserBot
README.md
$(ReleaseNotes)
- NETSDK1138;CS0419;CS1573;CS1591
+ NETSDK1138;CS0419;CS1573;CS1591;CA1850
TRACE;OBFUSCATION;MTPG