Skip to content

Add netstandard2.0 support for Roslyn analyzer hosting and tests - #29

Merged
Malcolmnixon merged 1 commit into
mainfrom
feature/netstandard2.0-support
Jul 28, 2026
Merged

Add netstandard2.0 support for Roslyn analyzer hosting and tests#29
Malcolmnixon merged 1 commit into
mainfrom
feature/netstandard2.0-support

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

This pull request introduces support for the netstandard2.0 target to the rendering model, abstractions, layout engine, and SVG renderer packages, enabling them to be used within Roslyn analyzers and source generators. It also ensures deterministic behavior across all supported frameworks by replacing unstable sorts with stable ordering in key algorithms, and documents these changes and their motivations throughout the codebase and documentation. Additionally, it introduces a custom MinHeap implementation for consistent routing and updates platform requirements and verification documentation accordingly.

Platform and Targeting Support

  • Added netstandard2.0 as a target framework in the project files for DemaConsulting.Rendering.Abstractions and DemaConsulting.Rendering.Layout, enabling use in Roslyn analyzers and source generators. [1] [2]
  • Updated documentation and the README.md to clarify which packages support netstandard2.0, the rationale for this, and that the raster renderer is excluded due to native dependencies. [1] [2] [3] [4] [5] [6]

Determinism and Stable Ordering

  • Replaced all uses of unstable Sort with stable OrderBy in algorithms (e.g., connector label placement, crossing minimization, long edge joining) to ensure identical results across .NET Core and .NET Framework. [1] [2] [3]
  • Updated array initialization from Array.Fill to explicit loops for compatibility with netstandard2.0. [1] [2]

Engine and Implementation Details

  • Introduced a custom MinHeap implementation for the orthogonal edge router, ensuring a single, deterministic priority queue across all frameworks.
  • Registered the new MinHeap file for review tracking. (.reviewmark.yaml)
  • Minor update to hash code calculation for improved compatibility.

Verification and Requirements

  • Added a new platform requirement and associated tests for netstandard2.0 support in rendering components to the requirements YAML and verification documentation. [1] [2] [3]

These changes collectively ensure that the rendering libraries are compatible with Roslyn analyzers, behave deterministically across all supported .NET targets, and have clear documentation and verification for these guarantees.

Add a netstandard2.0 target to the model, contracts, layout, and SVG
packages so they can be referenced from a Roslyn analyzer or source
generator, which the compiler loads into a netstandard2.0 context. The
raster package is excluded because it depends on SkiaSharp's native
assets.

Rather than adding compatibility shims or conditional compilation, the
few call sites that used .NET Core-only APIs are rewritten so the same
code compiles and behaves identically on every target framework:

- SvgRenderer drops the redundant CultureInfo argument from its
  StringBuilder interpolation calls. Every hole was already an
  invariant-formatted string, except sweep, which is now a string.
  It also drops StringComparison.Ordinal from Replace calls, which
  is the default for the two-argument overload.
- OrthogonalEdgeRouter uses a new engine-owned MinHeap in place of
  PriorityQueue. MinHeap mirrors the framework four-ary heap exactly,
  so tied states are expanded in the same order on every target.
- HashCode.Combine and Array.Fill are replaced with inline equivalents.

Three unstable List<T>.Sort calls are replaced with stable ordering so
tie order no longer depends on the host runtime.

The four test projects gain a Windows-only net481 target, which binds
the suite to the netstandard2.0 assets and provides the evidence for
Rendering-Platform-NetStandard20.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Malcolmnixon
Malcolmnixon merged commit 3a478e5 into main Jul 28, 2026
6 checks passed
@Malcolmnixon
Malcolmnixon deleted the feature/netstandard2.0-support branch July 28, 2026 00:57
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.

1 participant