Skip to content

Initial import: Ais.Net.Models.Json (low-allocation polymorphic JSON) - #1

Merged
HowardvanRooijen merged 4 commits into
mainfrom
features/initial-import
Jul 23, 2026
Merged

Initial import: Ais.Net.Models.Json (low-allocation polymorphic JSON)#1
HowardvanRooijen merged 4 commits into
mainfrom
features/initial-import

Conversation

@HowardvanRooijen

Copy link
Copy Markdown
Contributor

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 $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 (message.ToJsonUtf8Bytes(), message.WriteJsonTo(writer), AisMessageBase.FromJsonUtf8(bytes)). The polymorphism is configured programmatically, so the core Ais.Net.Models types 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.BenchmarksMemoryDiagnoser serialize/deserialize benchmarks.
  • Full endjin build infrastructure (ZeroFailed build.ps1/.zf, GitVersion, CI workflows, Central Package Management, .editorconfig/stylecop.json, global.json), plus a README.md with usage and the NATS adapter example.

⚠️ CI dependency

This package depends on the Ais.Net.Models 1.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.Models 1.0.0. Once 1.0.0 is published, run a restore to seed packages.lock.json so CI locked-mode restore works.

🤖 Generated with Claude Code

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
Copilot AI review requested due to automatic review settings July 23, 2026 13:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AisMessageJson static 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.

Comment thread Solutions/.editorconfig Outdated

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
Comment on lines +14 to +15
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode Condition="$(ContinuousIntegrationBuild) == 'true'">true</RestoreLockedMode>
Comment on lines +7 to +9
<ItemGroup Label="Ais.Net.Models.Json">
<PackageVersion Include="Ais.Net.Models" Version="1.0.0" />
</ItemGroup>
Comment on lines +49 to +51
# 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
Comment thread .zf/config.ps1
Comment on lines +8 to +12
# 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"
}
HowardvanRooijen and others added 2 commits July 23, 2026 17:57
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
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

Test Results

24 tests   24 ✅  0s ⏱️
 1 suites   0 💤
 1 files     0 ❌

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
@HowardvanRooijen

Copy link
Copy Markdown
Contributor Author

Thanks for the review — dispositions below:

  1. .editorconfig invalid csharp_new_line_before_open_brace value — ✅ Fixed in bd6c92b. Replaced the invalid object_collection / typo'd object_collection_array_initalizers tokens with the valid object_collection_array_initializers.

  2. RestoreLockedMode with no packages.lock.json — ✅ Added in a1ef60b. The lock file couldn't be generated until the Ais.Net.Models dependency was published; it's now committed against the published package.

  3. Pinned to Ais.Net.Models 1.0.0 (not on the feed) — ✅ Bumped to 1.0.1 in 86c9270. 1.0.0 was tagged but failed NuGet validation; 1.0.1 is the first published 1.x and is now on nuget.org. Verified locally: restore + build + all 24 tests pass against the published package.

4 & 5. @main on the endjin GitHub Actions and the ZeroFailed build extension — Intentional, left as-is. Tracking @main for endjin's own first-party actions (endjin/Endjin.RecommendedPractices.GitHubActions) and the ZeroFailed.Build.DotNet extension is the established pattern across the endjin ecosystem (and matches the Ais.Net.Models core repo) — it's how these repos receive continuous, bot-managed updates. Third-party/GitHub actions (e.g. actions/checkout) remain SHA-pinned, which is the deliberate distinction: pin external, track first-party. Changing these would diverge from the org convention and break the auto-update flow.

@HowardvanRooijen
HowardvanRooijen merged commit 9d2f170 into main Jul 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants