From 6a97b1a64c7dbcd2aecc73ba15827c85e5b45ee2 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 14 Apr 2026 17:31:49 +0000
Subject: [PATCH 1/9] feat: add Encoding.Utf8WithoutBom extension
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/9a5c3164-66fa-4fa3-b551-950f51e9fc94
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
---
PowerKit.Tests/EncodingExtensionsTests.cs | 27 +++++++++++++++++++++++
PowerKit/Extensions/EncodingExtensions.cs | 16 ++++++++++++++
2 files changed, 43 insertions(+)
create mode 100644 PowerKit.Tests/EncodingExtensionsTests.cs
create mode 100644 PowerKit/Extensions/EncodingExtensions.cs
diff --git a/PowerKit.Tests/EncodingExtensionsTests.cs b/PowerKit.Tests/EncodingExtensionsTests.cs
new file mode 100644
index 0000000..7d36c26
--- /dev/null
+++ b/PowerKit.Tests/EncodingExtensionsTests.cs
@@ -0,0 +1,27 @@
+using System.Text;
+using FluentAssertions;
+using PowerKit.Extensions;
+using Xunit;
+
+namespace PowerKit.Tests;
+
+public class EncodingExtensionsTests
+{
+ [Fact]
+ public void Utf8WithoutBom_IsUtf8()
+ {
+ Encoding.Utf8WithoutBom.WebName.Should().Be("utf-8");
+ }
+
+ [Fact]
+ public void Utf8WithoutBom_HasNoBom()
+ {
+ Encoding.Utf8WithoutBom.GetPreamble().Should().BeEmpty();
+ }
+
+ [Fact]
+ public void Utf8WithoutBom_IsDifferentFromEncodingUtf8()
+ {
+ Encoding.Utf8WithoutBom.Should().NotBeSameAs(Encoding.UTF8);
+ }
+}
diff --git a/PowerKit/Extensions/EncodingExtensions.cs b/PowerKit/Extensions/EncodingExtensions.cs
new file mode 100644
index 0000000..e11c52a
--- /dev/null
+++ b/PowerKit/Extensions/EncodingExtensions.cs
@@ -0,0 +1,16 @@
+using System.Text;
+
+namespace PowerKit.Extensions;
+
+internal static class EncodingExtensions
+{
+ private static readonly Encoding Utf8WithoutBomValue = new UTF8Encoding(false);
+
+ extension(Encoding)
+ {
+ ///
+ /// Gets an instance of the UTF-8 encoding that does not emit a byte order mark (BOM).
+ ///
+ public static Encoding Utf8WithoutBom => Utf8WithoutBomValue;
+ }
+}
From 70d4ecbf7026db019ee7023b7a0c968fa5ea36a2 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 14 Apr 2026 17:33:31 +0000
Subject: [PATCH 2/9] test: fix test method naming consistency
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/9a5c3164-66fa-4fa3-b551-950f51e9fc94
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
---
PowerKit.Tests/EncodingExtensionsTests.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/PowerKit.Tests/EncodingExtensionsTests.cs b/PowerKit.Tests/EncodingExtensionsTests.cs
index 7d36c26..cae4b5d 100644
--- a/PowerKit.Tests/EncodingExtensionsTests.cs
+++ b/PowerKit.Tests/EncodingExtensionsTests.cs
@@ -20,7 +20,7 @@ public void Utf8WithoutBom_HasNoBom()
}
[Fact]
- public void Utf8WithoutBom_IsDifferentFromEncodingUtf8()
+ public void Utf8WithoutBom_IsDifferentFromUtf8()
{
Encoding.Utf8WithoutBom.Should().NotBeSameAs(Encoding.UTF8);
}
From f1612c0abe582a77dae9039c26541b8e401c53c1 Mon Sep 17 00:00:00 2001
From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com>
Date: Tue, 14 Apr 2026 20:46:28 +0300
Subject: [PATCH 3/9] Update EncodingExtensions.cs
---
PowerKit/Extensions/EncodingExtensions.cs | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/PowerKit/Extensions/EncodingExtensions.cs b/PowerKit/Extensions/EncodingExtensions.cs
index e11c52a..293e5ae 100644
--- a/PowerKit/Extensions/EncodingExtensions.cs
+++ b/PowerKit/Extensions/EncodingExtensions.cs
@@ -2,15 +2,18 @@
namespace PowerKit.Extensions;
-internal static class EncodingExtensions
+file static class EncodingEx
{
- private static readonly Encoding Utf8WithoutBomValue = new UTF8Encoding(false);
+ public static Encoding Utf8WithoutBom { get; } = new UTF8Encoding(false);
+}
+internal static class EncodingExtensions
+{
extension(Encoding)
{
///
/// Gets an instance of the UTF-8 encoding that does not emit a byte order mark (BOM).
///
- public static Encoding Utf8WithoutBom => Utf8WithoutBomValue;
+ public static Encoding Utf8WithoutBom => EncodingEx.Utf8WithoutBom;
}
}
From 16af99fff46cf9a66750c1b263da6379969d7a7c Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 14 Apr 2026 17:46:39 +0000
Subject: [PATCH 4/9] test: replace property checks with functional
encoding/decoding test
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/8a41fff1-a0a5-41ff-b43d-8a4cfe44f7d5
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
---
PowerKit.Tests/EncodingExtensionsTests.cs | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/PowerKit.Tests/EncodingExtensionsTests.cs b/PowerKit.Tests/EncodingExtensionsTests.cs
index cae4b5d..c33bce2 100644
--- a/PowerKit.Tests/EncodingExtensionsTests.cs
+++ b/PowerKit.Tests/EncodingExtensionsTests.cs
@@ -8,20 +8,15 @@ namespace PowerKit.Tests;
public class EncodingExtensionsTests
{
[Fact]
- public void Utf8WithoutBom_IsUtf8()
+ public void Utf8WithoutBom_Test()
{
- Encoding.Utf8WithoutBom.WebName.Should().Be("utf-8");
- }
+ // Arrange
+ var text = "hello, world! 🌍";
- [Fact]
- public void Utf8WithoutBom_HasNoBom()
- {
- Encoding.Utf8WithoutBom.GetPreamble().Should().BeEmpty();
- }
+ // Act
+ var bytes = Encoding.Utf8WithoutBom.GetBytes(text);
- [Fact]
- public void Utf8WithoutBom_IsDifferentFromUtf8()
- {
- Encoding.Utf8WithoutBom.Should().NotBeSameAs(Encoding.UTF8);
+ // Assert
+ Encoding.UTF8.GetString(bytes).Should().Be(text);
}
}
From 210164c918cf225e459236944078f54ec271bd38 Mon Sep 17 00:00:00 2001
From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com>
Date: Tue, 14 Apr 2026 20:48:54 +0300
Subject: [PATCH 5/9] Update PowerKit/Extensions/EncodingExtensions.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
PowerKit/Extensions/EncodingExtensions.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/PowerKit/Extensions/EncodingExtensions.cs b/PowerKit/Extensions/EncodingExtensions.cs
index 293e5ae..1248612 100644
--- a/PowerKit/Extensions/EncodingExtensions.cs
+++ b/PowerKit/Extensions/EncodingExtensions.cs
@@ -4,7 +4,7 @@ namespace PowerKit.Extensions;
file static class EncodingEx
{
- public static Encoding Utf8WithoutBom { get; } = new UTF8Encoding(false);
+ public static Encoding Utf8WithoutBom { get; } = Encoding.ReadOnly(new UTF8Encoding(false));
}
internal static class EncodingExtensions
From 6633d989a8352f792d322eb850b1f26562db3b6c Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 14 Apr 2026 17:52:09 +0000
Subject: [PATCH 6/9] revert: remove Encoding.ReadOnly() wrapper (method
doesn't exist)
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/3e50f80d-751a-4a79-8b1c-d5ee4f17034d
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
---
PowerKit/Extensions/EncodingExtensions.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/PowerKit/Extensions/EncodingExtensions.cs b/PowerKit/Extensions/EncodingExtensions.cs
index 1248612..293e5ae 100644
--- a/PowerKit/Extensions/EncodingExtensions.cs
+++ b/PowerKit/Extensions/EncodingExtensions.cs
@@ -4,7 +4,7 @@ namespace PowerKit.Extensions;
file static class EncodingEx
{
- public static Encoding Utf8WithoutBom { get; } = Encoding.ReadOnly(new UTF8Encoding(false));
+ public static Encoding Utf8WithoutBom { get; } = new UTF8Encoding(false);
}
internal static class EncodingExtensions
From 0f4e3297f97250684ae2f410d7e1d8f746d9f742 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 14 Apr 2026 19:07:43 +0000
Subject: [PATCH 7/9] refactor: replace ZipArchiveEntryExtensions.Utf8NoBom
with Encoding.Utf8WithoutBom
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/4080f2c4-800e-4e10-bfb4-763d281faafc
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
---
.../Extensions/ZipArchiveEntryExtensions.cs | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/PowerKit/Extensions/ZipArchiveEntryExtensions.cs b/PowerKit/Extensions/ZipArchiveEntryExtensions.cs
index 7011795..c40822f 100644
--- a/PowerKit/Extensions/ZipArchiveEntryExtensions.cs
+++ b/PowerKit/Extensions/ZipArchiveEntryExtensions.cs
@@ -10,8 +10,6 @@ namespace PowerKit.Extensions;
internal static class ZipArchiveEntryExtensions
{
- private static readonly Encoding Utf8NoBom = new UTF8Encoding(false);
-
extension(ZipArchiveEntry entry)
{
///
@@ -42,7 +40,7 @@ public void WriteAllBytes(byte[] bytes)
public string ReadAllText(Encoding? encoding = null)
{
using var stream = entry.Open();
- using var reader = new StreamReader(stream, encoding ?? Utf8NoBom);
+ using var reader = new StreamReader(stream, encoding ?? Encoding.Utf8WithoutBom);
return reader.ReadToEnd();
}
@@ -53,7 +51,7 @@ public string ReadAllText(Encoding? encoding = null)
public void WriteAllText(string text, Encoding? encoding = null)
{
using var stream = entry.Open();
- using var writer = new StreamWriter(stream, encoding ?? Utf8NoBom);
+ using var writer = new StreamWriter(stream, encoding ?? Encoding.Utf8WithoutBom);
writer.Write(text);
}
@@ -64,7 +62,7 @@ public void WriteAllText(string text, Encoding? encoding = null)
public string[] ReadAllLines(Encoding? encoding = null)
{
using var stream = entry.Open();
- using var reader = new StreamReader(stream, encoding ?? Utf8NoBom);
+ using var reader = new StreamReader(stream, encoding ?? Encoding.Utf8WithoutBom);
var lines = new List();
while (reader.ReadLine() is { } line)
@@ -81,7 +79,7 @@ public string[] ReadAllLines(Encoding? encoding = null)
public void WriteAllLines(IEnumerable lines, Encoding? encoding = null)
{
using var stream = entry.Open();
- using var writer = new StreamWriter(stream, encoding ?? Utf8NoBom);
+ using var writer = new StreamWriter(stream, encoding ?? Encoding.Utf8WithoutBom);
foreach (var line in lines)
{
@@ -126,7 +124,7 @@ public async Task ReadAllTextAsync(
)
{
using var stream = entry.Open();
- using var reader = new StreamReader(stream, encoding ?? Utf8NoBom);
+ using var reader = new StreamReader(stream, encoding ?? Encoding.Utf8WithoutBom);
return await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
}
@@ -141,7 +139,7 @@ public async Task WriteAllTextAsync(
)
{
using var stream = entry.Open();
- using var writer = new StreamWriter(stream, encoding ?? Utf8NoBom);
+ using var writer = new StreamWriter(stream, encoding ?? Encoding.Utf8WithoutBom);
await writer.WriteAsync(text.AsMemory(), cancellationToken).ConfigureAwait(false);
await writer.FlushAsync(cancellationToken).ConfigureAwait(false);
@@ -156,7 +154,7 @@ public async Task ReadAllLinesAsync(
)
{
using var stream = entry.Open();
- using var reader = new StreamReader(stream, encoding ?? Utf8NoBom);
+ using var reader = new StreamReader(stream, encoding ?? Encoding.Utf8WithoutBom);
var lines = new List();
while (await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false) is { } line)
@@ -177,7 +175,7 @@ public async Task WriteAllLinesAsync(
)
{
using var stream = entry.Open();
- using var writer = new StreamWriter(stream, encoding ?? Utf8NoBom);
+ using var writer = new StreamWriter(stream, encoding ?? Encoding.Utf8WithoutBom);
foreach (var line in lines)
{
From 97c15d9c9ad641d02057e8387e43901a268e07d1 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 14 Apr 2026 19:12:43 +0000
Subject: [PATCH 8/9] fix: wrap ZipArchiveEntryExtensions in NET40+ guard;
reads use Encoding.UTF8 for BOM handling
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/634e2076-ae0d-4954-8810-0e0ec002275c
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
---
PowerKit/Extensions/ZipArchiveEntryExtensions.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/PowerKit/Extensions/ZipArchiveEntryExtensions.cs b/PowerKit/Extensions/ZipArchiveEntryExtensions.cs
index c40822f..8d2c6dc 100644
--- a/PowerKit/Extensions/ZipArchiveEntryExtensions.cs
+++ b/PowerKit/Extensions/ZipArchiveEntryExtensions.cs
@@ -8,6 +8,7 @@
namespace PowerKit.Extensions;
+#if NET40_OR_GREATER || NETSTANDARD || NET
internal static class ZipArchiveEntryExtensions
{
extension(ZipArchiveEntry entry)
@@ -40,7 +41,7 @@ public void WriteAllBytes(byte[] bytes)
public string ReadAllText(Encoding? encoding = null)
{
using var stream = entry.Open();
- using var reader = new StreamReader(stream, encoding ?? Encoding.Utf8WithoutBom);
+ using var reader = new StreamReader(stream, encoding ?? Encoding.UTF8);
return reader.ReadToEnd();
}
@@ -62,7 +63,7 @@ public void WriteAllText(string text, Encoding? encoding = null)
public string[] ReadAllLines(Encoding? encoding = null)
{
using var stream = entry.Open();
- using var reader = new StreamReader(stream, encoding ?? Encoding.Utf8WithoutBom);
+ using var reader = new StreamReader(stream, encoding ?? Encoding.UTF8);
var lines = new List();
while (reader.ReadLine() is { } line)
@@ -87,7 +88,6 @@ public void WriteAllLines(IEnumerable lines, Encoding? encoding = null)
}
}
-#if NET40_OR_GREATER || NETSTANDARD || NET
///
/// Reads all bytes from the zip archive entry asynchronously.
///
@@ -124,7 +124,7 @@ public async Task ReadAllTextAsync(
)
{
using var stream = entry.Open();
- using var reader = new StreamReader(stream, encoding ?? Encoding.Utf8WithoutBom);
+ using var reader = new StreamReader(stream, encoding ?? Encoding.UTF8);
return await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
}
@@ -154,7 +154,7 @@ public async Task ReadAllLinesAsync(
)
{
using var stream = entry.Open();
- using var reader = new StreamReader(stream, encoding ?? Encoding.Utf8WithoutBom);
+ using var reader = new StreamReader(stream, encoding ?? Encoding.UTF8);
var lines = new List();
while (await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false) is { } line)
@@ -186,6 +186,6 @@ await writer
await writer.FlushAsync(cancellationToken).ConfigureAwait(false);
}
-#endif
}
}
+#endif
From 6a80d707cf3756ce0adfebac8e0aee35c128826a Mon Sep 17 00:00:00 2001
From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com>
Date: Tue, 14 Apr 2026 22:15:32 +0300
Subject: [PATCH 9/9] Update ZipArchiveEntryExtensions.cs
---
PowerKit/Extensions/ZipArchiveEntryExtensions.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/PowerKit/Extensions/ZipArchiveEntryExtensions.cs b/PowerKit/Extensions/ZipArchiveEntryExtensions.cs
index 8d2c6dc..ca0ae70 100644
--- a/PowerKit/Extensions/ZipArchiveEntryExtensions.cs
+++ b/PowerKit/Extensions/ZipArchiveEntryExtensions.cs
@@ -1,3 +1,4 @@
+#if NET40_OR_GREATER || NETSTANDARD || NET
using System;
using System.Collections.Generic;
using System.IO;
@@ -8,7 +9,6 @@
namespace PowerKit.Extensions;
-#if NET40_OR_GREATER || NETSTANDARD || NET
internal static class ZipArchiveEntryExtensions
{
extension(ZipArchiveEntry entry)