diff --git a/CHANGELOG.md b/CHANGELOG.md
index b4c0fab52..e174558f9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,9 +15,12 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
- [Ruby] update dependency messages up to v26 ([#267](https://github.com/cucumber/gherkin/pull/267))
### Changed
-- [.NET] Drop unsupported frameworks. Now supported target frameworks are .NET 8, .NET Framework 4.6.2, .NET Standard 2.0 ([#265](https://github.com/cucumber/gherkin/pull/265))
+- [.NET] Drop unsupported frameworks. Now supported target frameworks are .NET 8, .NET Standard 2.0 ([#265](https://github.com/cucumber/gherkin/pull/265))
- [.NET] Adopt File Scoped Namespaces c# feature ([#271](https://github.com/cucumber/gherkin/pull/271))
- [.NET] Adopt c# 12 primary constructors ([#272](https://github.com/cucumber/gherkin/pull/272))
+- [.NET] Adopt c# 10 ImplicitUsings
+- [.NET] Replace TinyJson to System.Text.Json
+- [.NET] Enable warnings as errors
## [29.0.0] - 2024-08-12
### Added
diff --git a/dotnet/Directory.Build.props b/dotnet/Directory.Build.props
index 7f5ce1c47..e454fc19b 100644
--- a/dotnet/Directory.Build.props
+++ b/dotnet/Directory.Build.props
@@ -2,6 +2,8 @@
12
+ enable
+ true
diff --git a/dotnet/Gherkin.Specs/AstBuildingTests.cs b/dotnet/Gherkin.Specs/AstBuildingTests.cs
index 123ee8543..85f907cfc 100644
--- a/dotnet/Gherkin.Specs/AstBuildingTests.cs
+++ b/dotnet/Gherkin.Specs/AstBuildingTests.cs
@@ -1,4 +1,3 @@
-using System.Linq;
using FluentAssertions;
using Gherkin.CucumberMessages.Types;
using Gherkin.Specs.Helper;
diff --git a/dotnet/Gherkin.Specs/CLI/Program.cs b/dotnet/Gherkin.Specs/CLI/Program.cs
index 0da59e6a6..b20253fa3 100644
--- a/dotnet/Gherkin.Specs/CLI/Program.cs
+++ b/dotnet/Gherkin.Specs/CLI/Program.cs
@@ -1,10 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using Gherkin.CucumberMessages;
using Gherkin.Specs.EventStubs;
using Gherkin.Specs.Tokens;
-using Utf8Json.Resolvers;
+using System.Text.Json;
+using System.Text.Json.Serialization;
namespace Gherkin.Specs.CLI;
@@ -102,7 +100,11 @@ private static int PrintEvents(PrintEventsArgs args)
{
foreach (var evt in gherkinEventsProvider.GetEvents(sourceEventEvent))
{
- var jsonString = Utf8Json.JsonSerializer.ToJsonString((object)evt, StandardResolver.ExcludeNullCamelCase);
+ var jsonString = JsonSerializer.Serialize(evt, new JsonSerializerOptions(JsonSerializerDefaults.Web)
+ {
+ Converters = { new JsonStringEnumConverter() },
+ DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
+ });
Console.WriteLine(jsonString);
}
}
diff --git a/dotnet/Gherkin.Specs/DependencyValidationTests.cs b/dotnet/Gherkin.Specs/DependencyValidationTests.cs
new file mode 100644
index 000000000..3de8556fe
--- /dev/null
+++ b/dotnet/Gherkin.Specs/DependencyValidationTests.cs
@@ -0,0 +1,21 @@
+#if NETFRAMEWORK
+using System.Reflection;
+using System.Text.Json;
+using Xunit;
+
+namespace Gherkin.Specs;
+
+public sealed class DependencyValidationTests
+{
+ [Fact]
+ public void SystemTextJsonUpgradeBlocker()
+ {
+ // this test was made intentionally to block upgrade for system.text.json nuget package for .NET standard version of library
+ // discussion: https://github.com/cucumber/messages/pull/237#issuecomment-2225649432
+
+ var version = typeof(JsonSerializer).Assembly.GetCustomAttribute().Version;
+
+ Assert.Equal("6.0.21.52210", version); // System.Text.Json Version 6.0.0
+ }
+}
+#endif
\ No newline at end of file
diff --git a/dotnet/Gherkin.Specs/EventStubs/GherkinEventsProvider.cs b/dotnet/Gherkin.Specs/EventStubs/GherkinEventsProvider.cs
index bdbba383f..5621dd3bd 100644
--- a/dotnet/Gherkin.Specs/EventStubs/GherkinEventsProvider.cs
+++ b/dotnet/Gherkin.Specs/EventStubs/GherkinEventsProvider.cs
@@ -1,9 +1,6 @@
using Gherkin.CucumberMessages;
using Gherkin.CucumberMessages.Pickles;
using Gherkin.CucumberMessages.Types;
-using System;
-using System.Collections.Generic;
-using System.IO;
namespace Gherkin.Specs.EventStubs;
diff --git a/dotnet/Gherkin.Specs/EventStubs/SourceProvider.cs b/dotnet/Gherkin.Specs/EventStubs/SourceProvider.cs
index 5c2bc4bed..61a8416d4 100644
--- a/dotnet/Gherkin.Specs/EventStubs/SourceProvider.cs
+++ b/dotnet/Gherkin.Specs/EventStubs/SourceProvider.cs
@@ -1,6 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
using Gherkin.CucumberMessages.Types;
namespace Gherkin.Specs.EventStubs;
diff --git a/dotnet/Gherkin.Specs/EventTestBase.cs b/dotnet/Gherkin.Specs/EventTestBase.cs
index 693d9a1d0..c73639453 100644
--- a/dotnet/Gherkin.Specs/EventTestBase.cs
+++ b/dotnet/Gherkin.Specs/EventTestBase.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.IO;
using System.Text;
using FluentAssertions;
using Gherkin.CucumberMessages;
diff --git a/dotnet/Gherkin.Specs/Gherkin.Specs.csproj b/dotnet/Gherkin.Specs/Gherkin.Specs.csproj
index 803463e38..7b0e9bdbd 100644
--- a/dotnet/Gherkin.Specs/Gherkin.Specs.csproj
+++ b/dotnet/Gherkin.Specs/Gherkin.Specs.csproj
@@ -1,6 +1,7 @@
+
- net8.0
+ net8.0;net462
Exe
Gherkin.Specs.CLI.Program
@@ -8,7 +9,6 @@
-
all
diff --git a/dotnet/Gherkin.Specs/Helper/NDJsonParser.cs b/dotnet/Gherkin.Specs/Helper/NDJsonParser.cs
index 027d622e4..17e187d29 100644
--- a/dotnet/Gherkin.Specs/Helper/NDJsonParser.cs
+++ b/dotnet/Gherkin.Specs/Helper/NDJsonParser.cs
@@ -1,6 +1,6 @@
-using System;
-using System.Collections.Generic;
-using Utf8Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
namespace Gherkin.Specs.Helper;
@@ -14,7 +14,13 @@ public static List Deserialize(string ndjson)
foreach (var line in lines)
{
- var deserializedObject = JsonSerializer.Deserialize(line);
+ var deserializedObject = JsonSerializer.Deserialize(line, new JsonSerializerOptions(JsonSerializerDefaults.Web)
+ {
+ Converters =
+ {
+ new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
+ }
+ });
result.Add(deserializedObject);
}
diff --git a/dotnet/Gherkin.Specs/Helper/TestFileProvider.cs b/dotnet/Gherkin.Specs/Helper/TestFileProvider.cs
index 7d1165ec4..03dd13213 100644
--- a/dotnet/Gherkin.Specs/Helper/TestFileProvider.cs
+++ b/dotnet/Gherkin.Specs/Helper/TestFileProvider.cs
@@ -1,7 +1,3 @@
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
namespace Gherkin.Specs.Helper;
public class TestFileProvider
@@ -21,7 +17,7 @@ private static IEnumerable