Skip to content

V3.0.0 Release - Updated to latest Autofac + Improvements - #4

Merged
nfMalde merged 1 commit into
masterfrom
feat/autofac9-v3
Aug 1, 2026
Merged

V3.0.0 Release - Updated to latest Autofac + Improvements#4
nfMalde merged 1 commit into
masterfrom
feat/autofac9-v3

Conversation

@nfMalde

@nfMalde nfMalde commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Changed

  • Upgraded to Autofac 9.x
  • Resolving is roughly three times faster. Measured over 2,000,000 resolves on .NET 10: a component with
    decorated properties went from ~3.2s to ~1.0s, a component without any from ~2.0s to ~0.7s. Two things
    got it there:
    • Property metadata (the decorated properties, the service to resolve for each of them and the setter) is
      collected once per type and cached. Previously every single resolve called GetProperties() on the
      concrete type and asked every property for its attributes
    • Properties are written through emitted setters instead of PropertyInfo.SetValue, which also removes
      the boxing of every assignment
  • EasyPropInject is now added as a service middleware source instead of hooking the registry's Registered
    event and every registration's PipelineBuilding event. One middleware instance is shared by the whole
    container instead of allocating one per component registration, and AddEasyPropInject() may be called at
    any point while configuring the builder — before, after or in between registrations. The README used to
    claim it had to come first; that restriction is gone and is covered by tests
  • Shared instances are explicitly skipped once they have been activated (NewInstanceActivated), rather
    than relying on the resolve pipeline to short-circuit before the middleware is reached
  • A decorated property without a setter now throws an InvalidOperationException naming the type and the
    property instead of an opaque ArgumentException from deep inside reflection
  • FromAutofacAttribute is sealed and its ResolveFromRegisteredType is annotated as nullable

Fixed

  • Private and protected properties declared on a base class were never injected. Reflection does not
    return non-public members of base types, so the type hierarchy is now walked explicitly
  • A property whose service could not be resolved was unconditionally overwritten with null, silently
    wiping any value assigned in the constructor. The result of the resolve attempt is now respected — see
    UnresolvedPropertyBehavior if you relied on the old behaviour

@nfMalde
nfMalde merged commit 09cbb39 into master Aug 1, 2026
1 check passed
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