Skip to content

2.0.0: printer-agnostic library with pluggable drivers - #7

Open
simonebortolin wants to merge 16 commits into
mainfrom
ccr-11739362-dqtji2
Open

simonebortolin wants to merge 16 commits into
mainfrom
ccr-11739362-dqtji2

Conversation

@simonebortolin

@simonebortolin simonebortolin commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Reworks the library around a single entrypoint and pluggable printer drivers, configured OpenIddict-style, so more printers can be supported by implementing one interface. Ships it as NuGet packages with a documentation site.

services.AddLetra()
    .AddLetraTag200b(letraTag => letraTag.SetReplyTimeout(TimeSpan.FromSeconds(15)));
// or LabelPrinting.Create(letra => letra.AddLetraTag200b())

var printer = (await printing.DiscoverAsync()).First();
await printing.PrintAsync(printer, new TextLabel("Ciao") { Size = LabelTextSize.L, Formatting = new() { Bold = true } });

Library

  • Letra200bSharp (core) – no rendering/transport dependencies:
    • label model: TextLabel, BarcodeLabel, TwoDCodeLabel, ImageLabel, DinRailLabel, ComposedLabel – required content in the constructor, every option an init property, so new options no longer break callers;
    • ILabelPrinterDriver (discovery, PrinterCapabilities, ILabelRenderer, printing a LabelBitmap) – a new printer is one implementation registered with AddDriver<T>();
    • ILabelPrintingService – discovery across drivers, previews, printing; AddLetra() builder / LabelPrinting.Create;
    • optional renderer features ITwoDCodePlanner, IDinRailLayout.
  • Letra200bSharp.200b – the LetraTag 200B driver: the existing renderer, wire format and BLE transport (now internal), plus options (reply timeout, packet delay, MTU, default font) and cancellation.
  • Public API tracking with Microsoft.CodeAnalysis.PublicApiAnalyzers: the 2.0.0 API (nullability included) is in PublicAPI.Shipped.txt; an undeclared (RS0016) or removed (RS0017) member fails the build.
  • Breaking: LetraHelper, RenderHelper, LetraPrinter are gone → version 2.0.0.

The output is unchanged: 136 jobs, previews and content images (text, barcodes, 2D codes, images, DIN rail, compositions) hash identically before and after the refactor. App and CLI moved to the new API; saved history and compositions stay compatible.

Fixes

  • Linux: every render in the desktop app/CLI failed with "The version of the native libSkiaSharp library (119.0) is incompatible" (pre-existing on main): the Linux native library came only from Avalonia, built for SkiaSharp 3. Now SkiaSharp.NativeAssets.Linux matches SkiaSharp.

Tests

  • New TUnit project (101 tests): BLE protocol with a regression suite for the ESC (0x1B) chunk sequence number – including after the counter wraps past 255, and checked to fail if the skip is removed –, status codes, every rendering feature added since the original fork (font-independent assertions), driver registration with a fake printer, history migrations/JSON compatibility.

CI / delivery

  • Test job on Linux, Windows and macOS, with TRX reports published as check runs (trx-parser) and uploaded with the TUnit HTML reports.
  • Pack NuGet: Letra200bSharp and Letra200bSharp.200b (MIT, README, icon, Source Link, .snupkg), included in PR pre-releases and attached to releases.
  • Build docs: DocFX site (guide + API reference from the XML docs), warnings as errors.
  • On a new release from main: Publish to GitHub Packages, Publish to nuget.org (Trusted Publishing via NuGet/login, no stored API key – skipped while the NUGET_USER variable isn't set) and Deploy docs to GitHub Pages.
  • Pre-release and release depend on tests, packages and every app build.

Other

  • SECURITY.md filled in (2.0.x supported, private vulnerability reporting).

Before merging (repository settings)

  • Settings → Pages → Source: GitHub Actions.
  • nuget.org trusted publishing policy for simonebortolin/Letra200bSharp, workflow ci.yml, and the NUGET_USER Actions variable.
  • Settings → Code security → Private vulnerability reporting.

Testing

  • dotnet test 101/101 locally and in CI on Linux, Windows and macOS.
  • Reproduced the CI desktop publish commands for win-x64 and linux-x64; launched the Linux GUI under Xvfb and generated text and 2D previews; ran the CLI.
  • Packed both libraries and checked their metadata; built the DocFX site and viewed it in a browser.
  • Android built in CI.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ

Rework the library around a single entrypoint and pluggable printer drivers,
configured OpenIddict-style:

    services.AddLetra().AddDymoLetraTag(dymo => dymo.SetReplyTimeout(...));
    // or LabelPrinting.Create(letra => letra.AddDymoLetraTag())

Letra200bSharp (core, no rendering/transport dependencies):
- Label model: TextLabel, BarcodeLabel, TwoDCodeLabel, ImageLabel,
  DinRailLabel, ComposedLabel - required content in the constructor, every
  option an init property, so new options are no longer breaking changes.
  Enums and option types move out of LetraHelper into the namespace.
- ILabelPrinterDriver: discovery, PrinterCapabilities, ILabelRenderer and
  printing of a rendered LabelBitmap. A new printer is one implementation
  registered with LetraBuilder.AddDriver<T>().
- ILabelPrintingService: discovery across drivers, previews and printing,
  routed by PrinterInfo.Driver.
- Optional renderer features ITwoDCodePlanner and IDinRailLayout.

Letra200bSharp.Dymo: the LetraTag 200B driver - the existing renderer, wire
format and BLE transport, now internal, plus DymoLetraTagOptions (reply
timeout, packet delay, MTU, default font, name prefix) and cancellation.

The rendering and wire output are unchanged: 136 jobs, previews and content
images (text, barcodes, 2D codes, images, DIN rail, compositions) hash
identically before and after. The app and CLI move to the new API, and the
new Letra200bSharp.Tests project (run in CI) covers the protocol, driver
registration with a fake printer, and font-independent rendering.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
On Linux the native library only came from Avalonia.Skia, still built
against SkiaSharp 3 (libSkiaSharp 119), which SkiaSharp 4.153 refuses to
load: every render in the Linux desktop app and CLI failed with "The version
of the native libSkiaSharp library (119.0) is incompatible". Reference
SkiaSharp.NativeAssets.Linux at the managed SkiaSharp version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
Drop "Dymo" from the driver's names: the project becomes Letra200bSharp.200b
(namespace Letra200bSharp.LetraTag200b, since a namespace segment can't start
with a digit), with LetraTag200bDriver/Options/Builder and AddLetraTag200b().
Also restore the "is { } x" pattern in CompositionService.ToLabel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
- Tests now use TUnit and cover what was added since the original fork:
  the BLE protocol (header, chunking, packing, status codes) with a
  dedicated regression suite for the ESC (0x1B) chunk sequence number -
  never used, also after the counter wraps past 255, without losing data -,
  image thresholding and edge rows, previews, text sizes/styles/formatting/
  boxes/frame margins/alignment, every 1D symbology with auto-detection and
  captions, 2D codes, DIN rail, composition, driver registration and the
  app's history migrations and JSON compatibility.
- CI runs them in a dedicated Test job on Linux, Windows and macOS, and the
  pre-release/release jobs now depend on it.
- Test project uses plural TargetFrameworks so CI's -p:TargetFrameworks
  override doesn't skip the packages' build props.
- History parameters share an IComposablePart interface, replacing the
  if-chain in CompositionService.ToLabel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
The library's public API changed incompatibly (LetraHelper/RenderHelper/
LetraPrinter replaced by AddLetra() and pluggable drivers), so this is a new
major version. SECURITY.md was still GitHub's template: state that only 2.0.x
is supported and how to report a vulnerability privately.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
With Arial (macOS/Windows runners) an underline shrinks the glyphs to make
room for it, so the label ends up with slightly less ink than plain text and
Formatting_options_each_change_the_print failed there. Assert that bold,
underline, strikethrough and DIN rail separators change the print, not that
they add ink - how much ink they add depends on the font.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Pre-release 2.0.0-pr.7.78 is ready: https://github.com/simonebortolin/Letra200bSharp/releases/tag/pr-7-78-1

Windows, Linux and Android builds of 9384c5d. Updated on every push, deleted when this PR is closed.

claude added 10 commits October 24, 2026 13:20
- docs/: a DocFX site with a guide (getting started, labels, adding a
  printer) and the API reference generated from the libraries' XML docs.
  CI builds it on every run (warnings as errors) and deploys it to GitHub
  Pages from main.
- The libraries are packed as NuGet packages (Letra200bSharp,
  Letra200bSharp.200b) with shared metadata (build/Package.props), Source
  Link and symbol packages; the release pushes them to GitHub Packages and
  attaches them to the GitHub Release, and PR pre-releases carry them too.
- Tests write TRX (and TUnit HTML) reports, uploaded as artifacts and
  published as check runs with trx-parser, per OS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
- New publish-nuget job, after a new release: nuget.org Trusted Publishing
  (NuGet/login, OIDC - no stored key) when the NUGET_USER repository
  variable is set, or the NUGET_API_KEY secret otherwise; skipped with a
  warning when neither is configured. Symbol packages go along.
- GitHub Packages publishing moves out of the release job into its own
  publish-github job, and the docs are deployed with each new release, so
  the site documents the released packages.
- The packages get an icon, as nuget.org shows on their pages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
Drop the NUGET_API_KEY fallback: the publish-nuget job only exchanges the
workflow's OIDC token for a short-lived key through NuGet/login, so no API
key is ever stored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
Microsoft.CodeAnalysis.PublicApiAnalyzers on both packaged libraries (via
build/Package.props): their public API, nullability included, is declared in
PublicAPI.Unshipped.txt (moved to PublicAPI.Shipped.txt at release), and an
undeclared (RS0016) or removed (RS0017) member fails the build, so a
breaking change can't slip into a release unnoticed. The files were
generated with the analyzer's own code fix (dotnet format analyzers).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
Move the PublicAPI.Unshipped.txt entries of both libraries to
PublicAPI.Shipped.txt: this PR is the 2.0.0 release, so further API changes
start from an empty Unshipped file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
The net10.0-android build of Letra200bSharp.200b generates a public
Letra200bSharp.LetraTag200b.Resource class, which PublicApiAnalyzers flagged
as undeclared API (RS0016) and failed the Android APK build. The library has
no Android resources: generate the class as internal instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
LabelBitmap's indexer reads a non-zero byte as ink, but the encoder only
packed bytes equal to 1, so a bitmap built with e.g. 255 printed blank.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SyVioB8aypTW6FAWsFg8U3
It gets the workflow token with checks: write, so a moved tag shouldn't be
able to change what runs.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SyVioB8aypTW6FAWsFg8U3
Keep VersionPrefix 2.0.0 (main moved to 1.7.0 with the Avalonia 12.2.0
update): this branch carries the breaking library API change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ
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