Skip to content

Upgrade Autofac and remove the dead net462 reference assemblies - #2131

Merged
NickJosevski merged 2 commits into
mainfrom
nj/net10-prep-autofac-and-refasm
Aug 12, 2026
Merged

NickJosevski merged 2 commits into
mainfrom
nj/net10-prep-autofac-and-refasm

Conversation

@NickJosevski

@NickJosevski NickJosevski commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
Commit What
Remove the dead .NET Framework reference assemblies Microsoft.NETFramework.ReferenceAssemblies.net462, unused
Upgrade Autofac 4.8.0 → 9.3.1 No code changes needed

ContainerBuilder.Update() is the headline Autofac 5 removal and was never used here.

Neither change is required for .NET 10. Autofac 4.8.0 builds with no warnings and resolves correctly on net10.0 — measured. This is hygiene: 4.8.0 is from 2018 and only ships net45 and netstandard1.1 assets. Doing it while Calamari still targets net8 means a green net8 build proves the bump in isolation, ahead of the target-framework flip.

-one new warning is CS8714 at Calamari.Common/Plumbing/Pipeline/Resolver.cs:17 — Autofac 9's Resolve<TService> carries a notnull constraint that TBehaviour doesn't satisfy. Calamari.Common doesn't treat warnings as errors, so it builds.

Yes server will reference this when shipped.

@NickJosevski
NickJosevski marked this pull request as ready for review August 11, 2026 08:14
NickJosevski and others added 2 commits August 12, 2026 10:10
Calamari.csproj still referenced Microsoft.NETFramework.ReferenceAssemblies.net462.
That reference has done nothing since net462 was dropped as a target framework in
#1669.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Autofac 4.8.0 dates from 2018 and is five majors behind. Octopus Server already
runs 9.3.1 on net10.

Done while Calamari still targets net8. Autofac 9.3.1 resolves on net8. The DI
upgrade is therefore verified against a known-good baseline instead of being
entangled with the framework change.

Notes for reviewers. ContainerBuilder.Update() is the headline Autofac 5 removal
and was never used here. The .Update call sites in this repo belong to LibGit2Sharp.
The API surface in use is mainstream and unchanged across the version range. The
custom RegisterPrioritisedList<T> extension builds on Meta<T> and WithMetadata.
Both APIs are stable.

Verified: clean rebuild with no new warnings. 26 tests pass covering the custom
registration ordering and flavour resolution.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@NickJosevski
NickJosevski force-pushed the nj/net10-prep-autofac-and-refasm branch from 249c97c to 79505f8 Compare August 12, 2026 00:10

@zentron zentron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feels pretty low risk.

Our usage of Autofac in Calamari tends to rely on mainly simplistic registrations, we generally dont weave much magic with multiple lifetimescopes, and the whole process is pretty short lived. If testing didnt turn anything up, I think this is safe to go out despire the major bump

@NickJosevski
NickJosevski merged commit 735a69f into main Aug 12, 2026
29 checks passed
@NickJosevski
NickJosevski deleted the nj/net10-prep-autofac-and-refasm branch August 12, 2026 05:14
NickJosevski added a commit that referenced this pull request Aug 14, 2026
Script wrappers form an execution chain and file-format replacers are tried in
sequence, so a reordering changes deployment behaviour. Nothing currently
detects that: every wrapper still constructs and every command still resolves,
so the existing suite stays green.

Two guards, both PlatformAgnostic:

ContainerOrderingFixture asserts the orderings directly. The load-bearing one is
ScriptWrapperPrioritiesAreUnique - ScriptEngine sorts with OrderByDescending,
which is stable, so a shared priority silently hands the tie-break to the
container's collection ordering. Priorities are distinct today (1003/1002/1001/
1000/100), but AwsScriptWrapper, AzureContextScriptWrapper,
GoogleCloudContextScriptWrapper and AzureServiceFabricPowerShellContext all sit
on CloudAuthenticationPriority in their separate flavours, so a second cloud
wrapper in one flavour would make the chain container-dependent. The rest pin the
wrapper chain for a Kubernetes/AWS/PowerShell step, the file-format replacer
order, and discoverer key uniqueness.

ContainerSnapshotFixture compares a rendering of the whole container against an
approved file: registrations, lifetimes, collection order, and the concrete types
injected into every command. Targeted assertions only catch what someone thought
of; this catches anything observable that moves. Re-approve with
CALAMARI_APPROVE_CONTAINER_SNAPSHOT=1.

The snapshot is normalised so one file serves every platform: the OS-chosen
filesystem and certificate-store implementations collapse to placeholders,
Autofac's __RegistrationOrder tick counter is dropped, and collection fields
render distinct element types rather than counts.

Baselined at Autofac 9.3.1, matching main. The instrument was built to catch the
4.8.0 -> 9.3.1 bump, which has since landed via #2131; rebasing across it
reproduced exactly the predicted diff - the recorded version line plus five
RegisterInstance registrations gaining AutoActivate - with the five ordering
tests still passing. Those five are inert: none of the instances is IDisposable
and the codebase has no OnActivating/OnActivated handlers.

That rebase crossed eight commits of main, including Octostache 3.9.3, the
unconditional docker credential helper and a new feature toggle. Nothing outside
those six lines moved, which is the evidence that matters for a golden file: it
is stable enough not to cry wolf.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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