Skip to content

DW-41: Upgrade System.Memory family to 4.6.x for netstandard2.0, declare it in the nuspec, add CI reference check - #159

Open
Sawraz-IS wants to merge 2 commits into
developfrom
system-memory-4.6-family
Open

Sawraz-IS wants to merge 2 commits into
developfrom
system-memory-4.6-family

Conversation

@Sawraz-IS

Copy link
Copy Markdown
Collaborator

Summary

Upgrades the System.* compatibility packages used by the netstandard2.0 build (what .NET Framework apps get) to the 4.6.x family, declares them in the nuspec, and adds a CI check so a System.* version mismatch can't ship again. This is step 1 of moving off the OCR-372 System.Memory 4.5.5 pin, and a prerequisite for SkiaSharp (which needs System.Memory 4.6.3 on .NET Framework).

It also fixes a live bug. The published IronSoftware.System.Drawing 2026.8.2 fails in a plain .NET Framework 4.8 console app:

FileLoadException: Could not load file or assembly 'System.Memory, Version=4.0.1.2 ...'

IronSoftware.Drawing.Common.dll is compiled against System.Memory 4.5.5 (assembly 4.0.1.2), which SkiaSharp and Maui.Graphics pull in at build time. The nuspec declares no System.Memory dependency, so a consumer only restores ImageSharp's minimum, 4.5.4 (assembly 4.0.1.1). That's the same class of bug as OCR-372.

Changes

  • IronSoftware.Drawing/SystemPackages.props (new, imported by IronSoftware.Drawing.Common.csproj, netstandard2.0 only). These four ship together and must be upgraded together:

    Package Was (transitive) Now Assembly version
    System.Memory 4.5.5 4.6.3 4.0.5.0 (net462) / 4.0.2.0 (netstandard2.0)
    System.Buffers 4.5.1 4.6.1 4.0.5.0
    System.Numerics.Vectors 4.5.0 4.6.1 4.1.6.0
    System.Runtime.CompilerServices.Unsafe 5.0.0 6.1.2 6.0.3.0
  • NuGet/IronSoftware.Drawing.nuspec: the four packages are now declared in the netstandard2.0 dependency group, at the same versions we compile against. The release note gives the binding-redirect versions. net6.0 is unchanged.

  • CI/scripts/Test-SystemAssemblyReferences.ps1 plus a new step in build_drawing_libraries.yml right after the build. For every netstandard2.0 / .NET Framework group in the nuspec, it reads the DLLs that group ships and fails if any of them:

    • references a watched System.* assembly (Memory, Buffers, Vectors, Unsafe, Threading.Tasks.Extensions, Bcl.AsyncInterfaces, Text.Json, Text.Encodings.Web) without a declared dependency, or
    • references it at a higher version than the declared package provides (the lowest across its net462 / netstandard2.0 lib folders).

Testing

  • Build: full solution, Release, 0 errors.

  • Tests: net8.0 423/423 passed; net48 409/409 passed. The net48 test output deploys Memory 4.0.5.0, Buffers 4.0.5.0, Vectors 4.1.6.0 and Unsafe 6.0.3.0, and the generated binding redirects match the release-note versions.

  • CI check:

    • Passes on this branch.
    • Fails, as intended, against a nuspec with the System.Memory dependency removed (the post-OCR-372 state).
    • Fails, as intended, against one declaring System.Memory 4.5.5 (references System.Memory 4.0.2.0, but the declared System.Memory 4.5.5 only provides 4.0.1.2).
  • Package: packed with nuget.exe 6.2.1 using the deploy job's layout (bin/Release + NuGet/). lib/netstandard2.0 and lib/net60 are present, and the packed nuspec lists the four new dependencies. (NU5501 about lib/net60 folder naming was already there.)

  • .NET Framework 4.8 consumer apps against the local package (load and export PNG, JPEG, BMP, multi-page TIFF, WebP):

    Scenario Result
    SDK-style console app ✅
    Same app + System.Text.Json 10.0.13 (which itself needs System.Memory 4.6.3) ✅
    App that pins System.Memory 4.5.5 directly ✅ Clear NU1605 downgrade build error instead of a runtime crash
    AutoGenerateBindingRedirects=false, no redirects ❌ FileLoadException (expected: shows the redirects are required)
    Same, plus the redirect block below in App.config ✅
    App with a stale hand-written 4.0.1.2 redirect (upgrade case) ✅ Automatic redirects override it
    Baseline: published 2026.8.2, plain SDK-style app ❌ FileLoadException System.Memory 4.0.1.2
  • Not tested: old-style packages.config projects and ASP.NET Web Site projects in Visual Studio. They need the redirect block if VS doesn't add it.

Binding redirects (for customers who maintain them by hand)

<dependentAssembly><assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /><bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" /></dependentAssembly>
<dependentAssembly><assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /><bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" /></dependentAssembly>
<dependentAssembly><assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /><bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" /></dependentAssembly>
<dependentAssembly><assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /><bindingRedirect oldVersion="0.0.0.0-4.1.6.0" newVersion="4.1.6.0" /></dependentAssembly>

Downstream impact (read before releasing)

  • Products that pin System.Memory 4.5.5 directly (IronPdf, OpenXmlPowerTools, IronSoftware.Chrome, IronSoftware.Pdfium, IronWord, IronOcr, IronBarCode) get a NU1605 build error when they adopt this version. That's intentional: they must move to the same four versions in the same release and declare them in their own nuspecs. The same CI check can be copied into those repos; it also covers merged DLLs, which is exactly how OCR-372 happened.
  • This branch is based on develop, which doesn't have DW-38 yet. Expect small csproj/nuspec conflicts with the DW-38 branch (TargetFrameworks line, nuspec groups). Both changes should be kept.

🤖 Generated with Claude Code

@Sawraz-IS
Sawraz-IS changed the base branch from develop to DW-38-imagesharp-v4-framework-support October 23, 2026 08:26
Base automatically changed from DW-38-imagesharp-v4-framework-support to develop December 2, 2026 02:32

@mee-ironsoftware mee-ironsoftware left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 Automated /scrutinize review — not yet read by @mee-ironsoftware.

Automated review — verdict: ship

Blockers: 0 · Major: 0 · Nits: 4 — 3 inline, 1 in this body.

This is deliberately a comment only: it never approves and never requests changes. The verdict above is advisory; @mee-ironsoftware will follow up.

Compiles the netstandard2.0 build against System.Memory 4.6.3 / Buffers 4.6.1 / Vectors 4.6.1 / Unsafe 6.1.2, declares the same four in the nuspec, and adds a CI check that compares the shipped DLL's assembly references with the nuspec. Traced props → csproj → nuspec → CI script: the versions are consistent (System.Memory 4.6.3's own nuspec depends on exactly those three) and the check works on …

Full summary

Compiles the netstandard2.0 build against System.Memory 4.6.3 / Buffers 4.6.1 / Vectors 4.6.1 / Unsafe 6.1.2, declares the same four in the nuspec, and adds a CI check that compares the shipped DLL's assembly references with the nuspec. Traced props → csproj → nuspec → CI script: the versions are consistent (System.Memory 4.6.3's own nuspec depends on exactly those three) and the check works on the windows-latest build agent. Only nits remain. Note: the head already contains DW-38 (451786e), so the PR description's DW-38 conflict warning is out of date.

Findings outside the diff

These lines are not in this PR's diff, so they cannot be inline comments — but they are part of the review.

  • Nit (no file) — Root cause is the hand-maintained nuspec; consider generating it from the csproj later
    OCR-372 and this bug both come from the nuspec dependency list drifting away from the csproj's PackageReferences. The CI check catches the System.* subset after the fact. dotnet pack from the csproj (with PrivateAssets where a reference shouldn't flow) would derive the dependency groups automatically and remove this class of bug for every package. The check is a reasonable step for now. This is not a blocker for this PR.

Reviewed head SHA 935ba85ade3f550a90ff430276652228c7f9e8d9. Re-request review on this PR to get a fresh pass.

Comment thread NuGet/IronSoftware.Drawing.nuspec Resolved
@Sawraz-IS Sawraz-IS changed the title Upgrade System.Memory family to 4.6.x for netstandard2.0, declare it in the nuspec, add CI reference check DW-41: Upgrade System.Memory family to 4.6.x for netstandard2.0, declare it in the nuspec, add CI reference check Dec 3, 2026
Sawraz-IS added a commit that referenced this pull request Dec 3, 2026

@ikkyuland ikkyuland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ikkyu's bot auto-review (not from human)

Status: APPROVE. No findings.

The netstandard2.0 build now compiles against the System.Memory 4.6.x family, and the nuspec declares the same four versions. Test-SystemAssemblyReferences.ps1 reads each shipped DLL and compares every watched reference with the assembly in the declared package. Commit 9a9275e fixes the three earlier nits (drift message, NU1605 release note, path separators), and I checked each fix in the full script.

Note: the Azure IronDrawing PR Validation run for 9a9275e is still queued. Make sure that the new "Check System.* assembly references against nuspec" step passes before you merge.

…declare it in the nuspec, and add a CI reference check
…ing, make the reference check path handling portable, and note the NU1605 requirement in the release notes
@Sawraz-IS
Sawraz-IS force-pushed the system-memory-4.6-family branch from 9a9275e to 366bd1f Compare December 3, 2026 07:21
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.

3 participants