Initial import: Ais.Net.Models.Json (low-allocation polymorphic JSON) - #1
Conversation
Low-allocation, UTF-8-first, polymorphic System.Text.Json serialization for the Ais.Net.Models AIS message types, for broadcasting decoded messages over byte-oriented transports such as NATS and reconstructing the concrete .NET type on receipt. - Source-generated (reflection-free) System.Text.Json; polymorphic round-trip via a $type discriminator; enums as numbers; nulls omitted. - Public API: static AisMessageJson (SerializeToUtf8Bytes; Serialize into an IBufferWriter<byte> or a reusable Utf8JsonWriter; Deserialize from ReadOnlySpan<byte>; Options/TypeInfo), plus C# 14 extension members. - 24 round-trip/discriminator/parity tests and MemoryDiagnoser benchmarks. - endjin build infrastructure (ZeroFailed build.ps1/.zf, GitVersion, CI workflows, Central Package Management, .editorconfig/stylecop, global.json). Depends on the Ais.Net.Models package (1.0.0 or later). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3BkmohCNRYGY1RBKbNaCx
There was a problem hiding this comment.
Pull request overview
Initial import of Ais.Net.Models.Json, a UTF-8-first, low-allocation System.Text.Json serializer for Ais.Net.Models AIS message types, using a $type discriminator for polymorphic round-tripping, plus accompanying specs, benchmarks, and build/CI scaffolding.
Changes:
- Added the
AisMessageJsonstatic API, source-generation context, and C# extension members for UTF-8 JSON serialization/deserialization. - Added MSTest specs validating round-tripping, discriminator behavior, null omission, buffer-writer output, and enum formatting; plus BenchmarkDotNet benchmarks.
- Added build infrastructure (ZeroFailed/Endjin), central package management, GitHub Actions workflows, and documentation/licensing.
Reviewed changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Solutions/stylecop.json | Adds StyleCop analyzer settings file required by Endjin tooling. |
| Solutions/Directory.Packages.props | Enables Central Package Management and pins package versions. |
| Solutions/Ais.Net.Models.Json/AisMessageJsonExtensions.cs | Adds C# extension members over AisMessageJson for ergonomics. |
| Solutions/Ais.Net.Models.Json/AisMessageJsonContext.cs | Adds STJ source-generated context for reflection-free metadata. |
| Solutions/Ais.Net.Models.Json/AisMessageJson.cs | Implements polymorphic UTF-8 JSON serialization/deserialization with $type discriminator. |
| Solutions/Ais.Net.Models.Json/Ais.Net.Models.Json.csproj | Adds the main library project targeting net10.0 with packaging metadata. |
| Solutions/Ais.Net.Models.Json.Specs/AssemblyInfo.cs | Configures MSTest parallelization. |
| Solutions/Ais.Net.Models.Json.Specs/AisMessageJsonTests.cs | Adds serialization/deserialization specs for discriminator/null omission/buffer writer/etc. |
| Solutions/Ais.Net.Models.Json.Specs/Ais.Net.Models.Json.Specs.csproj | Adds the specs project and restore lock configuration. |
| Solutions/Ais.Net.Models.Json.slnx | Adds solution definition including library/specs/benchmarks projects. |
| Solutions/Ais.Net.Models.Json.Benchmarks/Program.cs | Adds BenchmarkDotNet entrypoint using BenchmarkSwitcher. |
| Solutions/Ais.Net.Models.Json.Benchmarks/JsonSerializationBenchmarks.cs | Adds benchmarks for byte array vs buffer writer vs pooled writer paths, plus deserialization. |
| Solutions/Ais.Net.Models.Json.Benchmarks/Ais.Net.Models.Json.Benchmarks.csproj | Adds the benchmarks project referencing the library. |
| Solutions/.editorconfig | Adds repo formatting/analyzer configuration. |
| README.md | Adds usage docs and NATS adapter example. |
| LICENSE | Adds Apache 2.0 license text. |
| imm.yaml | Adds engineering standards/metadata file. |
| global.json | Pins .NET SDK and MSTest SDK version. |
| GitVersion.yml | Adds GitVersion configuration. |
| build.ps1 | Adds ZeroFailed/InvokeBuild-based build entrypoint script. |
| .zf/config.ps1 | Adds ZeroFailed build configuration and solution selection. |
| .gitignore | Adds Visual Studio/.NET ignore rules and build artifact ignores. |
| .github/workflows/dependabot_approve_and_label.yml | Adds Dependabot automation workflow. |
| .github/workflows/build.yml | Adds CI build workflow using Endjin reusable pipeline. |
| .github/workflows/auto_release.yml | Adds auto-release/tagging workflow logic. |
| .gitattributes | Adds line-ending/text normalization rules. |
Comments suppressed due to low confidence (1)
.github/workflows/build.yml:62
- The reusable workflow is referenced at
@main, which makes the pipeline non-reproducible and introduces supply-chain risk (upstream changes can affect your builds without a PR here). Consider pinning to a specific tag or commit SHA.
build:
needs: prepareConfig
uses: endjin/Endjin.RecommendedPractices.GitHubActions/.github/workflows/scripted-build-matrix-pipeline.yml@main
with:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| csharp_new_line_before_catch = true | ||
| csharp_new_line_before_else = true | ||
| csharp_new_line_before_open_brace = object_collection, object_collection_array_initalizers, accessors, lambdas, control_blocks, methods, properties, types |
| <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> | ||
| <RestoreLockedMode Condition="$(ContinuousIntegrationBuild) == 'true'">true</RestoreLockedMode> |
| <ItemGroup Label="Ais.Net.Models.Json"> | ||
| <PackageVersion Include="Ais.Net.Models" Version="1.0.0" /> | ||
| </ItemGroup> |
| # Declare any environment variables and/or secrets that need to be available inside the build process | ||
| - uses: endjin/Endjin.RecommendedPractices.GitHubActions/actions/prepare-env-vars-and-secrets@main | ||
| id: prepareEnvVarsAndSecrets |
| # References the extension from its GitHub repository. If not already installed, use latest version from 'main' will be downloaded. | ||
| Name = "ZeroFailed.Build.DotNet" | ||
| GitRepository = "https://github.com/zerofailed/ZeroFailed.Build.DotNet" | ||
| GitRef = "main" | ||
| } |
1.0.0 was tagged but never published (NuGet validation); 1.0.1 is the first published 1.x release. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3BkmohCNRYGY1RBKbNaCx
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3BkmohCNRYGY1RBKbNaCx
Test Results24 tests 24 ✅ 0s ⏱️ Results for commit bd6c92b. ♻️ This comment has been updated with latest results. |
Replace the invalid/typo tokens (object_collection, object_collection_array_initalizers) with the valid object_collection_array_initializers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3BkmohCNRYGY1RBKbNaCx
|
Thanks for the review — dispositions below:
4 & 5. |
Initial import of the low-allocation, UTF-8-first, polymorphic System.Text.Json serialization package for the Ais.Net.Models AIS message types — for broadcasting decoded messages over byte-oriented transports such as NATS and reconstructing the concrete .NET type on receipt.
Contents
Ais.Net.Models.Json— source-generated (reflection-free)System.Text.Json; polymorphic round-trip via a$typediscriminator; enums as numbers; nulls omitted. Public API: staticAisMessageJson(SerializeToUtf8Bytes; serialize into anIBufferWriter<byte>or a reusableUtf8JsonWriter; deserialize fromReadOnlySpan<byte>;Options/TypeInfo) plus C# 14 extension members (message.ToJsonUtf8Bytes(),message.WriteJsonTo(writer),AisMessageBase.FromJsonUtf8(bytes)). The polymorphism is configured programmatically, so the coreAis.Net.Modelstypes carry no JSON attributes.Ais.Net.Models.Json.Specs— 24 round-trip / discriminator / null-omission / buffer-writer / enum-format / extension-member tests.Ais.Net.Models.Json.Benchmarks—MemoryDiagnoserserialize/deserialize benchmarks.build.ps1/.zf, GitVersion, CI workflows, Central Package Management,.editorconfig/stylecop.json,global.json), plus aREADME.mdwith usage and the NATS adapter example.This package depends on the
Ais.Net.Models1.0.0 package, which is not yet published (it is in flight as ais-dotnet/Ais.Net.Models#8). CI here will not build until that 1.0.0 release is on NuGet/GitHub Packages.Verified locally — build succeeds and all 24 tests pass — against a local pack of
Ais.Net.Models1.0.0. Once 1.0.0 is published, run a restore to seedpackages.lock.jsonso CI locked-mode restore works.🤖 Generated with Claude Code