Repository navigation
2.0.0: printer-agnostic library with pluggable drivers - #7
Open
simonebortolin wants to merge 16 commits into
Open
simonebortolin wants to merge 16 commits into
simonebortolin wants to merge 16 commits into
Conversation
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
|
Pre-release Windows, Linux and Android builds of 9384c5d. Updated on every push, deleted when this PR is closed. |
- 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
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01SyVioB8aypTW6FAWsFg8U3
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Library
Letra200bSharp(core) – no rendering/transport dependencies:TextLabel,BarcodeLabel,TwoDCodeLabel,ImageLabel,DinRailLabel,ComposedLabel– required content in the constructor, every option aninitproperty, so new options no longer break callers;ILabelPrinterDriver(discovery,PrinterCapabilities,ILabelRenderer, printing aLabelBitmap) – a new printer is one implementation registered withAddDriver<T>();ILabelPrintingService– discovery across drivers, previews, printing;AddLetra()builder /LabelPrinting.Create;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.Microsoft.CodeAnalysis.PublicApiAnalyzers: the 2.0.0 API (nullability included) is inPublicAPI.Shipped.txt; an undeclared (RS0016) or removed (RS0017) member fails the build.LetraHelper,RenderHelper,LetraPrinterare 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
main): the Linux native library came only from Avalonia, built for SkiaSharp 3. NowSkiaSharp.NativeAssets.Linuxmatches SkiaSharp.Tests
CI / delivery
Testjob on Linux, Windows and macOS, with TRX reports published as check runs (trx-parser) and uploaded with the TUnit HTML reports.Pack NuGet:Letra200bSharpandLetra200bSharp.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.main: Publish to GitHub Packages, Publish to nuget.org (Trusted Publishing viaNuGet/login, no stored API key – skipped while theNUGET_USERvariable isn't set) and Deploy docs to GitHub Pages.Other
SECURITY.mdfilled in (2.0.x supported, private vulnerability reporting).Before merging (repository settings)
simonebortolin/Letra200bSharp, workflowci.yml, and theNUGET_USERActions variable.Testing
dotnet test101/101 locally and in CI on Linux, Windows and macOS.🤖 Generated with Claude Code
https://claude.ai/code/session_01DRhXBxWUgnHqiT4dYByZgJ