Skip to content

Releases: DevTeam/Pure.DI

2.5.0

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 07 Jul 14:08

❗ Breaking Changes

  • [Bind] Member Exports Renamed to [Export] β€” The attribute used to expose fields, properties, and methods as bindings is now ExportAttribute.
    • Replace member-level [Bind] usage with [Export].
    • BindAttribute now represents implementation-level bindings.
    • Related terminology was aligned from β€œexposed roots” to β€œexported roots”; use RootKinds.Exported instead of RootKinds.Exposed.

πŸš€ New Features

  • Implementation-Level Binding Attributes β€” Pure.DI can now discover bindings declared directly on implementation types.

    • Use [Bind(typeof(IContract), Lifetime.Singleton, "tag")] to declare contract, lifetime, and tags on a class or struct.
    • Built-in Type, Tag, and new Lifetime attributes can now participate in implementation binding metadata.
    • Multiple contracts and tags in the same attribute group are merged into one binding.
    • Separate Bind attribute groups on the same implementation create separate bindings.
    • Generic marker contracts such as typeof(IBox<TT>) are supported for generic implementations.
    • See readme/bind-attribute.md.
  • Custom Binding Attributes

    • Custom attributes can now be registered as implementation-level binding metadata.
    • TypeAttribute<T>(), TagAttribute<T>(), and the new LifetimeAttribute<T>() allow Pure.DI to read contract, tag, and lifetime metadata from custom attribute constructor arguments.
    • This enables implementation assemblies to describe their DI role while keeping composition setup concise.
    • See readme/custom-bind-attribute.md.
  • Export Attribute for Member-Based Bindings

    • New ExportAttribute replaces member-level BindAttribute for fields, properties, and methods.
    • Supports exported members with explicit contract type, lifetime, and tags.
    • Generic exported members remain supported.
    • See readme/export-attribute.md.

πŸ›  Improvements

  • Binding Metadata Validation

    • Added diagnostics for invalid implementation-level binding metadata.
    • Pure.DI now reports an error when an implementation type has multiple lifetime attributes inside the same binding group.
  • Documentation and Usage Scenarios

    • Added new examples for bind type attributes, tag attributes, lifetime attributes, metadata merging, generic contracts, multiple contracts, custom bind attributes, and exported members.

Full Changelog: 2.4.3...2.5.0

2.4.3

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 18 Jun 05:17

This release focuses on improving compatibility, enhancing project templates, and expanding built-in support for standard .NET types.

πŸš€ New Features

  • Native AOT Support: Pure.DI.MS now fully supports Native AOT compilation, enabling better compatibility with modern .NET applications.
  • Enhanced Project Templates: Improved templates with automatic version configuration make creating new projects faster and more convenient.
  • Extended Built-in Type Support: Added out-of-the-box support for additional .NET standard types including TaskCompletionSource, CultureInfo, IFormatProvider, RandomNumberGenerator, IReadOnlySet, TimeProvider, and StringComparer.

🐞 Bug Fixes

  • Improved Native AOT compatibility in Pure.DI.MS.
  • Better handling of version placeholders in project templates.
  • Optimized code generation for improved performance and reduced overhead.

🎨 Improvements

  • More readable generated code with improved formatting and detailed comments.
  • Enhanced documentation with better examples and getting started guides.
  • Optimized performance by removing unnecessary synchronization in generated code.

Full Changelog: 2.4.2...2.4.3

2.4.2

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 14 May 13:24

πŸš€ Improvements

  • Emit _lock field only when actually used. The thread-safety _lock field is no longer emitted in generated compositions when no lock(...) statement references it. Previously it was created conservatively for any composition with overrides, wasting memory on every instance. No behavioral changes for compositions that genuinely require thread safety.

πŸ› Bug Fixes

  • Fix nullable reference type support. Distinguish T and T? in DI contracts and fix invalid ?? generated for nullable generic singleton dependencies.

Full Changelog: 2.4.1...2.4.2

2.4.1

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 13 May 13:33

πŸš€ New Features

Enhanced Code Generation

  • Improved type handling and formatting logic for better class diagram generation
  • Optimized Local Functions Logic β€” performance improvements in local function handling

πŸ› Bug Fixes

Localization Issues β€” fixed localization problems across multiple language resource files. Updated all localization strings for Arabic, Bengali, German, Spanish, French, Hebrew, Hindi, Indonesian, Italian, Japanese, Korean, Portuguese, Russian, Thai, Vietnamese, and Chinese

Full Changelog: 2.4.0...2.4.1

2.4.0

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 08 May 08:01

❗ Breaking Changes

  • Nullable Reference Types β€” This release introduces full support for nullable reference types, which changes how Pure.DI handles nullable types throughout the pipeline. Code that previously relied on automatic null checks for nullable arguments may need adjustment.

πŸš€ New Features

  • Nullable Reference Types β€” Breaking change! Pure.DI now fully preserves nullable reference type annotations throughout the dependency injection pipeline.

    • Nullable composition arguments (.Arg<T?>()) and root arguments (.RootArg<T?>()) no longer generate null checks, allowing null values to flow through as intended.
    • Non-null bindings can satisfy nullable dependencies β€” useful for optional constructor parameters, nullable factory results, and nullable collection elements.
    • Type system integration: nullable annotations are preserved when reading contracts, building graphs, and generating composition members.
    • Generic constraint awareness: prefer where T : class? over where T : class for contracts with nullable generic arguments to avoid C# compiler warnings.
    • New warnings for ambiguous nullable root types in Resolve methods help catch potential issues early.
    • See readme/nullable-reference-types.md for detailed examples and best practices.
  • TryBuildUp for Builders

    • New TryBuildUp method generated alongside BuildUp for safe type-based composition.
    • Returns false instead of throwing when the runtime subtype is unknown, enabling graceful fallback handling.
    • Example: composition.TryBuildUp(externalRobot) returns false for unsupported types while composition.BuildUp(externalRobot) would throw ArgumentException.
    • See readme/builders.md for usage examples.

πŸ‘₯ Contributors

Thanks to everyone who contributed to this release:

Full Changelog: 2.3.7...2.4.0

2.3.7

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 30 Apr 14:16

πŸš€ New Features

  • Generate Interfaces from Classes β€” special thanks to Adam Hathcock for designing and implementing this feature! πŸŽ‰

  • Scope Setup

    • New SetupScope method for composing scoped sub-graphs from a parent composition β€” open a scope per request/operation, share scoped instances inside it, and dispose them at the end.
    • Scopes can be produced by factory methods, enabling custom scope creation logic.
    • Parent and child scopes are validated to be distinct, preventing accidental self-nesting.
    • New Hint.ScopeMethodName hint lets you rename the generated scope factory method to fit your domain (e.g. SetupScope, CreateScope, BeginRequest):
      DI.Setup()
          .Hint(Hint.ScopeMethodName, "SetupScope")
          .Bind().As(Scoped).To<RequestContext>();
  • Unity Scene Scopes

    • New Unity scene scopes scenario: each loaded Unity scene gets its own scope, so scoped services are shared within a scene and isolated between scenes β€” Unity creates the MonoBehaviour instances and Pure.DI builds them up.
  • Microsoft DI Integration: Scoped Lifetimes

    • IServiceProvider integration now supports scoped lifetimes end-to-end via composition.CreateScope(), matching Microsoft.Extensions.DependencyInjection semantics.
    • Tag-based resolution and value-type roots are supported through the integration.
  • Generated Code is Marked

    • All generated code is now decorated with [GeneratedCode], so analyzers, coverage, and code-style tools can recognize and skip it correctly.
    • The generated Composition class embeds the actual Pure.DI package version it was produced with, instead of a hard-coded string.

πŸ› Bug Fixes

  • Fixed scoped/singleton instance propagation through nested scopes.
  • Fixed read-only handling of setup-context arguments inside generated scope methods.

πŸ‘₯ Contributors

Thanks to everyone who contributed to this release:

Full Changelog: 2.3.6...2.3.7

2.3.6

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 25 Mar 17:55

πŸš€ New Features

  • BCL Dictionary Support

    • Added support for injecting .NET Base Class Library Dictionary<TKey, TValue> types
    • Extended injection capabilities to cover standard dictionary types from BCL
  • IContext Extensions

  • Extended Factory Method Bindings

    • Added support for up to 16-parameter factory method bindings
    • Increased from previous limit, supporting more complex factory scenarios

⚑ Performance Improvements

  • Metadata Analysis

    • Optimized metadata analysis pipeline
    • Reduced overhead in setup metadata detection
  • Code Generation

    • Optimized factory code generation with reduced allocations
    • Optimized type resolution process
  • Graph Building

    • Reduced semantic analysis overhead by favoring syntactic analysis
    • Improved graph construction performance

πŸ“ Documentation

  • Updated and improved README documentation
  • Added "Article Basics" documentation

Full Changelog: 2.3.5...2.3.6

2.3.5

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 14 Mar 07:37

πŸ› Bug Fixes

  • #140 Incorrect generated code for the PerBlock lifetime: a local or parameter named ... cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
  • #141 Objects created without explicit binding began to use the specified default lifetime instead of Transient

Contributors

@YoshihiroIto
@NikolayPianikov

Full Changelog: 2.3.4...2.3.5

2.3.4

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 12 Mar 10:41

πŸš€ New Features

  • Auto-Bindings Default Lifetime Support

    • Added support for default lifetime configuration in auto-bindings
    • Improves consistency and reduces manual configuration
  • Anonymous Roots (#138)

    • Made anonymous roots lightweight
    • Reduced memory footprint and improved performance for anonymous root scenarios

πŸ› Bug Fixes

  • #132: Fixed optional enum default value emission

    • Fixed issue where optional enum default values were emitted as int literals, causing CS1503 compilation error
    • Enum default values from other assemblies are now correctly generated
    • Enhanced handling of explicit default values for enum types in dependency injection
  • #133: Fixed null parameter issue in self-injecting registrations

    • Fixed issue where null was passed as parameter when a registration injects itself
    • Improved Lazy status determination by properly taking into account injected dependencies
  • DIE043: Fixed casting exception

    • Fixed "Unable to cast object of type 'System.Int32' to type 'System.String'" error
    • Improved type handling in dependency graph construction
  • Improved error message for unresolved dependencies

⚑ Performance Improvements (#136)

  • Cache Refactoring

    • Significant performance improvements through cache refactoring
    • Reduced redundant operations in dependency graph building
  • Graph Build Optimizations

    • Optimization of graph build process to reduce computation time
    • Reduced number of attempts to build a dependency graph
    • Improved metadata analysis with preference for syntactic analysis instead of semantic
  • Variable Management

    • Optimization of Var and VarsMap handling
    • Improved graph build context preparation
    • Enhanced scope persistence rules with helper methods
  • Metadata Analysis

    • Optimized metadata analysis pipeline
    • Reduced overhead in setup metadata detection
  • GraphOverrider

    • Refactored GraphOverrider internals into focused helpers
    • Improved override depth handling
  • Code Generation

    • Spot optimization to eliminate unnecessary local values in generation
    • Optimized dependency graph construction by handling duplicate injections
  • Multithreading

    • Removed multithreading to improve stability

Full Changelog: 2.3.3...2.3.4

2.3.3

Choose a tag to compare

@NikolayPianikov NikolayPianikov released this 15 Feb 11:53

🐞 Bug Fixes

  • #132 Optional enum default value is emitted as int literal, causing CS1503

Full Changelog: 2.3.2...2.3.3