diff --git a/readme/ArrayDetails.md b/readme/ArrayDetails.md index 4c330fa77..9ad967038 100644 --- a/readme/ArrayDetails.md +++ b/readme/ArrayDetails.md @@ -6,7 +6,7 @@ Creating an object graph of 27 transient objects, including 4 transient array ob ```mermaid classDiagram class Array { - +CompositionRoot PureDIByCR + +CompositionRoot PureDIByCR() + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -77,7 +77,7 @@ classDiagram Service3v3 *-- Service4 : IService4 Service3v4 *-- Service4 : IService4 Service3v4 *-- Service4 : IService4 - Array ..> CompositionRoot : CompositionRoot PureDIByCR + Array ..> CompositionRoot : CompositionRoot PureDIByCR()
CompositionRoot ``` ### Generated code @@ -87,7 +87,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -95,7 +95,7 @@ classDiagram /// /// /// -/// PureDIByCR +///
or using method: Resolve<Pure.DI.Benchmarks.Model.CompositionRoot>() ///
/// /// Provides a composition root of type . @@ -103,28 +103,30 @@ classDiagram ///
///
///
+/// /// -/// This shows how to get an instance of type using the composition root : +/// This shows how to get an instance of type using the composition root : /// /// var composition = new Array(); /// var instance = composition.PureDIByCR(); /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -/// /// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Array { - private readonly Array _rootM03D12di; + private readonly Array _rootM03D13di; /// /// This constructor creates a new instance of . /// public Array() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -133,10 +135,20 @@ partial class Array /// Base composition. internal Array(Array baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Array(); + /// var instance = composition.PureDIByCR(); + /// + /// #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif @@ -157,7 +169,7 @@ partial class Array #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -171,7 +183,7 @@ partial class Array #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -184,10 +196,10 @@ partial class Array #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -208,10 +220,10 @@ partial class Array #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -230,7 +242,7 @@ partial class Array return "classDiagram\n" + " class Array {\n" + - " +CompositionRoot PureDIByCR\n" + + " +CompositionRoot PureDIByCR()\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -301,29 +313,29 @@ partial class Array " Service3v3 *-- Service4 : IService4\n" + " Service3v4 *-- Service4 : IService4\n" + " Service3v4 *-- Service4 : IService4\n" + - " Array ..> CompositionRoot : CompositionRoot PureDIByCR"; + " Array ..> CompositionRoot : CompositionRoot PureDIByCR()
provides CompositionRoot"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Array() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Array composite) { @@ -336,7 +348,7 @@ partial class Array } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.Benchmarks.Model.CompositionRoot Resolve(Array composition) { diff --git a/readme/EnumDetails.md b/readme/EnumDetails.md index 318e41702..363366023 100644 --- a/readme/EnumDetails.md +++ b/readme/EnumDetails.md @@ -6,7 +6,7 @@ Creating an object graph of 12 transient objects, including 1 transient enumerab ```mermaid classDiagram class Enum { - +CompositionRoot PureDIByCR + +CompositionRoot PureDIByCR() + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -77,7 +77,7 @@ classDiagram Service3v3 *-- Service4 : IService4 Service3v4 *-- Service4 : IService4 Service3v4 *-- Service4 : IService4 - Enum ..> CompositionRoot : CompositionRoot PureDIByCR + Enum ..> CompositionRoot : CompositionRoot PureDIByCR()
CompositionRoot ``` ### Generated code @@ -87,7 +87,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -95,7 +95,7 @@ classDiagram /// /// /// -/// PureDIByCR +///
or using method: Resolve<Pure.DI.Benchmarks.Model.CompositionRoot>() ///
/// /// Provides a composition root of type . @@ -103,28 +103,30 @@ classDiagram ///
///
///
+///
/// -/// This shows how to get an instance of type using the composition root : +/// This shows how to get an instance of type using the composition root : /// /// var composition = new Enum(); /// var instance = composition.PureDIByCR(); /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Enum { - private readonly Enum _rootM03D12di; + private readonly Enum _rootM03D13di; /// /// This constructor creates a new instance of . /// public Enum() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -133,25 +135,35 @@ partial class Enum /// Base composition. internal Enum(Enum baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Enum(); + /// var instance = composition.PureDIByCR(); + /// + /// #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif public partial Pure.DI.Benchmarks.Model.CompositionRoot PureDIByCR() { [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x200)] - System.Collections.Generic.IEnumerable LocalperBlockM03D12di10_IEnumerable() + System.Collections.Generic.IEnumerable LocalperBlockM03D13di10_IEnumerable() { yield return new Pure.DI.Benchmarks.Model.Service3(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); yield return new Pure.DI.Benchmarks.Model.Service3v2(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); yield return new Pure.DI.Benchmarks.Model.Service3v3(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); yield return new Pure.DI.Benchmarks.Model.Service3v4(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); } - var perBlockM03D12di10_IEnumerable = LocalperBlockM03D12di10_IEnumerable(); - return new Pure.DI.Benchmarks.Model.CompositionRoot(new Pure.DI.Benchmarks.Model.Service1(new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D12di10_IEnumerable)), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D12di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D12di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D12di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service3(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()), new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); + var perBlockM03D13di10_IEnumerable = LocalperBlockM03D13di10_IEnumerable(); + return new Pure.DI.Benchmarks.Model.CompositionRoot(new Pure.DI.Benchmarks.Model.Service1(new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D13di10_IEnumerable)), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D13di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D13di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D13di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service3(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()), new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); } #endregion @@ -166,7 +178,7 @@ partial class Enum #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -180,7 +192,7 @@ partial class Enum #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -193,10 +205,10 @@ partial class Enum #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -217,10 +229,10 @@ partial class Enum #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -239,7 +251,7 @@ partial class Enum return "classDiagram\n" + " class Enum {\n" + - " +CompositionRoot PureDIByCR\n" + + " +CompositionRoot PureDIByCR()\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -310,29 +322,29 @@ partial class Enum " Service3v3 *-- Service4 : IService4\n" + " Service3v4 *-- Service4 : IService4\n" + " Service3v4 *-- Service4 : IService4\n" + - " Enum ..> CompositionRoot : CompositionRoot PureDIByCR"; + " Enum ..> CompositionRoot : CompositionRoot PureDIByCR()
provides CompositionRoot"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Enum() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Enum composite) { @@ -345,7 +357,7 @@ partial class Enum } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.Benchmarks.Model.CompositionRoot Resolve(Enum composition) { diff --git a/readme/FuncDetails.md b/readme/FuncDetails.md index f9b3249ec..90ec733d2 100644 --- a/readme/FuncDetails.md +++ b/readme/FuncDetails.md @@ -6,7 +6,7 @@ Creating an object graph of 7 transition objects plus 1 `Func` with additiona ```mermaid classDiagram class Func { - +CompositionRoot PureDIByCR + +CompositionRoot PureDIByCR() + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -55,7 +55,7 @@ classDiagram Service2Func o-- "PerBlock" FuncᐸIService3ᐳ : FuncᐸIService3ᐳ Service3 *-- Service4 : IService4 Service3 *-- Service4 : IService4 - Func ..> CompositionRoot : CompositionRoot PureDIByCR + Func ..> CompositionRoot : CompositionRoot PureDIByCR()
CompositionRoot FuncᐸIService3ᐳ *-- Service3 : IService3 ``` @@ -66,7 +66,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -74,7 +74,7 @@ classDiagram /// /// /// -/// PureDIByCR +///
or using method: Resolve<Pure.DI.Benchmarks.Model.CompositionRoot>() ///
/// /// Provides a composition root of type . @@ -82,28 +82,30 @@ classDiagram ///
///
///
+///
/// -/// This shows how to get an instance of type using the composition root : +/// This shows how to get an instance of type using the composition root : /// /// var composition = new Func(); /// var instance = composition.PureDIByCR(); /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Func { - private readonly Func _rootM03D12di; + private readonly Func _rootM03D13di; /// /// This constructor creates a new instance of . /// public Func() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -112,23 +114,33 @@ partial class Func /// Base composition. internal Func(Func baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Func(); + /// var instance = composition.PureDIByCR(); + /// + /// #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif public partial Pure.DI.Benchmarks.Model.CompositionRoot PureDIByCR() { - System.Func perBlockM03D12di10_Func = new Func( + System.Func perBlockM03D13di10_Func = new Func( [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)768)] () => { - var value_M03D12di1 = new Pure.DI.Benchmarks.Model.Service3(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); - return value_M03D12di1; + var value_M03D13di1 = new Pure.DI.Benchmarks.Model.Service3(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); + return value_M03D13di1; }); - return new Pure.DI.Benchmarks.Model.CompositionRoot(new Pure.DI.Benchmarks.Model.Service1(new Pure.DI.Benchmarks.Model.Service2Func(perBlockM03D12di10_Func)), new Pure.DI.Benchmarks.Model.Service2Func(perBlockM03D12di10_Func), new Pure.DI.Benchmarks.Model.Service2Func(perBlockM03D12di10_Func), new Pure.DI.Benchmarks.Model.Service2Func(perBlockM03D12di10_Func), new Pure.DI.Benchmarks.Model.Service3(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()), new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); + return new Pure.DI.Benchmarks.Model.CompositionRoot(new Pure.DI.Benchmarks.Model.Service1(new Pure.DI.Benchmarks.Model.Service2Func(perBlockM03D13di10_Func)), new Pure.DI.Benchmarks.Model.Service2Func(perBlockM03D13di10_Func), new Pure.DI.Benchmarks.Model.Service2Func(perBlockM03D13di10_Func), new Pure.DI.Benchmarks.Model.Service2Func(perBlockM03D13di10_Func), new Pure.DI.Benchmarks.Model.Service3(new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()), new Pure.DI.Benchmarks.Model.Service4(), new Pure.DI.Benchmarks.Model.Service4()); } #endregion @@ -143,7 +155,7 @@ partial class Func #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -157,7 +169,7 @@ partial class Func #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -170,10 +182,10 @@ partial class Func #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -194,10 +206,10 @@ partial class Func #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -216,7 +228,7 @@ partial class Func return "classDiagram\n" + " class Func {\n" + - " +CompositionRoot PureDIByCR\n" + + " +CompositionRoot PureDIByCR()\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -265,30 +277,30 @@ partial class Func " Service2Func o-- \"PerBlock\" FuncᐸIService3ᐳ : FuncᐸIService3ᐳ\n" + " Service3 *-- Service4 : IService4\n" + " Service3 *-- Service4 : IService4\n" + - " Func ..> CompositionRoot : CompositionRoot PureDIByCR\n" + + " Func ..> CompositionRoot : CompositionRoot PureDIByCR()
provides CompositionRoot\n" + " FuncᐸIService3ᐳ *-- Service3 : IService3"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Func() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Func composite) { @@ -301,7 +313,7 @@ partial class Func } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.Benchmarks.Model.CompositionRoot Resolve(Func composition) { diff --git a/readme/SingletonDetails.md b/readme/SingletonDetails.md index 102909a98..a18104342 100644 --- a/readme/SingletonDetails.md +++ b/readme/SingletonDetails.md @@ -6,7 +6,7 @@ Creating an object graph of 20 transition objects plus 1 singleton with an addit ```mermaid classDiagram class Singleton { - +CompositionRoot PureDIByCR + +CompositionRoot PureDIByCR() + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -58,7 +58,7 @@ classDiagram Service2 *-- Service3 : IService3 Service3 o-- "Scoped" Service4 : IService4 Service3 o-- "Scoped" Service4 : IService4 - Singleton ..> CompositionRoot : CompositionRoot PureDIByCR + Singleton ..> CompositionRoot : CompositionRoot PureDIByCR()
CompositionRoot ``` ### Generated code @@ -68,7 +68,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -76,7 +76,7 @@ classDiagram /// /// /// -/// PureDIByCR +///
or using method: Resolve<Pure.DI.Benchmarks.Model.CompositionRoot>() ///
/// /// Provides a composition root of type . @@ -84,30 +84,32 @@ classDiagram ///
///
///
+///
/// -/// This shows how to get an instance of type using the composition root : +/// This shows how to get an instance of type using the composition root : /// /// var composition = new Singleton(); /// var instance = composition.PureDIByCR(); /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Singleton { - private readonly Singleton _rootM03D12di; - private Pure.DI.Benchmarks.Model.Service1 _scopedM03D12di35_Service1; - private Pure.DI.Benchmarks.Model.Service4 _scopedM03D12di38_Service4; + private readonly Singleton _rootM03D13di; + private Pure.DI.Benchmarks.Model.Service1 _scopedM03D13di35_Service1; + private Pure.DI.Benchmarks.Model.Service4 _scopedM03D13di38_Service4; /// /// This constructor creates a new instance of . /// public Singleton() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -116,24 +118,34 @@ partial class Singleton /// Base composition. internal Singleton(Singleton baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Singleton(); + /// var instance = composition.PureDIByCR(); + /// + /// #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif public partial Pure.DI.Benchmarks.Model.CompositionRoot PureDIByCR() { - if (ReferenceEquals(_scopedM03D12di38_Service4, null)) + if (ReferenceEquals(_scopedM03D13di38_Service4, null)) { - _scopedM03D12di38_Service4 = new Pure.DI.Benchmarks.Model.Service4(); + _scopedM03D13di38_Service4 = new Pure.DI.Benchmarks.Model.Service4(); } - if (ReferenceEquals(_scopedM03D12di35_Service1, null)) + if (ReferenceEquals(_scopedM03D13di35_Service1, null)) { - _scopedM03D12di35_Service1 = new Pure.DI.Benchmarks.Model.Service1(new Pure.DI.Benchmarks.Model.Service2(new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4))); + _scopedM03D13di35_Service1 = new Pure.DI.Benchmarks.Model.Service1(new Pure.DI.Benchmarks.Model.Service2(new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4))); } - return new Pure.DI.Benchmarks.Model.CompositionRoot(_scopedM03D12di35_Service1, new Pure.DI.Benchmarks.Model.Service2(new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4)), new Pure.DI.Benchmarks.Model.Service2(new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4)), new Pure.DI.Benchmarks.Model.Service2(new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4)), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D12di38_Service4, _scopedM03D12di38_Service4), _scopedM03D12di38_Service4, _scopedM03D12di38_Service4); + return new Pure.DI.Benchmarks.Model.CompositionRoot(_scopedM03D13di35_Service1, new Pure.DI.Benchmarks.Model.Service2(new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4)), new Pure.DI.Benchmarks.Model.Service2(new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4)), new Pure.DI.Benchmarks.Model.Service2(new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4)), new Pure.DI.Benchmarks.Model.Service3(_scopedM03D13di38_Service4, _scopedM03D13di38_Service4), _scopedM03D13di38_Service4, _scopedM03D13di38_Service4); } #endregion @@ -148,7 +160,7 @@ partial class Singleton #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -162,7 +174,7 @@ partial class Singleton #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -175,10 +187,10 @@ partial class Singleton #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -199,10 +211,10 @@ partial class Singleton #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -221,7 +233,7 @@ partial class Singleton return "classDiagram\n" + " class Singleton {\n" + - " +CompositionRoot PureDIByCR\n" + + " +CompositionRoot PureDIByCR()\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -273,29 +285,29 @@ partial class Singleton " Service2 *-- Service3 : IService3\n" + " Service3 o-- \"Scoped\" Service4 : IService4\n" + " Service3 o-- \"Scoped\" Service4 : IService4\n" + - " Singleton ..> CompositionRoot : CompositionRoot PureDIByCR"; + " Singleton ..> CompositionRoot : CompositionRoot PureDIByCR()
provides CompositionRoot"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Singleton() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Singleton composite) { @@ -308,7 +320,7 @@ partial class Singleton } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.Benchmarks.Model.CompositionRoot Resolve(Singleton composition) { diff --git a/readme/TransientDetails.md b/readme/TransientDetails.md index 75155667a..7a2a32fab 100644 --- a/readme/TransientDetails.md +++ b/readme/TransientDetails.md @@ -6,7 +6,7 @@ Creating an object graph of 22 transient objects. ```mermaid classDiagram class Transient { - +CompositionRoot PureDIByCR + +CompositionRoot PureDIByCR() + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -58,7 +58,7 @@ classDiagram Service2 *-- Service3 : IService3 Service3 *-- Service4 : IService4 Service3 *-- Service4 : IService4 - Transient ..> CompositionRoot : CompositionRoot PureDIByCR + Transient ..> CompositionRoot : CompositionRoot PureDIByCR()
CompositionRoot ``` ### Generated code @@ -68,7 +68,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -76,7 +76,7 @@ classDiagram /// /// /// -/// PureDIByCR +///
or using method: Resolve<Pure.DI.Benchmarks.Model.CompositionRoot>() ///
/// /// Provides a composition root of type . @@ -84,28 +84,30 @@ classDiagram ///
///
///
+///
/// -/// This shows how to get an instance of type using the composition root : +/// This shows how to get an instance of type using the composition root : /// /// var composition = new Transient(); /// var instance = composition.PureDIByCR(); /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Transient { - private readonly Transient _rootM03D12di; + private readonly Transient _rootM03D13di; /// /// This constructor creates a new instance of . /// public Transient() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -114,10 +116,20 @@ partial class Transient /// Base composition. internal Transient(Transient baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Transient(); + /// var instance = composition.PureDIByCR(); + /// + /// #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif @@ -138,7 +150,7 @@ partial class Transient #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -152,7 +164,7 @@ partial class Transient #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -165,10 +177,10 @@ partial class Transient #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -189,10 +201,10 @@ partial class Transient #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -211,7 +223,7 @@ partial class Transient return "classDiagram\n" + " class Transient {\n" + - " +CompositionRoot PureDIByCR\n" + + " +CompositionRoot PureDIByCR()\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -263,29 +275,29 @@ partial class Transient " Service2 *-- Service3 : IService3\n" + " Service3 *-- Service4 : IService4\n" + " Service3 *-- Service4 : IService4\n" + - " Transient ..> CompositionRoot : CompositionRoot PureDIByCR"; + " Transient ..> CompositionRoot : CompositionRoot PureDIByCR()
provides CompositionRoot"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Transient() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Transient composite) { @@ -298,7 +310,7 @@ partial class Transient } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.Benchmarks.Model.CompositionRoot Resolve(Transient composition) { diff --git a/readme/a-few-partial-classes.md b/readme/a-few-partial-classes.md index 1edecb027..76a589704 100644 --- a/readme/a-few-partial-classes.md +++ b/readme/a-few-partial-classes.md @@ -68,7 +68,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -78,7 +78,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -86,7 +86,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.SeveralPartialClassesScenario.IService>() ///
/// /// Provides a composition root of type . @@ -94,6 +94,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -101,21 +102,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -124,10 +126,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.SeveralPartialClassesScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -151,7 +163,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -165,7 +177,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -178,10 +190,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -202,10 +214,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -245,29 +257,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.SeveralPartialClassesScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.SeveralPartialClassesScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -280,7 +292,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.SeveralPartialClassesScenario.IService Resolve(Composition composition) { diff --git a/readme/advanced-interception.md b/readme/advanced-interception.md index d7a523006..7ae5e6498 100644 --- a/readme/advanced-interception.md +++ b/readme/advanced-interception.md @@ -136,7 +136,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -146,7 +146,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -154,7 +154,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Interception.AdvancedInterceptionScenario.IService>() ///
/// /// Provides a composition root of type . @@ -162,6 +162,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -169,21 +170,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -192,10 +194,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Interception.AdvancedInterceptionScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -219,7 +231,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -233,7 +245,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -246,10 +258,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -270,10 +282,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -315,29 +327,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Interception.AdvancedInterceptionScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Interception.AdvancedInterceptionScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -350,7 +362,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Interception.AdvancedInterceptionScenario.IService Resolve(Composition composition) { diff --git a/readme/arguments.md b/readme/arguments.md index 4dbb16b17..71c690a65 100644 --- a/readme/arguments.md +++ b/readme/arguments.md @@ -81,7 +81,7 @@ classDiagram Dependency o-- Int32 : Argument "id" Service o-- String : "name" Argument "serviceName" Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -91,7 +91,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -99,7 +99,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.ArgumentsScenario.IService>() ///
/// /// Provides a composition root of type . @@ -107,23 +107,25 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// -/// var composition = new Composition(id, serviceName); +/// var composition = new Composition(_argM03D13di_id, _argM03D13di_serviceName); /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly int _argM03D12di_id; - private readonly string _argM03D12di_serviceName; + private readonly Composition _rootM03D13di; + private readonly int _argM03D13di_id; + private readonly string _argM03D13di_serviceName; /// /// This parameterized constructor creates a new instance of with arguments. @@ -137,14 +139,14 @@ partial class Composition /// public Composition(int id, string serviceName) { - _rootM03D12di = this; + _rootM03D13di = this; if (ReferenceEquals(serviceName, null)) { throw new global::System.ArgumentNullException("serviceName"); } - _argM03D12di_id = id; - _argM03D12di_serviceName = serviceName; + _argM03D13di_id = id; + _argM03D13di_serviceName = serviceName; } /// @@ -153,12 +155,22 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _argM03D12di_id = baseComposition._argM03D12di_id; - _argM03D12di_serviceName = baseComposition._argM03D12di_serviceName; + _rootM03D13di = baseComposition._rootM03D13di; + _argM03D13di_id = baseComposition._argM03D13di_id; + _argM03D13di_serviceName = baseComposition._argM03D13di_serviceName; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(_argM03D13di_id, _argM03D13di_serviceName); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.ArgumentsScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -166,7 +178,7 @@ partial class Composition #endif get { - return new Pure.DI.UsageTests.Basics.ArgumentsScenario.Service(_argM03D12di_serviceName, new Pure.DI.UsageTests.Basics.ArgumentsScenario.Dependency(_argM03D12di_id)); + return new Pure.DI.UsageTests.Basics.ArgumentsScenario.Service(_argM03D13di_serviceName, new Pure.DI.UsageTests.Basics.ArgumentsScenario.Dependency(_argM03D13di_id)); } } #endregion @@ -182,7 +194,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -196,7 +208,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -209,10 +221,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -233,10 +245,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -280,29 +292,29 @@ partial class Composition " Dependency o-- Int32 : Argument \"id\"\n" + " Service o-- String : \"name\" Argument \"serviceName\"\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.ArgumentsScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.ArgumentsScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -315,7 +327,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.ArgumentsScenario.IService Resolve(Composition composition) { diff --git a/readme/array.md b/readme/array.md index 58c49d3af..eef20c8ac 100644 --- a/readme/array.md +++ b/readme/array.md @@ -93,7 +93,7 @@ classDiagram ArrayᐸIDependencyᐳ *-- AbcDependency : IDependency ArrayᐸIDependencyᐳ *-- XyzDependency : 2 IDependency Service *-- ArrayᐸIDependencyᐳ : ArrayᐸIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -103,7 +103,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -111,7 +111,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.ArrayScenario.IService>() ///
/// /// Provides a composition root of type . @@ -119,6 +119,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -126,21 +127,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -149,10 +151,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.ArrayScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -176,7 +188,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -190,7 +202,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -203,10 +215,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -227,10 +239,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -277,29 +289,29 @@ partial class Composition " ArrayᐸIDependencyᐳ *-- AbcDependency : IDependency\n" + " ArrayᐸIDependencyᐳ *-- XyzDependency : 2 IDependency\n" + " Service *-- ArrayᐸIDependencyᐳ : ArrayᐸIDependencyᐳ\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ArrayScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ArrayScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -312,7 +324,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.ArrayScenario.IService Resolve(Composition composition) { diff --git a/readme/async-enumerable.md b/readme/async-enumerable.md index d1bee026c..be30f4479 100644 --- a/readme/async-enumerable.md +++ b/readme/async-enumerable.md @@ -76,7 +76,7 @@ classDiagram IAsyncEnumerableᐸIDependencyᐳ *-- AbcDependency : IDependency IAsyncEnumerableᐸIDependencyᐳ *-- XyzDependency : 2 IDependency Service *-- IAsyncEnumerableᐸIDependencyᐳ : IAsyncEnumerableᐸIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -86,7 +86,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -94,7 +94,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.AsyncEnumerableScenario.IService>() ///
/// /// Provides a composition root of type . @@ -102,6 +102,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -109,21 +110,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -132,10 +134,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.AsyncEnumerableScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -144,13 +156,13 @@ partial class Composition get { [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x200)] - async System.Collections.Generic.IAsyncEnumerable LocaltransientM03D12di1_IAsyncEnumerable() + async System.Collections.Generic.IAsyncEnumerable LocaltransientM03D13di1_IAsyncEnumerable() { yield return new Pure.DI.UsageTests.BCL.AsyncEnumerableScenario.AbcDependency(); yield return new Pure.DI.UsageTests.BCL.AsyncEnumerableScenario.XyzDependency(); } - var transientM03D12di1_IAsyncEnumerable = LocaltransientM03D12di1_IAsyncEnumerable(); - return new Pure.DI.UsageTests.BCL.AsyncEnumerableScenario.Service(transientM03D12di1_IAsyncEnumerable); + var transientM03D13di1_IAsyncEnumerable = LocaltransientM03D13di1_IAsyncEnumerable(); + return new Pure.DI.UsageTests.BCL.AsyncEnumerableScenario.Service(transientM03D13di1_IAsyncEnumerable); } } #endregion @@ -166,7 +178,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -180,7 +192,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -193,10 +205,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -217,10 +229,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -267,29 +279,29 @@ partial class Composition " IAsyncEnumerableᐸIDependencyᐳ *-- AbcDependency : IDependency\n" + " IAsyncEnumerableᐸIDependencyᐳ *-- XyzDependency : 2 IDependency\n" + " Service *-- IAsyncEnumerableᐸIDependencyᐳ : IAsyncEnumerableᐸIDependencyᐳ\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.AsyncEnumerableScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.AsyncEnumerableScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -302,7 +314,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.AsyncEnumerableScenario.IService Resolve(Composition composition) { diff --git a/readme/auto-bindings.md b/readme/auto-bindings.md index 46ab27e35..991641094 100644 --- a/readme/auto-bindings.md +++ b/readme/auto-bindings.md @@ -39,7 +39,7 @@ classDiagram +Service(Dependency dependency) } Service *-- Dependency : Dependency - Composition ..> Service : Service MyService + Composition ..> Service : Service MyService
provides Service ``` @@ -52,7 +52,7 @@ classDiagram /// Specifies to create a partial class "Composition" /// /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -60,7 +60,7 @@ classDiagram /// /// /// -/// MyService +///
or using method: Resolve<Pure.DI.UsageTests.Basics.AutoBindingsScenario.Service>() ///
/// /// Specifies to create a property "MyService" @@ -68,6 +68,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -75,21 +76,22 @@ classDiagram /// var instance = composition.MyService; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -98,13 +100,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots /// /// Specifies to create a property "MyService" /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.MyService; + /// + /// public Pure.DI.UsageTests.Basics.AutoBindingsScenario.Service MyService { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -134,7 +143,7 @@ partial class Composition " +Service(Dependency dependency)\n" + " }\n" + " Service *-- Dependency : Dependency\n" + - " Composition ..> Service : Service MyService"; + " Composition ..> Service : Service MyService
provides Service"; } } ``` diff --git a/readme/auto-scoped.md b/readme/auto-scoped.md index 8457660fd..e46210dc2 100644 --- a/readme/auto-scoped.md +++ b/readme/auto-scoped.md @@ -92,8 +92,8 @@ classDiagram Program o-- "PerResolve" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ Service o-- "Scoped" Dependency : IDependency IService *-- Composition : Composition - Composition ..> Service : Service SessionRoot - Composition ..> Program : Program ProgramRoot + Composition ..> Service : Service SessionRoot
provides Service + Composition ..> Program : Program ProgramRoot
provides Program FuncᐸIServiceᐳ *-- IService : IService ``` @@ -104,7 +104,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -112,7 +112,7 @@ classDiagram /// /// /// -/// ProgramRoot +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Program>() ///
/// /// Program composition root @@ -120,7 +120,7 @@ classDiagram ///
/// /// -/// SessionRoot +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Service>() ///
/// /// Session composition root @@ -128,6 +128,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -135,24 +136,25 @@ classDiagram /// var instance = composition.ProgramRoot; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Dependency _scopedM03D12di34_Dependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Dependency _scopedM03D13di34_Dependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -161,14 +163,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots /// /// Session composition root /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.SessionRoot; + /// + /// private Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Service SessionRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -176,23 +185,30 @@ partial class Composition #endif get { - if (ReferenceEquals(_scopedM03D12di34_Dependency, null)) + if (ReferenceEquals(_scopedM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_scopedM03D12di34_Dependency, null)) + if (ReferenceEquals(_scopedM03D13di34_Dependency, null)) { - _scopedM03D12di34_Dependency = new Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Dependency(); + _scopedM03D13di34_Dependency = new Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Dependency(); } } } - return new Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Service(_scopedM03D12di34_Dependency); + return new Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Service(_scopedM03D13di34_Dependency); } } /// /// Program composition root /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.ProgramRoot; + /// + /// public Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Program ProgramRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -200,23 +216,23 @@ partial class Composition #endif get { - var perResolveM03D12di39_Func = default(System.Func); - perResolveM03D12di39_Func = new global::System.Func( + var perResolveM03D13di39_Func = default(System.Func); + perResolveM03D13di39_Func = new global::System.Func( [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)768)] () => { - var transientM03D12di2_Composition = this; - Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.IService transientM03D12di1_IService; + var transientM03D13di2_Composition = this; + Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.IService transientM03D13di1_IService; { - var baseComposition_M03D12di2 = transientM03D12di2_Composition; + var baseComposition_M03D13di2 = transientM03D13di2_Composition; // Creates a session - var session_M03D12di3 = new Composition(baseComposition_M03D12di2); - transientM03D12di1_IService = session_M03D12di3.SessionRoot; + var session_M03D13di3 = new Composition(baseComposition_M03D13di2); + transientM03D13di1_IService = session_M03D13di3.SessionRoot; } - var factory_M03D12di1 = transientM03D12di1_IService; - return factory_M03D12di1; + var factory_M03D13di1 = transientM03D13di1_IService; + return factory_M03D13di1; }); - return new Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Program(perResolveM03D12di39_Func); + return new Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Program(perResolveM03D13di39_Func); } } #endregion @@ -232,7 +248,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -246,7 +262,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -259,10 +275,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -283,10 +299,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -331,34 +347,34 @@ partial class Composition " Program o-- \"PerResolve\" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ\n" + " Service o-- \"Scoped\" Dependency : IDependency\n" + " IService *-- Composition : Composition\n" + - " Composition ..> Service : Service SessionRoot\n" + - " Composition ..> Program : Program ProgramRoot\n" + + " Composition ..> Service : Service SessionRoot
provides Service\n" + + " Composition ..> Program : Program ProgramRoot
provides Program\n" + " FuncᐸIServiceᐳ *-- IService : IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Service), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Program), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Service), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Program), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -371,7 +387,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Service Resolve(Composition composition) { @@ -389,7 +405,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.AutoScopedScenario.Program Resolve(Composition composition) { diff --git a/readme/check-for-a-root.md b/readme/check-for-a-root.md index 680353d6e..cfc30f5ec 100644 --- a/readme/check-for-a-root.md +++ b/readme/check-for-a-root.md @@ -64,7 +64,7 @@ Composition.HasRoot(typeof(IComparable)).ShouldBeFalse(); classDiagram class Composition { +IService Root - -IDependency RootM03D12di0001 + -IDependency RootM03D13di0001 + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -86,8 +86,8 @@ classDiagram <> } Service *-- Dependency : "MyDep" IDependency - Composition ..> Dependency : "MyDep" IDependency RootM03D12di0001 - Composition ..> Service : IService Root + Composition ..> Dependency : IDependency RootM03D13di0001
provides "MyDep" IDependency + Composition ..> Service : IService Root
provides IService ``` @@ -97,7 +97,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -105,7 +105,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.CheckForRootScenario.IService>() ///
/// /// Provides a composition root of type . @@ -113,7 +113,7 @@ classDiagram ///
/// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.Basics.CheckForRootScenario.IDependency>("MyDep") ///
/// /// Provides a composition root of type . @@ -121,6 +121,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -128,21 +129,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -151,10 +153,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.CheckForRootScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -169,7 +181,10 @@ partial class Composition } } - public Pure.DI.UsageTests.Basics.CheckForRootScenario.IDependency RootM03D12di0001 + /// + /// Provides a composition root of type . + /// + public Pure.DI.UsageTests.Basics.CheckForRootScenario.IDependency RootM03D13di0001 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] @@ -192,7 +207,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -206,7 +221,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -219,10 +234,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -243,10 +258,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -266,7 +281,7 @@ partial class Composition "classDiagram\n" + " class Composition {\n" + " +IService Root\n" + - " -IDependency RootM03D12di0001\n" + + " -IDependency RootM03D13di0001\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -288,37 +303,37 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : \"MyDep\" IDependency\n" + - " Composition ..> Dependency : \"MyDep\" IDependency RootM03D12di0001\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Dependency : IDependency RootM03D13di0001
provides \"MyDep\" IDependency\n" + + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; private static partial void OnNewRoot(global::Pure.DI.IResolver resolver, string name, object? tag, global::Pure.DI.Lifetime lifetime); static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - OnNewRoot(valResolverM03D12di_0000, "Root", null, Pure.DI.Lifetime.Transient); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - OnNewRoot(valResolverM03D12di_0001, "RootM03D12di0001", "MyDep", Pure.DI.Lifetime.Transient); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + OnNewRoot(valResolverM03D13di_0000, "Root", null, Pure.DI.Lifetime.Transient); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + OnNewRoot(valResolverM03D13di_0001, "RootM03D13di0001", "MyDep", Pure.DI.Lifetime.Transient); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CheckForRootScenario.IService), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CheckForRootScenario.IDependency), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CheckForRootScenario.IService), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CheckForRootScenario.IDependency), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -331,7 +346,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.CheckForRootScenario.IService Resolve(Composition composition) { @@ -349,7 +364,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.CheckForRootScenario.IDependency Resolve(Composition composition) { @@ -361,7 +376,7 @@ partial class Composition switch (tag) { case "MyDep": - return composition.RootM03D12di0001; + return composition.RootM03D13di0001; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.Basics.CheckForRootScenario.IDependency."); } diff --git a/readme/complex-generics.md b/readme/complex-generics.md index b9ec48f6b..b61bab4b0 100644 --- a/readme/complex-generics.md +++ b/readme/complex-generics.md @@ -95,7 +95,7 @@ classDiagram <> } ProgramᐸStringᐳ *-- ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ : IServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ - Composition ..> ProgramᐸStringᐳ : ProgramᐸStringᐳ Root + Composition ..> ProgramᐸStringᐳ : ProgramᐸStringᐳ Root
provides ProgramᐸStringᐳ ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ *-- DependencyᐸStringᐳ : IDependencyᐸStringᐳ ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ *-- DependencyStructᐸInt32ᐳ : "value type" IDependencyᐸInt32ᐳ ``` @@ -107,7 +107,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -115,7 +115,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.ComplexGenericsScenario.Program<string>>() ///
/// /// Provides a composition root of type . @@ -123,6 +123,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -130,21 +131,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -153,10 +155,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.ComplexGenericsScenario.Program Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -180,7 +192,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -194,7 +206,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -207,10 +219,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -231,10 +243,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -284,31 +296,31 @@ partial class Composition " <>\n" + " }\n" + " ProgramᐸStringᐳ *-- ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ : IServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ\n" + - " Composition ..> ProgramᐸStringᐳ : ProgramᐸStringᐳ Root\n" + + " Composition ..> ProgramᐸStringᐳ : ProgramᐸStringᐳ Root
provides ProgramᐸStringᐳ\n" + " ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ *-- DependencyᐸStringᐳ : IDependencyᐸStringᐳ\n" + " ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ *-- DependencyStructᐸInt32ᐳ : \"value type\" IDependencyᐸInt32ᐳ"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di>.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di>.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.ComplexGenericsScenario.Program), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.ComplexGenericsScenario.Program), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -321,7 +333,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver> + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver> { public Pure.DI.UsageTests.Basics.ComplexGenericsScenario.Program Resolve(Composition composition) { diff --git a/readme/composition-root-kinds.md b/readme/composition-root-kinds.md index ae90bf3a1..aa1b3cc75 100644 --- a/readme/composition-root-kinds.md +++ b/readme/composition-root-kinds.md @@ -48,8 +48,8 @@ var dependency = Composition.Dependency; classDiagram class Composition { +IDependency Dependency - +IService GetOtherService - +IService GetRoot + +IService GetOtherService() + +IService GetRoot() + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -74,9 +74,9 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService GetRoot - Composition ..> OtherService : "Other" IService GetOtherService - Composition ..> Dependency : IDependency Dependency + Composition ..> Service : IService GetRoot()
provides IService + Composition ..> OtherService : IService GetOtherService()
provides "Other" IService + Composition ..> Dependency : IDependency Dependency
provides IDependency ``` @@ -86,7 +86,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -94,7 +94,7 @@ classDiagram /// /// /// -/// Dependency +///
or using method: Resolve<Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IDependency>() ///
/// /// Creates a internal static root named "Dependency" @@ -102,7 +102,7 @@ classDiagram ///
/// /// -/// GetOtherService +///
or using method: Resolve<Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IService>("Other") ///
/// /// Creates a public root method named "GetOtherService" @@ -110,7 +110,7 @@ classDiagram ///
/// /// -/// GetRoot +///
or using method: Resolve<Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IService>() ///
/// /// Creates a private partial root method named "GetRoot" @@ -118,6 +118,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -125,21 +126,22 @@ classDiagram /// var instance = composition.Dependency; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -148,27 +150,41 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots - #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET - [global::System.Diagnostics.Contracts.Pure] - #endif /// /// Creates a private partial root method named "GetRoot" /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.GetRoot(); + /// + /// + #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET + [global::System.Diagnostics.Contracts.Pure] + #endif private partial Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IService GetRoot() { return new Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.Service(new Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.Dependency()); } - #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET - [global::System.Diagnostics.Contracts.Pure] - #endif /// /// Creates a public root method named "GetOtherService" /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.GetOtherService(); + /// + /// + #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET + [global::System.Diagnostics.Contracts.Pure] + #endif public Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IService GetOtherService() { return new Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.OtherService(); @@ -177,6 +193,13 @@ partial class Composition /// /// Creates a internal static root named "Dependency" /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Dependency; + /// + /// internal static Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IDependency Dependency { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -200,7 +223,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -214,7 +237,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -227,10 +250,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -251,10 +274,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -274,8 +297,8 @@ partial class Composition "classDiagram\n" + " class Composition {\n" + " +IDependency Dependency\n" + - " +IService GetOtherService\n" + - " +IService GetRoot\n" + + " +IService GetOtherService()\n" + + " +IService GetRoot()\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -300,34 +323,34 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService GetRoot\n" + - " Composition ..> OtherService : \"Other\" IService GetOtherService\n" + - " Composition ..> Dependency : IDependency Dependency"; + " Composition ..> Service : IService GetRoot()
provides IService\n" + + " Composition ..> OtherService : IService GetOtherService()
provides \"Other\" IService\n" + + " Composition ..> Dependency : IDependency Dependency
provides IDependency"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IService), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IDependency), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IService), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IDependency), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -340,7 +363,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IService Resolve(Composition composition) { @@ -360,7 +383,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.CompositionRootKindsScenario.IDependency Resolve(Composition composition) { diff --git a/readme/composition-roots.md b/readme/composition-roots.md index 2d4e633d7..34c3c976c 100644 --- a/readme/composition-roots.md +++ b/readme/composition-roots.md @@ -71,7 +71,7 @@ classDiagram class Composition { +IService MyRoot +IService SomeOtherService - -IDependency RootM03D12di0003 + -IDependency RootM03D13di0003 + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -96,9 +96,9 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> OtherService : "Other" IService SomeOtherService - Composition ..> Service : IService MyRoot - Composition ..> Dependency : IDependency RootM03D12di0003 + Composition ..> OtherService : IService SomeOtherService
provides "Other" IService + Composition ..> Service : IService MyRoot
provides IService + Composition ..> Dependency : IDependency RootM03D13di0003
provides IDependency ``` @@ -108,7 +108,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -116,7 +116,7 @@ classDiagram /// /// /// -/// MyRoot +///
or using method: Resolve<Pure.DI.UsageTests.Basics.CompositionRootsScenario.IService>() ///
/// /// Specifies to create a regular public composition root
@@ -125,7 +125,7 @@ classDiagram ///
/// /// -/// SomeOtherService +///
or using method: Resolve<Pure.DI.UsageTests.Basics.CompositionRootsScenario.IService>("Other") ///
/// /// Specifies to create a regular public composition root
@@ -135,7 +135,7 @@ classDiagram ///
/// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.Basics.CompositionRootsScenario.IDependency>() ///
/// /// Specifies to create a private composition root
@@ -144,6 +144,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -151,21 +152,22 @@ classDiagram /// var instance = composition.MyRoot; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -174,7 +176,7 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots @@ -182,6 +184,13 @@ partial class Composition /// Specifies to create a regular public composition root
/// of type "IService" with the name "MyRoot" ///
+ /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.MyRoot; + /// + /// public Pure.DI.UsageTests.Basics.CompositionRootsScenario.IService MyRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -198,6 +207,13 @@ partial class Composition /// of type "IService" with the name "SomeOtherService"
/// using the "Other" tag ///
+ /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.SomeOtherService; + /// + /// public Pure.DI.UsageTests.Basics.CompositionRootsScenario.IService SomeOtherService { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -213,7 +229,7 @@ partial class Composition /// Specifies to create a private composition root
/// that is only accessible from "Resolve()" methods ///
- public Pure.DI.UsageTests.Basics.CompositionRootsScenario.IDependency RootM03D12di0003 + public Pure.DI.UsageTests.Basics.CompositionRootsScenario.IDependency RootM03D13di0003 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] @@ -236,7 +252,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -250,7 +266,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -263,10 +279,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -287,10 +303,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -311,7 +327,7 @@ partial class Composition " class Composition {\n" + " +IService MyRoot\n" + " +IService SomeOtherService\n" + - " -IDependency RootM03D12di0003\n" + + " -IDependency RootM03D13di0003\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -336,34 +352,34 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> OtherService : \"Other\" IService SomeOtherService\n" + - " Composition ..> Service : IService MyRoot\n" + - " Composition ..> Dependency : IDependency RootM03D12di0003"; + " Composition ..> OtherService : IService SomeOtherService
provides \"Other\" IService\n" + + " Composition ..> Service : IService MyRoot
provides IService\n" + + " Composition ..> Dependency : IDependency RootM03D13di0003
provides IDependency"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CompositionRootsScenario.IService), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CompositionRootsScenario.IDependency), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CompositionRootsScenario.IService), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.CompositionRootsScenario.IDependency), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -376,7 +392,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.CompositionRootsScenario.IService Resolve(Composition composition) { @@ -396,11 +412,11 @@ partial class Composition } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.CompositionRootsScenario.IDependency Resolve(Composition composition) { - return composition.RootM03D12di0003; + return composition.RootM03D13di0003; } public Pure.DI.UsageTests.Basics.CompositionRootsScenario.IDependency ResolveByTag(Composition composition, object tag) @@ -408,7 +424,7 @@ partial class Composition switch (tag) { case null: - return composition.RootM03D12di0003; + return composition.RootM03D13di0003; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.Basics.CompositionRootsScenario.IDependency."); } diff --git a/readme/constructor-ordinal-attribute.md b/readme/constructor-ordinal-attribute.md index fc530659b..074874bf9 100644 --- a/readme/constructor-ordinal-attribute.md +++ b/readme/constructor-ordinal-attribute.md @@ -60,7 +60,7 @@ classDiagram <> } Service o-- String : Argument "serviceName" - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -70,7 +70,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -78,7 +78,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Attributes.ConstructorOrdinalAttributeScenario.IService>() ///
/// /// Provides a composition root of type . @@ -86,22 +86,24 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// -/// var composition = new Composition(serviceName); +/// var composition = new Composition(_argM03D13di_serviceName); /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly string _argM03D12di_serviceName; + private readonly Composition _rootM03D13di; + private readonly string _argM03D13di_serviceName; /// /// This parameterized constructor creates a new instance of with arguments. @@ -109,13 +111,13 @@ partial class Composition /// The composition argument of type . public Composition(string serviceName) { - _rootM03D12di = this; + _rootM03D13di = this; if (ReferenceEquals(serviceName, null)) { throw new global::System.ArgumentNullException("serviceName"); } - _argM03D12di_serviceName = serviceName; + _argM03D13di_serviceName = serviceName; } /// @@ -124,11 +126,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _argM03D12di_serviceName = baseComposition._argM03D12di_serviceName; + _rootM03D13di = baseComposition._rootM03D13di; + _argM03D13di_serviceName = baseComposition._argM03D13di_serviceName; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(_argM03D13di_serviceName); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Attributes.ConstructorOrdinalAttributeScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -136,7 +148,7 @@ partial class Composition #endif get { - return new Pure.DI.UsageTests.Attributes.ConstructorOrdinalAttributeScenario.Service(_argM03D12di_serviceName); + return new Pure.DI.UsageTests.Attributes.ConstructorOrdinalAttributeScenario.Service(_argM03D13di_serviceName); } } #endregion @@ -152,7 +164,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -166,7 +178,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -179,10 +191,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -203,10 +215,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -240,29 +252,29 @@ partial class Composition " <>\n" + " }\n" + " Service o-- String : Argument \"serviceName\"\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Attributes.ConstructorOrdinalAttributeScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Attributes.ConstructorOrdinalAttributeScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -275,7 +287,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Attributes.ConstructorOrdinalAttributeScenario.IService Resolve(Composition composition) { diff --git a/readme/custom-attributes.md b/readme/custom-attributes.md index 073c1743a..a3df2d943 100644 --- a/readme/custom-attributes.md +++ b/readme/custom-attributes.md @@ -76,7 +76,7 @@ classDiagram } Person *-- String : "NikName" String Person o-- Int32 : Argument "personId" - PersonComposition ..> Person : IPerson Person + PersonComposition ..> Person : IPerson Person
provides IPerson ``` @@ -86,7 +86,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -94,7 +94,7 @@ classDiagram /// /// /// -/// Person +///
or using method: Resolve<Pure.DI.UsageTests.Attributes.CustomAttributesScenario.IPerson>() ///
/// /// Provides a composition root of type . @@ -102,22 +102,24 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// -/// var composition = new PersonComposition(personId); +/// var composition = new PersonComposition(_argM03D13di_personId); /// var instance = composition.Person; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class PersonComposition { - private readonly PersonComposition _rootM03D12di; - private readonly int _argM03D12di_personId; + private readonly PersonComposition _rootM03D13di; + private readonly int _argM03D13di_personId; /// /// This parameterized constructor creates a new instance of with arguments. @@ -125,8 +127,8 @@ partial class PersonComposition /// The composition argument of type . public PersonComposition(int personId) { - _rootM03D12di = this; - _argM03D12di_personId = personId; + _rootM03D13di = this; + _argM03D13di_personId = personId; } /// @@ -135,11 +137,21 @@ partial class PersonComposition /// Base composition. internal PersonComposition(PersonComposition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _argM03D12di_personId = baseComposition._argM03D12di_personId; + _rootM03D13di = baseComposition._rootM03D13di; + _argM03D13di_personId = baseComposition._argM03D13di_personId; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new PersonComposition(_argM03D13di_personId); + /// var instance = composition.Person; + /// + /// public Pure.DI.UsageTests.Attributes.CustomAttributesScenario.IPerson Person { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -147,10 +159,10 @@ partial class PersonComposition #endif get { - string transientM03D12di1_String = "Nik"; - var transientM03D12di0_Person = new Pure.DI.UsageTests.Attributes.CustomAttributesScenario.Person(transientM03D12di1_String); - transientM03D12di0_Person.Id = _argM03D12di_personId; - return transientM03D12di0_Person; + string transientM03D13di1_String = "Nik"; + var transientM03D13di0_Person = new Pure.DI.UsageTests.Attributes.CustomAttributesScenario.Person(transientM03D13di1_String); + transientM03D13di0_Person.Id = _argM03D13di_personId; + return transientM03D13di0_Person; } } #endregion @@ -166,7 +178,7 @@ partial class PersonComposition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -180,7 +192,7 @@ partial class PersonComposition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -193,10 +205,10 @@ partial class PersonComposition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -217,10 +229,10 @@ partial class PersonComposition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -257,29 +269,29 @@ partial class PersonComposition " }\n" + " Person *-- String : \"NikName\" String\n" + " Person o-- Int32 : Argument \"personId\"\n" + - " PersonComposition ..> Person : IPerson Person"; + " PersonComposition ..> Person : IPerson Person
provides IPerson"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static PersonComposition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Attributes.CustomAttributesScenario.IPerson), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Attributes.CustomAttributesScenario.IPerson), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(PersonComposition composite) { @@ -292,7 +304,7 @@ partial class PersonComposition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Attributes.CustomAttributesScenario.IPerson Resolve(PersonComposition composition) { diff --git a/readme/decorator.md b/readme/decorator.md index 99f48f20e..24efe1f5e 100644 --- a/readme/decorator.md +++ b/readme/decorator.md @@ -53,7 +53,7 @@ classDiagram <> } GreetingService *-- Service : "base" IService - Composition ..> GreetingService : IService Root + Composition ..> GreetingService : IService Root
provides IService ``` @@ -63,7 +63,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -71,7 +71,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Interception.DecoratorScenario.IService>() ///
/// /// Provides a composition root of type . @@ -79,6 +79,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -86,21 +87,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -109,10 +111,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Interception.DecoratorScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -136,7 +148,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -150,7 +162,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -163,10 +175,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -187,10 +199,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -227,29 +239,29 @@ partial class Composition " <>\n" + " }\n" + " GreetingService *-- Service : \"base\" IService\n" + - " Composition ..> GreetingService : IService Root"; + " Composition ..> GreetingService : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Interception.DecoratorScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Interception.DecoratorScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -262,7 +274,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Interception.DecoratorScenario.IService Resolve(Composition composition) { diff --git a/readme/default-lifetime.md b/readme/default-lifetime.md index 97d4ae6cf..e5f3dc9be 100644 --- a/readme/default-lifetime.md +++ b/readme/default-lifetime.md @@ -66,7 +66,7 @@ classDiagram } Service o-- "Singleton" Dependency : IDependency Service o-- "Singleton" Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -76,7 +76,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -84,7 +84,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.IService>() ///
/// /// Provides a composition root of type . @@ -92,6 +92,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -99,25 +100,26 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.Service _singletonM03D12di35_Service; - private Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.Dependency _singletonM03D12di34_Dependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.Service _singletonM03D13di35_Service; + private Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.Dependency _singletonM03D13di34_Dependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -126,11 +128,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -138,23 +150,23 @@ partial class Composition #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_Service, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_Service, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_Service, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_Service, null)) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } - _singletonM03D12di35_Service = new Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.Service(_singletonM03D12di34_Dependency, _rootM03D12di._singletonM03D12di34_Dependency); - _rootM03D12di._singletonM03D12di35_Service = _singletonM03D12di35_Service; + _singletonM03D13di35_Service = new Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.Service(_singletonM03D13di34_Dependency, _rootM03D13di._singletonM03D13di34_Dependency); + _rootM03D13di._singletonM03D13di35_Service = _singletonM03D13di35_Service; } } } - return _rootM03D12di._singletonM03D12di35_Service; + return _rootM03D13di._singletonM03D13di35_Service; } } #endregion @@ -170,7 +182,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -184,7 +196,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -197,10 +209,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -221,10 +233,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -265,29 +277,29 @@ partial class Composition " }\n" + " Service o-- \"Singleton\" Dependency : IDependency\n" + " Service o-- \"Singleton\" Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -300,7 +312,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.DefaultLifetimeScenario.IService Resolve(Composition composition) { diff --git a/readme/default-values.md b/readme/default-values.md index c8b5f9b47..6e1f88fa2 100644 --- a/readme/default-values.md +++ b/readme/default-values.md @@ -59,7 +59,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -69,7 +69,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -77,7 +77,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.DefaultValuesScenario.IService>() ///
/// /// Provides a composition root of type . @@ -85,6 +85,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -92,21 +93,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -115,10 +117,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.DefaultValuesScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -145,7 +157,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -159,7 +171,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -172,10 +184,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -196,10 +208,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -240,29 +252,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.DefaultValuesScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.DefaultValuesScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -275,7 +287,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.DefaultValuesScenario.IService Resolve(Composition composition) { diff --git a/readme/dependent-compositions.md b/readme/dependent-compositions.md index 5e791163a..6e1502157 100644 --- a/readme/dependent-compositions.md +++ b/readme/dependent-compositions.md @@ -77,8 +77,8 @@ classDiagram } Program *-- Service : IService Service *-- Dependency : IDependency - OtherComposition ..> Service : IService Root - OtherComposition ..> Program : Program Program + OtherComposition ..> Service : IService Root
provides IService + OtherComposition ..> Program : Program Program
provides Program ``` @@ -91,7 +91,7 @@ classDiagram /// This setup generates code and can also be used as a dependency /// /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -99,7 +99,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService>() ///
/// /// Provides a composition root of type . @@ -107,6 +107,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -114,21 +115,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -137,10 +139,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -164,7 +176,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -178,7 +190,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -191,10 +203,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -215,10 +227,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -258,29 +270,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -293,7 +305,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService Resolve(Composition composition) { @@ -325,7 +337,7 @@ partial class Composition /// As in the previous case, this setup generates code and can also be used as a dependency /// /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -333,7 +345,7 @@ partial class Composition /// /// /// -/// Program +///
or using method: Resolve<Pure.DI.UsageTests.Basics.DependentCompositionsScenario.Program>() ///
/// /// Provides a composition root of type . @@ -341,7 +353,7 @@ partial class Composition ///
/// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService>() ///
/// /// Provides a composition root of type . @@ -349,6 +361,7 @@ partial class Composition ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -356,21 +369,22 @@ partial class Composition /// var instance = composition.Program; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class OtherComposition { - private readonly OtherComposition _rootM03D12di; + private readonly OtherComposition _rootM03D13di; /// /// This constructor creates a new instance of . /// public OtherComposition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -379,10 +393,20 @@ partial class OtherComposition /// Base composition. internal OtherComposition(OtherComposition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new OtherComposition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -394,6 +418,16 @@ partial class OtherComposition } } + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new OtherComposition(); + /// var instance = composition.Program; + /// + /// public Pure.DI.UsageTests.Basics.DependentCompositionsScenario.Program Program { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -417,7 +451,7 @@ partial class OtherComposition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -431,7 +465,7 @@ partial class OtherComposition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -444,10 +478,10 @@ partial class OtherComposition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -468,10 +502,10 @@ partial class OtherComposition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -516,33 +550,33 @@ partial class OtherComposition " }\n" + " Program *-- Service : IService\n" + " Service *-- Dependency : IDependency\n" + - " OtherComposition ..> Service : IService Root\n" + - " OtherComposition ..> Program : Program Program"; + " OtherComposition ..> Service : IService Root
provides IService\n" + + " OtherComposition ..> Program : Program Program
provides Program"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static OtherComposition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.DependentCompositionsScenario.Program), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.DependentCompositionsScenario.Program), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(OtherComposition composite) { @@ -555,7 +589,7 @@ partial class OtherComposition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.DependentCompositionsScenario.IService Resolve(OtherComposition composition) { @@ -573,7 +607,7 @@ partial class OtherComposition } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.DependentCompositionsScenario.Program Resolve(OtherComposition composition) { diff --git a/readme/disposable-singleton.md b/readme/disposable-singleton.md index 9193c456b..1b83003ba 100644 --- a/readme/disposable-singleton.md +++ b/readme/disposable-singleton.md @@ -72,7 +72,7 @@ classDiagram <> } Service o-- "Singleton" Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -82,7 +82,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -90,7 +90,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.IService>() ///
/// /// Provides a composition root of type . @@ -98,6 +98,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -105,27 +106,28 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition: global::System.IDisposable { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private readonly global::System.IDisposable[] _disposablesM03D12di; - private int _disposeIndexM03D12di; - private Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.Dependency _singletonM03D12di34_Dependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private readonly global::System.IDisposable[] _disposablesM03D13di; + private int _disposeIndexM03D13di; + private Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.Dependency _singletonM03D13di34_Dependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); - _disposablesM03D12di = new global::System.IDisposable[1]; + _rootM03D13di = this; + _lockM03D13di = new object(); + _disposablesM03D13di = new global::System.IDisposable[1]; } /// @@ -134,11 +136,21 @@ partial class Composition: global::System.IDisposable /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// using var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -146,19 +158,19 @@ partial class Composition: global::System.IDisposable #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; - _rootM03D12di._disposablesM03D12di[_rootM03D12di._disposeIndexM03D12di++] = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; + _rootM03D13di._disposablesM03D13di[_rootM03D13di._disposeIndexM03D13di++] = _singletonM03D13di34_Dependency; } } } - return new Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.Service(_rootM03D12di._singletonM03D12di34_Dependency); + return new Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.Service(_rootM03D13di._singletonM03D13di34_Dependency); } } #endregion @@ -174,7 +186,7 @@ partial class Composition: global::System.IDisposable #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -188,7 +200,7 @@ partial class Composition: global::System.IDisposable #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -201,10 +213,10 @@ partial class Composition: global::System.IDisposable #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -225,10 +237,10 @@ partial class Composition: global::System.IDisposable #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -245,11 +257,11 @@ partial class Composition: global::System.IDisposable /// public void Dispose() { - lock (_lockM03D12di) + lock (_lockM03D13di) { - while (_disposeIndexM03D12di > 0) + while (_disposeIndexM03D13di > 0) { - var disposableInstance = _disposablesM03D12di[--_disposeIndexM03D12di]; + var disposableInstance = _disposablesM03D13di[--_disposeIndexM03D13di]; try { disposableInstance.Dispose(); @@ -260,7 +272,7 @@ partial class Composition: global::System.IDisposable } } - _singletonM03D12di34_Dependency = null; + _singletonM03D13di34_Dependency = null; } } @@ -296,29 +308,29 @@ partial class Composition: global::System.IDisposable " <>\n" + " }\n" + " Service o-- \"Singleton\" Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -331,7 +343,7 @@ partial class Composition: global::System.IDisposable } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.DisposableSingletonScenario.IService Resolve(Composition composition) { diff --git a/readme/enumerable-generics.md b/readme/enumerable-generics.md index bb684d410..3ed0d4ad5 100644 --- a/readme/enumerable-generics.md +++ b/readme/enumerable-generics.md @@ -95,8 +95,8 @@ classDiagram IEnumerableᐸIDependencyᐸStringᐳᐳ *-- XyzDependencyᐸStringᐳ : "Xyz" IDependencyᐸStringᐳ IEnumerableᐸIDependencyᐸInt32ᐳᐳ *-- AbcDependencyᐸInt32ᐳ : IDependencyᐸInt32ᐳ IEnumerableᐸIDependencyᐸInt32ᐳᐳ *-- XyzDependencyᐸInt32ᐳ : "Xyz" IDependencyᐸInt32ᐳ - Composition ..> ServiceᐸInt32ᐳ : IServiceᐸInt32ᐳ IntRoot - Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ StringRoot + Composition ..> ServiceᐸInt32ᐳ : IServiceᐸInt32ᐳ IntRoot
provides IServiceᐸInt32ᐳ + Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ StringRoot
provides IServiceᐸStringᐳ ServiceᐸInt32ᐳ o-- "PerBlock" IEnumerableᐸIDependencyᐸInt32ᐳᐳ : IEnumerableᐸIDependencyᐸInt32ᐳᐳ ServiceᐸStringᐳ o-- "PerBlock" IEnumerableᐸIDependencyᐸStringᐳᐳ : IEnumerableᐸIDependencyᐸStringᐳᐳ ``` @@ -108,7 +108,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -116,7 +116,7 @@ classDiagram /// /// /// -/// IntRoot +///
or using method: Resolve<Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService<int>>() ///
/// /// Provides a composition root of type . @@ -124,7 +124,7 @@ classDiagram ///
/// /// -/// StringRoot +///
or using method: Resolve<Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService<string>>() ///
/// /// Provides a composition root of type . @@ -132,6 +132,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -139,21 +140,22 @@ classDiagram /// var instance = composition.IntRoot; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -162,10 +164,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.IntRoot; + /// + /// public Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService IntRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -174,16 +186,26 @@ partial class Composition get { [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x200)] - System.Collections.Generic.IEnumerable> LocalperBlockM03D12di1_IEnumerable() + System.Collections.Generic.IEnumerable> LocalperBlockM03D13di1_IEnumerable() { yield return new Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.AbcDependency(); yield return new Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.XyzDependency(); } - var perBlockM03D12di1_IEnumerable = LocalperBlockM03D12di1_IEnumerable(); - return new Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.Service(perBlockM03D12di1_IEnumerable); + var perBlockM03D13di1_IEnumerable = LocalperBlockM03D13di1_IEnumerable(); + return new Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.Service(perBlockM03D13di1_IEnumerable); } } + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.StringRoot; + /// + /// public Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService StringRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -192,13 +214,13 @@ partial class Composition get { [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x200)] - System.Collections.Generic.IEnumerable> LocalperBlockM03D12di1_IEnumerable() + System.Collections.Generic.IEnumerable> LocalperBlockM03D13di1_IEnumerable() { yield return new Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.AbcDependency(); yield return new Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.XyzDependency(); } - var perBlockM03D12di1_IEnumerable = LocalperBlockM03D12di1_IEnumerable(); - return new Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.Service(perBlockM03D12di1_IEnumerable); + var perBlockM03D13di1_IEnumerable = LocalperBlockM03D13di1_IEnumerable(); + return new Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.Service(perBlockM03D13di1_IEnumerable); } } #endregion @@ -214,7 +236,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -228,7 +250,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -241,10 +263,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -265,10 +287,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -336,35 +358,35 @@ partial class Composition " IEnumerableᐸIDependencyᐸStringᐳᐳ *-- XyzDependencyᐸStringᐳ : \"Xyz\" IDependencyᐸStringᐳ\n" + " IEnumerableᐸIDependencyᐸInt32ᐳᐳ *-- AbcDependencyᐸInt32ᐳ : IDependencyᐸInt32ᐳ\n" + " IEnumerableᐸIDependencyᐸInt32ᐳᐳ *-- XyzDependencyᐸInt32ᐳ : \"Xyz\" IDependencyᐸInt32ᐳ\n" + - " Composition ..> ServiceᐸInt32ᐳ : IServiceᐸInt32ᐳ IntRoot\n" + - " Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ StringRoot\n" + + " Composition ..> ServiceᐸInt32ᐳ : IServiceᐸInt32ᐳ IntRoot
provides IServiceᐸInt32ᐳ\n" + + " Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ StringRoot
provides IServiceᐸStringᐳ\n" + " ServiceᐸInt32ᐳ o-- \"PerBlock\" IEnumerableᐸIDependencyᐸInt32ᐳᐳ : IEnumerableᐸIDependencyᐸInt32ᐳᐳ\n" + " ServiceᐸStringᐳ o-- \"PerBlock\" IEnumerableᐸIDependencyᐸStringᐳᐳ : IEnumerableᐸIDependencyᐸStringᐳᐳ"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di>.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di>.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di>.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di>.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -377,7 +399,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver> + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver> { public Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService Resolve(Composition composition) { @@ -395,7 +417,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver> + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver> { public Pure.DI.UsageTests.BCL.EnumerableGenericsScenario.IService Resolve(Composition composition) { diff --git a/readme/enumerable.md b/readme/enumerable.md index 92d71f675..43dff8620 100644 --- a/readme/enumerable.md +++ b/readme/enumerable.md @@ -68,7 +68,7 @@ classDiagram IEnumerableᐸIDependencyᐳ *-- AbcDependency : IDependency IEnumerableᐸIDependencyᐳ *-- XyzDependency : 2 IDependency Service o-- "PerBlock" IEnumerableᐸIDependencyᐳ : IEnumerableᐸIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -78,7 +78,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -86,7 +86,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.EnumerableScenario.IService>() ///
/// /// Provides a composition root of type . @@ -94,6 +94,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -101,21 +102,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -124,10 +126,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.EnumerableScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -136,13 +148,13 @@ partial class Composition get { [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x200)] - System.Collections.Generic.IEnumerable LocalperBlockM03D12di1_IEnumerable() + System.Collections.Generic.IEnumerable LocalperBlockM03D13di1_IEnumerable() { yield return new Pure.DI.UsageTests.BCL.EnumerableScenario.AbcDependency(); yield return new Pure.DI.UsageTests.BCL.EnumerableScenario.XyzDependency(); } - var perBlockM03D12di1_IEnumerable = LocalperBlockM03D12di1_IEnumerable(); - return new Pure.DI.UsageTests.BCL.EnumerableScenario.Service(perBlockM03D12di1_IEnumerable); + var perBlockM03D13di1_IEnumerable = LocalperBlockM03D13di1_IEnumerable(); + return new Pure.DI.UsageTests.BCL.EnumerableScenario.Service(perBlockM03D13di1_IEnumerable); } } #endregion @@ -158,7 +170,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -172,7 +184,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -185,10 +197,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -209,10 +221,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -259,29 +271,29 @@ partial class Composition " IEnumerableᐸIDependencyᐳ *-- AbcDependency : IDependency\n" + " IEnumerableᐸIDependencyᐳ *-- XyzDependency : 2 IDependency\n" + " Service o-- \"PerBlock\" IEnumerableᐸIDependencyᐳ : IEnumerableᐸIDependencyᐳ\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.EnumerableScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.EnumerableScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -294,7 +306,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.EnumerableScenario.IService Resolve(Composition composition) { diff --git a/readme/factory.md b/readme/factory.md index 106ee671c..a7bd94230 100644 --- a/readme/factory.md +++ b/readme/factory.md @@ -70,7 +70,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -80,7 +80,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -88,7 +88,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.FactoryScenario.IService>() ///
/// /// Provides a composition root of type . @@ -96,6 +96,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -103,21 +104,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -126,10 +128,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.FactoryScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -137,13 +149,13 @@ partial class Composition #endif get { - Pure.DI.UsageTests.Basics.FactoryScenario.Dependency transientM03D12di1_Dependency; + Pure.DI.UsageTests.Basics.FactoryScenario.Dependency transientM03D13di1_Dependency; { - var dependency_M03D12di1 = new Dependency(DateTimeOffset.Now); - dependency_M03D12di1.Initialize(); - transientM03D12di1_Dependency = dependency_M03D12di1; + var dependency_M03D13di1 = new Dependency(DateTimeOffset.Now); + dependency_M03D13di1.Initialize(); + transientM03D13di1_Dependency = dependency_M03D13di1; } - return new Pure.DI.UsageTests.Basics.FactoryScenario.Service(transientM03D12di1_Dependency); + return new Pure.DI.UsageTests.Basics.FactoryScenario.Service(transientM03D13di1_Dependency); } } #endregion @@ -159,7 +171,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -173,7 +185,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -186,10 +198,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -210,10 +222,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -251,29 +263,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.FactoryScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.FactoryScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -286,7 +298,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.FactoryScenario.IService Resolve(Composition composition) { diff --git a/readme/field-injection.md b/readme/field-injection.md index 54f5bc9ec..7b5188e95 100644 --- a/readme/field-injection.md +++ b/readme/field-injection.md @@ -59,7 +59,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -69,7 +69,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -77,7 +77,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.FieldInjectionScenario.IService>() ///
/// /// Provides a composition root of type . @@ -85,6 +85,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -92,21 +93,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -115,10 +117,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.FieldInjectionScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -126,9 +138,9 @@ partial class Composition #endif get { - var transientM03D12di0_Service = new Pure.DI.UsageTests.Basics.FieldInjectionScenario.Service(); - transientM03D12di0_Service.DependencyVal = new Pure.DI.UsageTests.Basics.FieldInjectionScenario.Dependency(); - return transientM03D12di0_Service; + var transientM03D13di0_Service = new Pure.DI.UsageTests.Basics.FieldInjectionScenario.Service(); + transientM03D13di0_Service.DependencyVal = new Pure.DI.UsageTests.Basics.FieldInjectionScenario.Dependency(); + return transientM03D13di0_Service; } } #endregion @@ -144,7 +156,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -158,7 +170,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -171,10 +183,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -195,10 +207,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -239,29 +251,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.FieldInjectionScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.FieldInjectionScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -274,7 +286,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.FieldInjectionScenario.IService Resolve(Composition composition) { diff --git a/readme/func-with-arguments.md b/readme/func-with-arguments.md index 09c38b29e..aeca0888b 100644 --- a/readme/func-with-arguments.md +++ b/readme/func-with-arguments.md @@ -96,7 +96,7 @@ classDiagram Dependency *-- Int32 : Int32 FuncᐸInt32ˏIDependencyᐳ *-- Dependency : Dependency Service *-- FuncᐸInt32ˏIDependencyᐳ : FuncᐸInt32ˏIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -106,7 +106,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -114,7 +114,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.IService>() ///
/// /// Provides a composition root of type . @@ -122,6 +122,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -129,24 +130,25 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.Clock _singletonM03D12di34_Clock; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.Clock _singletonM03D13di34_Clock; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -155,11 +157,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -167,24 +179,24 @@ partial class Composition #endif get { - System.Func transientM03D12di1_Func = dependencyId => + System.Func transientM03D13di1_Func = dependencyId => { - int transientM03D12di3_Int32 = dependencyId; - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Clock, null)) + int transientM03D13di3_Int32 = dependencyId; + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Clock, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Clock, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Clock, null)) { - _singletonM03D12di34_Clock = new Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.Clock(); - _rootM03D12di._singletonM03D12di34_Clock = _singletonM03D12di34_Clock; + _singletonM03D13di34_Clock = new Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.Clock(); + _rootM03D13di._singletonM03D13di34_Clock = _singletonM03D13di34_Clock; } } } - var dependency_M03D12di1 = new Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.Dependency(_rootM03D12di._singletonM03D12di34_Clock, transientM03D12di3_Int32); - return dependency_M03D12di1; + var dependency_M03D13di1 = new Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.Dependency(_rootM03D13di._singletonM03D13di34_Clock, transientM03D13di3_Int32); + return dependency_M03D13di1; }; - return new Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.Service(transientM03D12di1_Func); + return new Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.Service(transientM03D13di1_Func); } } #endregion @@ -200,7 +212,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -214,7 +226,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -227,10 +239,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -251,10 +263,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -302,29 +314,29 @@ partial class Composition " Dependency *-- Int32 : Int32\n" + " FuncᐸInt32ˏIDependencyᐳ *-- Dependency : Dependency\n" + " Service *-- FuncᐸInt32ˏIDependencyᐳ : FuncᐸInt32ˏIDependencyᐳ\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -337,7 +349,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.FuncWithArgumentsScenario.IService Resolve(Composition composition) { diff --git a/readme/func.md b/readme/func.md index d5b9ecfe8..2d0ecf977 100644 --- a/readme/func.md +++ b/readme/func.md @@ -62,7 +62,7 @@ classDiagram <> } Service o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService FuncᐸIDependencyᐳ *-- Dependency : IDependency ``` @@ -73,7 +73,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -81,7 +81,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.FuncScenario.IService>() ///
/// /// Provides a composition root of type . @@ -89,6 +89,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -96,23 +97,24 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -121,11 +123,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.FuncScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -133,15 +145,15 @@ partial class Composition #endif get { - var perResolveM03D12di36_Func = default(System.Func); - perResolveM03D12di36_Func = new global::System.Func( + var perResolveM03D13di36_Func = default(System.Func); + perResolveM03D13di36_Func = new global::System.Func( [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)768)] () => { - var factory_M03D12di1 = new Pure.DI.UsageTests.BCL.FuncScenario.Dependency(); - return factory_M03D12di1; + var factory_M03D13di1 = new Pure.DI.UsageTests.BCL.FuncScenario.Dependency(); + return factory_M03D13di1; }); - return new Pure.DI.UsageTests.BCL.FuncScenario.Service(perResolveM03D12di36_Func); + return new Pure.DI.UsageTests.BCL.FuncScenario.Service(perResolveM03D13di36_Func); } } #endregion @@ -157,7 +169,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -171,7 +183,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -184,10 +196,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -208,10 +220,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -252,30 +264,30 @@ partial class Composition " <>\n" + " }\n" + " Service o-- \"PerResolve\" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ\n" + - " Composition ..> Service : IService Root\n" + + " Composition ..> Service : IService Root
provides IService\n" + " FuncᐸIDependencyᐳ *-- Dependency : IDependency"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.FuncScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.FuncScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -288,7 +300,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.FuncScenario.IService Resolve(Composition composition) { diff --git a/readme/generic-composition-roots.md b/readme/generic-composition-roots.md index b0546347c..1b0dd50fb 100644 --- a/readme/generic-composition-roots.md +++ b/readme/generic-composition-roots.md @@ -54,8 +54,8 @@ When a generic composition root is used, `Resolve` methods cannot be used to res ```mermaid classDiagram class Composition { - +IServiceᐸTᐳ GetMyRoot - +IServiceᐸTᐳ GetOtherService + +IServiceᐸTᐳ GetMyRootᐸTᐳ() + +IServiceᐸTᐳ GetOtherServiceᐸTᐳ() + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -77,8 +77,8 @@ classDiagram class IDependencyᐸTᐳ { <> } - Composition ..> ServiceᐸTᐳ : IServiceᐸTᐳ GetMyRoot - Composition ..> OtherServiceᐸTᐳ : "Other" IServiceᐸTᐳ GetOtherService + Composition ..> ServiceᐸTᐳ : IServiceᐸTᐳ GetMyRootᐸTᐳ()
provides IServiceᐸTᐳ + Composition ..> OtherServiceᐸTᐳ : IServiceᐸTᐳ GetOtherServiceᐸTᐳ()
provides "Other" IServiceᐸTᐳ ServiceᐸTᐳ *-- DependencyᐸTᐳ : IDependencyᐸTᐳ OtherServiceᐸTᐳ *-- DependencyᐸTᐳ : IDependencyᐸTᐳ ``` @@ -90,7 +90,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -98,7 +98,7 @@ classDiagram /// /// /// -/// GetMyRoot +/// /// /// /// Specifies to create a regular public method
@@ -108,7 +108,7 @@ classDiagram ///
/// /// -/// GetOtherService +/// /// /// /// Specifies to create a regular public method
@@ -119,28 +119,30 @@ classDiagram ///
///
///
+///
/// -/// This shows how to get an instance of type using the composition root : +/// This shows how to get an instance of type using the composition root : /// /// var composition = new Composition(); -/// var instance = composition.GetMyRoot; +/// var instance = composition.GetMyRoot<T>(); /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -149,40 +151,54 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots - #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET - [global::System.Diagnostics.Contracts.Pure] - #endif /// /// Specifies to create a regular public method
/// to get a composition root of type Service<T>
/// with the name "GetMyRoot" ///
+ /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.GetMyRoot<T>(); + /// + /// + #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET + [global::System.Diagnostics.Contracts.Pure] + #endif public Pure.DI.UsageTests.Basics.GenericsCompositionRootsScenario.IService GetMyRoot() { return new Pure.DI.UsageTests.Basics.GenericsCompositionRootsScenario.Service(new Pure.DI.UsageTests.Basics.GenericsCompositionRootsScenario.Dependency()); } - #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET - [global::System.Diagnostics.Contracts.Pure] - #endif /// /// Specifies to create a regular public method
/// to get a composition root of type OtherService<T>
/// with the name "GetOtherService"
/// using the "Other" tag ///
+ /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.GetOtherService<T>(); + /// + /// + #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET + [global::System.Diagnostics.Contracts.Pure] + #endif public Pure.DI.UsageTests.Basics.GenericsCompositionRootsScenario.IService GetOtherService() { - Pure.DI.UsageTests.Basics.GenericsCompositionRootsScenario.OtherService transientM03D12di0_OtherService; + Pure.DI.UsageTests.Basics.GenericsCompositionRootsScenario.OtherService transientM03D13di0_OtherService; { - var dependency_M03D12di1 = new Pure.DI.UsageTests.Basics.GenericsCompositionRootsScenario.Dependency(); - transientM03D12di0_OtherService = new OtherService(dependency_M03D12di1); + var dependency_M03D13di1 = new Pure.DI.UsageTests.Basics.GenericsCompositionRootsScenario.Dependency(); + transientM03D13di0_OtherService = new OtherService(dependency_M03D13di1); } - return transientM03D12di0_OtherService; + return transientM03D13di0_OtherService; } #endregion @@ -197,7 +213,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -211,7 +227,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -250,8 +266,8 @@ partial class Composition return "classDiagram\n" + " class Composition {\n" + - " +IServiceᐸTᐳ GetMyRoot\n" + - " +IServiceᐸTᐳ GetOtherService\n" + + " +IServiceᐸTᐳ GetMyRootᐸTᐳ()\n" + + " +IServiceᐸTᐳ GetOtherServiceᐸTᐳ()\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -273,17 +289,17 @@ partial class Composition " class IDependencyᐸTᐳ {\n" + " <>\n" + " }\n" + - " Composition ..> ServiceᐸTᐳ : IServiceᐸTᐳ GetMyRoot\n" + - " Composition ..> OtherServiceᐸTᐳ : \"Other\" IServiceᐸTᐳ GetOtherService\n" + + " Composition ..> ServiceᐸTᐳ : IServiceᐸTᐳ GetMyRootᐸTᐳ()
provides IServiceᐸTᐳ\n" + + " Composition ..> OtherServiceᐸTᐳ : IServiceᐸTᐳ GetOtherServiceᐸTᐳ()
provides \"Other\" IServiceᐸTᐳ\n" + " ServiceᐸTᐳ *-- DependencyᐸTᐳ : IDependencyᐸTᐳ\n" + " OtherServiceᐸTᐳ *-- DependencyᐸTᐳ : IDependencyᐸTᐳ"; } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { diff --git a/readme/generics.md b/readme/generics.md index a82d2a6f8..5dd2c68ea 100644 --- a/readme/generics.md +++ b/readme/generics.md @@ -82,7 +82,7 @@ classDiagram } Service *-- DependencyᐸInt32ᐳ : IDependencyᐸInt32ᐳ Service *-- DependencyᐸStringᐳ : IDependencyᐸStringᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -92,7 +92,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -100,7 +100,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.GenericsScenario.IService>() ///
/// /// Provides a composition root of type . @@ -108,6 +108,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -115,21 +116,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -138,10 +140,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.GenericsScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -165,7 +177,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -179,7 +191,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -192,10 +204,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -216,10 +228,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -267,29 +279,29 @@ partial class Composition " }\n" + " Service *-- DependencyᐸInt32ᐳ : IDependencyᐸInt32ᐳ\n" + " Service *-- DependencyᐸStringᐳ : IDependencyᐸStringᐳ\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.GenericsScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.GenericsScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -302,7 +314,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.GenericsScenario.IService Resolve(Composition composition) { diff --git a/readme/injection.md b/readme/injection.md index 58ece396a..145305785 100644 --- a/readme/injection.md +++ b/readme/injection.md @@ -60,7 +60,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -70,7 +70,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -78,7 +78,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.InjectionScenario.IService>() ///
/// /// Provides a composition root of type . @@ -86,6 +86,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -93,21 +94,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -116,10 +118,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.InjectionScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -127,12 +139,12 @@ partial class Composition #endif get { - Pure.DI.UsageTests.Basics.InjectionScenario.Service transientM03D12di0_Service; + Pure.DI.UsageTests.Basics.InjectionScenario.Service transientM03D13di0_Service; { - var dependency_M03D12di1 = new Pure.DI.UsageTests.Basics.InjectionScenario.Dependency(); - transientM03D12di0_Service = new Service(dependency_M03D12di1); + var dependency_M03D13di1 = new Pure.DI.UsageTests.Basics.InjectionScenario.Dependency(); + transientM03D13di0_Service = new Service(dependency_M03D13di1); } - return transientM03D12di0_Service; + return transientM03D13di0_Service; } } #endregion @@ -148,7 +160,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -162,7 +174,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -175,10 +187,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -199,10 +211,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -240,29 +252,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.InjectionScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.InjectionScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -275,7 +287,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.InjectionScenario.IService Resolve(Composition composition) { diff --git a/readme/injections-of-abstractions.md b/readme/injections-of-abstractions.md index cde28e76a..c7a1a7669 100644 --- a/readme/injections-of-abstractions.md +++ b/readme/injections-of-abstractions.md @@ -67,7 +67,7 @@ classDiagram } Program *-- Service : IService Service *-- Dependency : IDependency - Composition ..> Program : Program Root + Composition ..> Program : Program Root
provides Program ``` @@ -77,7 +77,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -85,7 +85,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.InjectionsOfAbstractionsScenario.Program>() ///
/// /// Specifies to create a composition root (a property)
@@ -94,6 +94,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -101,21 +102,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -124,7 +126,7 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots @@ -132,6 +134,13 @@ partial class Composition /// Specifies to create a composition root (a property)
/// of type "Program" with the name "Root": ///
+ /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.InjectionsOfAbstractionsScenario.Program Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -173,7 +182,7 @@ partial class Composition " }\n" + " Program *-- Service : IService\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Program : Program Root"; + " Composition ..> Program : Program Root
provides Program"; } } ``` diff --git a/readme/instance-initialization.md b/readme/instance-initialization.md index cead8bbfe..8d101d5c7 100644 --- a/readme/instance-initialization.md +++ b/readme/instance-initialization.md @@ -76,7 +76,7 @@ classDiagram } Service o-- String : Argument "serviceName" Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -86,7 +86,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -94,7 +94,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.InstanceInitializationScenario.IService>() ///
/// /// Provides a composition root of type . @@ -102,22 +102,24 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// -/// var composition = new Composition(serviceName); +/// var composition = new Composition(_argM03D13di_serviceName); /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly string _argM03D12di_serviceName; + private readonly Composition _rootM03D13di; + private readonly string _argM03D13di_serviceName; /// /// This parameterized constructor creates a new instance of with arguments. @@ -125,13 +127,13 @@ partial class Composition /// The composition argument of type . public Composition(string serviceName) { - _rootM03D12di = this; + _rootM03D13di = this; if (ReferenceEquals(serviceName, null)) { throw new global::System.ArgumentNullException("serviceName"); } - _argM03D12di_serviceName = serviceName; + _argM03D13di_serviceName = serviceName; } /// @@ -140,11 +142,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _argM03D12di_serviceName = baseComposition._argM03D12di_serviceName; + _rootM03D13di = baseComposition._rootM03D13di; + _argM03D13di_serviceName = baseComposition._argM03D13di_serviceName; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(_argM03D13di_serviceName); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.InstanceInitializationScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -152,13 +164,13 @@ partial class Composition #endif get { - Pure.DI.UsageTests.Basics.InstanceInitializationScenario.Service transientM03D12di0_Service; + Pure.DI.UsageTests.Basics.InstanceInitializationScenario.Service transientM03D13di0_Service; { - var service_M03D12di1 = new Pure.DI.UsageTests.Basics.InstanceInitializationScenario.Service(_argM03D12di_serviceName, new Pure.DI.UsageTests.Basics.InstanceInitializationScenario.Dependency()); - service_M03D12di1.Initialize(); - transientM03D12di0_Service = service_M03D12di1; + var service_M03D13di1 = new Pure.DI.UsageTests.Basics.InstanceInitializationScenario.Service(_argM03D13di_serviceName, new Pure.DI.UsageTests.Basics.InstanceInitializationScenario.Dependency()); + service_M03D13di1.Initialize(); + transientM03D13di0_Service = service_M03D13di1; } - return transientM03D12di0_Service; + return transientM03D13di0_Service; } } #endregion @@ -174,7 +186,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -188,7 +200,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -201,10 +213,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -225,10 +237,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -266,29 +278,29 @@ partial class Composition " }\n" + " Service o-- String : Argument \"serviceName\"\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.InstanceInitializationScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.InstanceInitializationScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -301,7 +313,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.InstanceInitializationScenario.IService Resolve(Composition composition) { diff --git a/readme/interception.md b/readme/interception.md index b87d4a886..59cf20927 100644 --- a/readme/interception.md +++ b/readme/interception.md @@ -72,7 +72,7 @@ classDiagram class IService { <> } - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -82,7 +82,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -90,7 +90,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Interception.InterceptionScenario.IService>() ///
/// /// Provides a composition root of type . @@ -98,6 +98,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -105,21 +106,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -128,10 +130,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Interception.InterceptionScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -155,7 +167,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -169,7 +181,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -182,10 +194,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -206,10 +218,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -243,29 +255,29 @@ partial class Composition " class IService {\n" + " <>\n" + " }\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Interception.InterceptionScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Interception.InterceptionScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -278,7 +290,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Interception.InterceptionScenario.IService Resolve(Composition composition) { diff --git a/readme/keyed-service-provider.md b/readme/keyed-service-provider.md index f267a2151..cb220c51e 100644 --- a/readme/keyed-service-provider.md +++ b/readme/keyed-service-provider.md @@ -50,8 +50,8 @@ service.Dependency.ShouldBe(dependency); ```mermaid classDiagram class Composition { - -IDependency RootM03D12di0001 - -IService RootM03D12di0002 + -IDependency RootM03D13di0001 + -IService RootM03D13di0002 + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object GetService(Type type) @@ -72,8 +72,8 @@ classDiagram <> } Service o-- "Singleton" Dependency : "Dependency Key" IDependency - Composition ..> Dependency : "Dependency Key" IDependency RootM03D12di0001 - Composition ..> Service : "Service Key" IService RootM03D12di0002 + Composition ..> Dependency : IDependency RootM03D13di0001
provides "Dependency Key" IDependency + Composition ..> Service : IService RootM03D13di0002
provides "Service Key" IService ``` @@ -83,7 +83,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -91,7 +91,7 @@ classDiagram /// /// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IDependency>("Dependency Key") ///
/// /// Provides a composition root of type . @@ -99,7 +99,7 @@ classDiagram ///
/// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IService>("Service Key") ///
/// /// Provides a composition root of type . @@ -107,24 +107,26 @@ classDiagram ///
///
///
-/// Class diagram
-/// This class was created by Pure.DI source code generator. ///
+/// Class diagram
+/// This class was created by Pure.DI source code generator. /// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.Dependency _singletonM03D12di34_Dependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.Dependency _singletonM03D13di34_Dependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -133,52 +135,58 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots - public Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IDependency RootM03D12di0001 + /// + /// Provides a composition root of type . + /// + public Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IDependency RootM03D13di0001 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } } } - return _rootM03D12di._singletonM03D12di34_Dependency; + return _rootM03D13di._singletonM03D13di34_Dependency; } } - public Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IService RootM03D12di0002 + /// + /// Provides a composition root of type . + /// + public Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IService RootM03D13di0002 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } } } - return new Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.Service(_rootM03D12di._singletonM03D12di34_Dependency); + return new Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.Service(_rootM03D13di._singletonM03D13di34_Dependency); } } #endregion @@ -194,7 +202,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -208,7 +216,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -221,10 +229,10 @@ partial class Composition #endif public object GetService(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -245,10 +253,10 @@ partial class Composition #endif public object GetRequiredKeyedService(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -267,8 +275,8 @@ partial class Composition return "classDiagram\n" + " class Composition {\n" + - " -IDependency RootM03D12di0001\n" + - " -IService RootM03D12di0002\n" + + " -IDependency RootM03D13di0001\n" + + " -IService RootM03D13di0002\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object GetService(Type type)\n" + @@ -289,33 +297,33 @@ partial class Composition " <>\n" + " }\n" + " Service o-- \"Singleton\" Dependency : \"Dependency Key\" IDependency\n" + - " Composition ..> Dependency : \"Dependency Key\" IDependency RootM03D12di0001\n" + - " Composition ..> Service : \"Service Key\" IService RootM03D12di0002"; + " Composition ..> Dependency : IDependency RootM03D13di0001
provides \"Dependency Key\" IDependency\n" + + " Composition ..> Service : IService RootM03D13di0002
provides \"Service Key\" IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IDependency), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IService), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IDependency), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IService), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -328,7 +336,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IDependency Resolve(Composition composition) { @@ -340,13 +348,13 @@ partial class Composition switch (tag) { case "Dependency Key": - return composition.RootM03D12di0001; + return composition.RootM03D13di0001; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IDependency."); } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IService Resolve(Composition composition) { @@ -358,7 +366,7 @@ partial class Composition switch (tag) { case "Service Key": - return composition.RootM03D12di0002; + return composition.RootM03D13di0002; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.BCL.KeyedServiceProviderScenario.IService."); } diff --git a/readme/lazy.md b/readme/lazy.md index e1d8c0bee..1b8dc0850 100644 --- a/readme/lazy.md +++ b/readme/lazy.md @@ -55,7 +55,7 @@ classDiagram <> } Service *-- LazyᐸIDependencyᐳ : LazyᐸIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService LazyᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ FuncᐸIDependencyᐳ *-- Dependency : IDependency ``` @@ -67,7 +67,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -75,7 +75,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.LazyScenario.IService>() ///
/// /// Provides a composition root of type . @@ -83,6 +83,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -90,23 +91,24 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -115,11 +117,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.LazyScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -127,20 +139,20 @@ partial class Composition #endif get { - var perResolveM03D12di37_Func = default(System.Func); - perResolveM03D12di37_Func = new global::System.Func( + var perResolveM03D13di37_Func = default(System.Func); + perResolveM03D13di37_Func = new global::System.Func( [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)768)] () => { - var factory_M03D12di1 = new Pure.DI.UsageTests.BCL.LazyScenario.Dependency(); - return factory_M03D12di1; + var factory_M03D13di1 = new Pure.DI.UsageTests.BCL.LazyScenario.Dependency(); + return factory_M03D13di1; }); - System.Lazy transientM03D12di1_Lazy; + System.Lazy transientM03D13di1_Lazy; { - var factory_M03D12di2 = perResolveM03D12di37_Func; - transientM03D12di1_Lazy = new global::System.Lazy(factory_M03D12di2, true); + var factory_M03D13di2 = perResolveM03D13di37_Func; + transientM03D13di1_Lazy = new global::System.Lazy(factory_M03D13di2, true); } - return new Pure.DI.UsageTests.BCL.LazyScenario.Service(transientM03D12di1_Lazy); + return new Pure.DI.UsageTests.BCL.LazyScenario.Service(transientM03D13di1_Lazy); } } #endregion @@ -156,7 +168,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -170,7 +182,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -183,10 +195,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -207,10 +219,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -252,31 +264,31 @@ partial class Composition " <>\n" + " }\n" + " Service *-- LazyᐸIDependencyᐳ : LazyᐸIDependencyᐳ\n" + - " Composition ..> Service : IService Root\n" + + " Composition ..> Service : IService Root
provides IService\n" + " LazyᐸIDependencyᐳ o-- \"PerResolve\" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ\n" + " FuncᐸIDependencyᐳ *-- Dependency : IDependency"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.LazyScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.LazyScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -289,7 +301,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.LazyScenario.IService Resolve(Composition composition) { diff --git a/readme/manually-started-tasks.md b/readme/manually-started-tasks.md index a5a0b29fb..6b26e219c 100644 --- a/readme/manually-started-tasks.md +++ b/readme/manually-started-tasks.md @@ -95,7 +95,7 @@ classDiagram TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions TaskFactory *-- TaskScheduler : TaskScheduler Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ - Composition ..> Service : IService GetRoot + Composition ..> Service : IService GetRoot(System.Threading.CancellationToken cancellationToken)
provides IService TaskᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ TaskᐸIDependencyᐳ o-- CancellationToken : Argument "cancellationToken" FuncᐸIDependencyᐳ *-- Dependency : IDependency @@ -108,7 +108,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -116,7 +116,7 @@ classDiagram /// /// /// -/// GetRoot +/// /// /// /// Provides a composition root of type . @@ -124,30 +124,32 @@ classDiagram /// /// ///
+///
/// -/// This shows how to get an instance of type using the composition root : +/// This shows how to get an instance of type using the composition root : /// -/// var composition = new Composition(cancellationToken); +/// var composition = new Composition(); /// var instance = composition.GetRoot(cancellationToken); /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; /// /// This parameterized constructor creates a new instance of with arguments. /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -156,31 +158,41 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.GetRoot(cancellationToken); + /// + /// #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif public Pure.DI.UsageTests.BCL.ManualTaskScenario.IService GetRoot(System.Threading.CancellationToken cancellationToken) { - var perResolveM03D12di39_Func = default(System.Func); - perResolveM03D12di39_Func = new global::System.Func( + var perResolveM03D13di39_Func = default(System.Func); + perResolveM03D13di39_Func = new global::System.Func( [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)768)] () => { - var factory_M03D12di1 = new Pure.DI.UsageTests.BCL.ManualTaskScenario.Dependency(); - return factory_M03D12di1; + var factory_M03D13di1 = new Pure.DI.UsageTests.BCL.ManualTaskScenario.Dependency(); + return factory_M03D13di1; }); - System.Threading.Tasks.Task transientM03D12di1_Task; + System.Threading.Tasks.Task transientM03D13di1_Task; { - var factory_M03D12di2 = perResolveM03D12di39_Func; - var cancellationToken_M03D12di3 = cancellationToken; - transientM03D12di1_Task = new Task(factory_M03D12di2, cancellationToken_M03D12di3); + var factory_M03D13di2 = perResolveM03D13di39_Func; + var cancellationToken_M03D13di3 = cancellationToken; + transientM03D13di1_Task = new Task(factory_M03D13di2, cancellationToken_M03D13di3); } - return new Pure.DI.UsageTests.BCL.ManualTaskScenario.Service(transientM03D12di1_Task); + return new Pure.DI.UsageTests.BCL.ManualTaskScenario.Service(transientM03D13di1_Task); } #endregion @@ -217,7 +229,7 @@ partial class Composition " TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions\n" + " TaskFactory *-- TaskScheduler : TaskScheduler\n" + " Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ\n" + - " Composition ..> Service : IService GetRoot\n" + + " Composition ..> Service : IService GetRoot(System.Threading.CancellationToken cancellationToken)
provides IService\n" + " TaskᐸIDependencyᐳ o-- \"PerResolve\" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ\n" + " TaskᐸIDependencyᐳ o-- CancellationToken : Argument \"cancellationToken\"\n" + " FuncᐸIDependencyᐳ *-- Dependency : IDependency"; diff --git a/readme/member-ordinal-attribute.md b/readme/member-ordinal-attribute.md index eb740e7b3..1a274cb4c 100644 --- a/readme/member-ordinal-attribute.md +++ b/readme/member-ordinal-attribute.md @@ -86,7 +86,7 @@ classDiagram Person o-- Int32 : Argument "personId" Person o-- String : Argument "personName" Person o-- DateTime : Argument "personBirthday" - PersonComposition ..> Person : IPerson Person + PersonComposition ..> Person : IPerson Person
provides IPerson ``` @@ -96,7 +96,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -104,7 +104,7 @@ classDiagram /// /// /// -/// Person +///
or using method: Resolve<Pure.DI.UsageTests.Attributes.MemberOrdinalAttributeScenario.IPerson>() ///
/// /// Provides a composition root of type . @@ -112,24 +112,26 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// -/// var composition = new PersonComposition(personId, personName, personBirthday); +/// var composition = new PersonComposition(_argM03D13di_personId, _argM03D13di_personName, _argM03D13di_personBirthday); /// var instance = composition.Person; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class PersonComposition { - private readonly PersonComposition _rootM03D12di; - private readonly int _argM03D12di_personId; - private readonly string _argM03D12di_personName; - private readonly System.DateTime _argM03D12di_personBirthday; + private readonly PersonComposition _rootM03D13di; + private readonly int _argM03D13di_personId; + private readonly string _argM03D13di_personName; + private readonly System.DateTime _argM03D13di_personBirthday; /// /// This parameterized constructor creates a new instance of with arguments. @@ -139,15 +141,15 @@ partial class PersonComposition /// The composition argument of type . public PersonComposition(int personId, string personName, System.DateTime personBirthday) { - _rootM03D12di = this; + _rootM03D13di = this; if (ReferenceEquals(personName, null)) { throw new global::System.ArgumentNullException("personName"); } - _argM03D12di_personId = personId; - _argM03D12di_personName = personName; - _argM03D12di_personBirthday = personBirthday; + _argM03D13di_personId = personId; + _argM03D13di_personName = personName; + _argM03D13di_personBirthday = personBirthday; } /// @@ -156,13 +158,23 @@ partial class PersonComposition /// Base composition. internal PersonComposition(PersonComposition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _argM03D12di_personId = baseComposition._argM03D12di_personId; - _argM03D12di_personName = baseComposition._argM03D12di_personName; - _argM03D12di_personBirthday = baseComposition._argM03D12di_personBirthday; + _rootM03D13di = baseComposition._rootM03D13di; + _argM03D13di_personId = baseComposition._argM03D13di_personId; + _argM03D13di_personName = baseComposition._argM03D13di_personName; + _argM03D13di_personBirthday = baseComposition._argM03D13di_personBirthday; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new PersonComposition(_argM03D13di_personId, _argM03D13di_personName, _argM03D13di_personBirthday); + /// var instance = composition.Person; + /// + /// public Pure.DI.UsageTests.Attributes.MemberOrdinalAttributeScenario.IPerson Person { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -170,11 +182,11 @@ partial class PersonComposition #endif get { - var transientM03D12di0_Person = new Pure.DI.UsageTests.Attributes.MemberOrdinalAttributeScenario.Person(); - transientM03D12di0_Person.Id = _argM03D12di_personId; - transientM03D12di0_Person.FirstName = _argM03D12di_personName; - transientM03D12di0_Person.Birthday = _argM03D12di_personBirthday; - return transientM03D12di0_Person; + var transientM03D13di0_Person = new Pure.DI.UsageTests.Attributes.MemberOrdinalAttributeScenario.Person(); + transientM03D13di0_Person.Id = _argM03D13di_personId; + transientM03D13di0_Person.FirstName = _argM03D13di_personName; + transientM03D13di0_Person.Birthday = _argM03D13di_personBirthday; + return transientM03D13di0_Person; } } #endregion @@ -190,7 +202,7 @@ partial class PersonComposition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -204,7 +216,7 @@ partial class PersonComposition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -217,10 +229,10 @@ partial class PersonComposition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -241,10 +253,10 @@ partial class PersonComposition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -285,29 +297,29 @@ partial class PersonComposition " Person o-- Int32 : Argument \"personId\"\n" + " Person o-- String : Argument \"personName\"\n" + " Person o-- DateTime : Argument \"personBirthday\"\n" + - " PersonComposition ..> Person : IPerson Person"; + " PersonComposition ..> Person : IPerson Person
provides IPerson"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static PersonComposition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Attributes.MemberOrdinalAttributeScenario.IPerson), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Attributes.MemberOrdinalAttributeScenario.IPerson), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(PersonComposition composite) { @@ -320,7 +332,7 @@ partial class PersonComposition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Attributes.MemberOrdinalAttributeScenario.IPerson Resolve(PersonComposition composition) { diff --git a/readme/method-injection.md b/readme/method-injection.md index eb2953689..3e779fb55 100644 --- a/readme/method-injection.md +++ b/readme/method-injection.md @@ -60,7 +60,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -70,7 +70,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -78,7 +78,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.MethodInjectionScenario.IService>() ///
/// /// Provides a composition root of type . @@ -86,6 +86,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -93,21 +94,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -116,10 +118,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.MethodInjectionScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -127,9 +139,9 @@ partial class Composition #endif get { - var transientM03D12di0_Service = new Pure.DI.UsageTests.Basics.MethodInjectionScenario.Service(); - transientM03D12di0_Service.SetDependency(new Pure.DI.UsageTests.Basics.MethodInjectionScenario.Dependency()); - return transientM03D12di0_Service; + var transientM03D13di0_Service = new Pure.DI.UsageTests.Basics.MethodInjectionScenario.Service(); + transientM03D13di0_Service.SetDependency(new Pure.DI.UsageTests.Basics.MethodInjectionScenario.Dependency()); + return transientM03D13di0_Service; } } #endregion @@ -145,7 +157,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -159,7 +171,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -172,10 +184,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -196,10 +208,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -240,29 +252,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.MethodInjectionScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.MethodInjectionScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -275,7 +287,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.MethodInjectionScenario.IService Resolve(Composition composition) { diff --git a/readme/multi-contract-bindings.md b/readme/multi-contract-bindings.md index a9f2a6316..72ba06913 100644 --- a/readme/multi-contract-bindings.md +++ b/readme/multi-contract-bindings.md @@ -60,7 +60,7 @@ classDiagram } Service *-- Dependency : IDependency Service *-- Dependency : IAdvancedDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -70,7 +70,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -78,7 +78,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.MultiContractBindingsScenario.IService>() ///
/// /// Provides a composition root of type . @@ -86,6 +86,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -93,21 +94,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -116,10 +118,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.MultiContractBindingsScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -143,7 +155,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -157,7 +169,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -170,10 +182,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -194,10 +206,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -242,29 +254,29 @@ partial class Composition " }\n" + " Service *-- Dependency : IDependency\n" + " Service *-- Dependency : IAdvancedDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.MultiContractBindingsScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.MultiContractBindingsScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -277,7 +289,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.MultiContractBindingsScenario.IService Resolve(Composition composition) { diff --git a/readme/oncannotresolve-hint.md b/readme/oncannotresolve-hint.md index 17172455c..a82f77b8b 100644 --- a/readme/oncannotresolve-hint.md +++ b/readme/oncannotresolve-hint.md @@ -85,7 +85,7 @@ classDiagram } Dependency *-- String : String Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -95,7 +95,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -103,7 +103,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Hints.OnCannotResolveHintScenario.IService>() ///
/// /// Provides a composition root of type . @@ -111,6 +111,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -118,21 +119,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -141,10 +143,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Hints.OnCannotResolveHintScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -152,8 +164,8 @@ partial class Composition #endif get { - var transientM03D12di2_String = OnCannotResolve(null, Pure.DI.Lifetime.Transient); - return new Pure.DI.UsageTests.Hints.OnCannotResolveHintScenario.Service(new Pure.DI.UsageTests.Hints.OnCannotResolveHintScenario.Dependency(transientM03D12di2_String)); + var transientM03D13di2_String = OnCannotResolve(null, Pure.DI.Lifetime.Transient); + return new Pure.DI.UsageTests.Hints.OnCannotResolveHintScenario.Service(new Pure.DI.UsageTests.Hints.OnCannotResolveHintScenario.Dependency(transientM03D13di2_String)); } } #endregion @@ -169,7 +181,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -183,7 +195,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -196,10 +208,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -220,10 +232,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -267,29 +279,29 @@ partial class Composition " }\n" + " Dependency *-- String : String\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.OnCannotResolveHintScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.OnCannotResolveHintScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -302,7 +314,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Hints.OnCannotResolveHintScenario.IService Resolve(Composition composition) { diff --git a/readme/ondependencyinjection-hint.md b/readme/ondependencyinjection-hint.md index c0d370e76..31f66d069 100644 --- a/readme/ondependencyinjection-hint.md +++ b/readme/ondependencyinjection-hint.md @@ -82,7 +82,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -92,7 +92,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -100,7 +100,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Hints.OnDependencyInjectionHintScenario.IService>() ///
/// /// Provides a composition root of type . @@ -108,6 +108,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -115,21 +116,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -138,10 +140,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Hints.OnDependencyInjectionHintScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -165,7 +177,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -179,7 +191,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -192,10 +204,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -216,10 +228,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -261,29 +273,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.OnDependencyInjectionHintScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.OnDependencyInjectionHintScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -296,7 +308,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Hints.OnDependencyInjectionHintScenario.IService Resolve(Composition composition) { diff --git a/readme/onnewinstance-hint.md b/readme/onnewinstance-hint.md index 5cdbccc05..7f3c72f3c 100644 --- a/readme/onnewinstance-hint.md +++ b/readme/onnewinstance-hint.md @@ -84,7 +84,7 @@ classDiagram <> } Service o-- "Singleton" Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -94,7 +94,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -102,7 +102,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.IService>() ///
/// /// Provides a composition root of type . @@ -110,6 +110,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -117,24 +118,25 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.Dependency _singletonM03D12di34_Dependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.Dependency _singletonM03D13di34_Dependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -143,11 +145,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -155,24 +167,24 @@ partial class Composition #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.Dependency _singletonM03D12di34_DependencyTemp; - _singletonM03D12di34_DependencyTemp = new Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.Dependency(); - OnNewInstance(ref _singletonM03D12di34_DependencyTemp, null, Pure.DI.Lifetime.Singleton); + Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.Dependency _singletonM03D13di34_DependencyTemp; + _singletonM03D13di34_DependencyTemp = new Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.Dependency(); + OnNewInstance(ref _singletonM03D13di34_DependencyTemp, null, Pure.DI.Lifetime.Singleton); global::System.Threading.Thread.MemoryBarrier(); - _singletonM03D12di34_Dependency = _singletonM03D12di34_DependencyTemp; - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = _singletonM03D13di34_DependencyTemp; + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } } } - var transientM03D12di0_Service = new Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.Service(_rootM03D12di._singletonM03D12di34_Dependency); - OnNewInstance(ref transientM03D12di0_Service, null, Pure.DI.Lifetime.Transient); - return transientM03D12di0_Service; + var transientM03D13di0_Service = new Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.Service(_rootM03D13di._singletonM03D13di34_Dependency); + OnNewInstance(ref transientM03D13di0_Service, null, Pure.DI.Lifetime.Transient); + return transientM03D13di0_Service; } } #endregion @@ -188,7 +200,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -202,7 +214,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -215,10 +227,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -239,10 +251,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -284,29 +296,29 @@ partial class Composition " <>\n" + " }\n" + " Service o-- \"Singleton\" Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -319,7 +331,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Hints.OnNewInstanceHintScenario.IService Resolve(Composition composition) { diff --git a/readme/overriding-the-bcl-binding.md b/readme/overriding-the-bcl-binding.md index c78680338..a60e0a778 100644 --- a/readme/overriding-the-bcl-binding.md +++ b/readme/overriding-the-bcl-binding.md @@ -59,7 +59,7 @@ classDiagram <> } Service *-- ArrayᐸIDependencyᐳ : ArrayᐸIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -69,7 +69,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -77,7 +77,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.OverridingBclBindingScenario.IService>() ///
/// /// Provides a composition root of type . @@ -85,6 +85,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -92,21 +93,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -115,10 +117,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.OverridingBclBindingScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -126,13 +138,13 @@ partial class Composition #endif get { - Pure.DI.UsageTests.BCL.OverridingBclBindingScenario.IDependency[] transientM03D12di1_ = new IDependency[] + Pure.DI.UsageTests.BCL.OverridingBclBindingScenario.IDependency[] transientM03D13di1_ = new IDependency[] { new AbcDependency(), new XyzDependency(), new AbcDependency() }; - return new Pure.DI.UsageTests.BCL.OverridingBclBindingScenario.Service(transientM03D12di1_); + return new Pure.DI.UsageTests.BCL.OverridingBclBindingScenario.Service(transientM03D13di1_); } } #endregion @@ -148,7 +160,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -162,7 +174,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -175,10 +187,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -199,10 +211,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -236,29 +248,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- ArrayᐸIDependencyᐳ : ArrayᐸIDependencyᐳ\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.OverridingBclBindingScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.OverridingBclBindingScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -271,7 +283,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.OverridingBclBindingScenario.IService Resolve(Composition composition) { diff --git a/readme/partial-class.md b/readme/partial-class.md index cd5633864..7df9eebce 100644 --- a/readme/partial-class.md +++ b/readme/partial-class.md @@ -93,7 +93,7 @@ classDiagram Service *-- Dependency : IDependency Service *-- Dependency : IDependency Dependency *-- Int64 : Int64 - Composition ..> Service : Service Root + Composition ..> Service : Service Root
provides Service ``` @@ -103,7 +103,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -111,7 +111,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.PartialClassScenario.Service>() ///
/// /// Provides a composition root of type . @@ -119,6 +119,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -126,21 +127,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -149,10 +151,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// internal Pure.DI.UsageTests.Basics.PartialClassScenario.Service Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -160,10 +172,10 @@ partial class Composition #endif get { - long transientM03D12di5_Int64 = GenerateId(); - long transientM03D12di4_Int64 = GenerateId(); - string transientM03D12di1_String = $"{_serviceName}_{GenerateId()}"; - return new Pure.DI.UsageTests.Basics.PartialClassScenario.Service(transientM03D12di1_String, new Pure.DI.UsageTests.Basics.PartialClassScenario.Dependency(transientM03D12di5_Int64), new Pure.DI.UsageTests.Basics.PartialClassScenario.Dependency(transientM03D12di4_Int64)); + long transientM03D13di5_Int64 = GenerateId(); + long transientM03D13di4_Int64 = GenerateId(); + string transientM03D13di1_String = $"{_serviceName}_{GenerateId()}"; + return new Pure.DI.UsageTests.Basics.PartialClassScenario.Service(transientM03D13di1_String, new Pure.DI.UsageTests.Basics.PartialClassScenario.Dependency(transientM03D13di5_Int64), new Pure.DI.UsageTests.Basics.PartialClassScenario.Dependency(transientM03D13di4_Int64)); } } #endregion @@ -179,7 +191,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -193,7 +205,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -206,10 +218,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -230,10 +242,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -274,29 +286,29 @@ partial class Composition " Service *-- Dependency : IDependency\n" + " Service *-- Dependency : IDependency\n" + " Dependency *-- Int64 : Int64\n" + - " Composition ..> Service : Service Root"; + " Composition ..> Service : Service Root
provides Service"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.PartialClassScenario.Service), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.PartialClassScenario.Service), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -309,7 +321,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.PartialClassScenario.Service Resolve(Composition composition) { diff --git a/readme/perblock.md b/readme/perblock.md index 5594d8a0c..53e4f6ee3 100644 --- a/readme/perblock.md +++ b/readme/perblock.md @@ -70,7 +70,7 @@ classDiagram Service o-- "PerBlock" Dependency : IDependency Service o-- "PerBlock" Dependency : IDependency Service *-- LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ - Composition ..> Service : Service Root + Composition ..> Service : Service Root
provides Service LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ o-- "PerResolve" FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ *-- ValueTupleᐸIDependencyˏIDependencyᐳ : ValueTupleᐸIDependencyˏIDependencyᐳ ``` @@ -82,7 +82,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -90,7 +90,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Service>() ///
/// /// Provides a composition root of type . @@ -98,6 +98,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -105,23 +106,24 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -130,11 +132,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Service Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -142,22 +154,22 @@ partial class Composition #endif get { - var perResolveM03D12di40_Func = default(System.Func<(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep4)>); - perResolveM03D12di40_Func = new global::System.Func<(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep4)>( + var perResolveM03D13di40_Func = default(System.Func<(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep4)>); + perResolveM03D13di40_Func = new global::System.Func<(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep4)>( [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)768)] () => { - var perBlockM03D12di4_Dependency = new Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Dependency(); - var factory_M03D12di1 = (perBlockM03D12di4_Dependency, perBlockM03D12di4_Dependency); - return factory_M03D12di1; + var perBlockM03D13di4_Dependency = new Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Dependency(); + var factory_M03D13di1 = (perBlockM03D13di4_Dependency, perBlockM03D13di4_Dependency); + return factory_M03D13di1; }); - System.Lazy<(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep4)> transientM03D12di2_Lazy; + System.Lazy<(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep4)> transientM03D13di2_Lazy; { - var factory_M03D12di2 = perResolveM03D12di40_Func; - transientM03D12di2_Lazy = new global::System.Lazy<(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep4)>(factory_M03D12di2, true); + var factory_M03D13di2 = perResolveM03D13di40_Func; + transientM03D13di2_Lazy = new global::System.Lazy<(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerBlockScenario.IDependency dep4)>(factory_M03D13di2, true); } - var perBlockM03D12di1_Dependency = new Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Dependency(); - return new Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Service(perBlockM03D12di1_Dependency, perBlockM03D12di1_Dependency, transientM03D12di2_Lazy); + var perBlockM03D13di1_Dependency = new Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Dependency(); + return new Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Service(perBlockM03D13di1_Dependency, perBlockM03D13di1_Dependency, transientM03D13di2_Lazy); } } #endregion @@ -173,7 +185,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -187,7 +199,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -200,10 +212,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -224,10 +236,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -272,31 +284,31 @@ partial class Composition " Service o-- \"PerBlock\" Dependency : IDependency\n" + " Service o-- \"PerBlock\" Dependency : IDependency\n" + " Service *-- LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ\n" + - " Composition ..> Service : Service Root\n" + + " Composition ..> Service : Service Root
provides Service\n" + " LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ o-- \"PerResolve\" FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ\n" + " FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ *-- ValueTupleᐸIDependencyˏIDependencyᐳ : ValueTupleᐸIDependencyˏIDependencyᐳ"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Service), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Service), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -309,7 +321,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.PerBlockScenario.Service Resolve(Composition composition) { diff --git a/readme/perresolve.md b/readme/perresolve.md index db81eb7b1..94b422f3b 100644 --- a/readme/perresolve.md +++ b/readme/perresolve.md @@ -70,7 +70,7 @@ classDiagram Service o-- "PerResolve" Dependency : IDependency Service o-- "PerResolve" Dependency : IDependency Service *-- LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ - Composition ..> Service : Service Root + Composition ..> Service : Service Root
provides Service LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ o-- "PerResolve" FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ *-- ValueTupleᐸIDependencyˏIDependencyᐳ : ValueTupleᐸIDependencyˏIDependencyᐳ ``` @@ -82,7 +82,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -90,7 +90,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Service>() ///
/// /// Provides a composition root of type . @@ -98,6 +98,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -105,23 +106,24 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -130,11 +132,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Service Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -142,41 +154,41 @@ partial class Composition #endif get { - var perResolveM03D12di34_Dependency = default(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Dependency); - var perResolveM03D12di40_Func = default(System.Func<(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep4)>); - perResolveM03D12di40_Func = new global::System.Func<(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep4)>( + var perResolveM03D13di34_Dependency = default(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Dependency); + var perResolveM03D13di40_Func = default(System.Func<(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep4)>); + perResolveM03D13di40_Func = new global::System.Func<(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep4)>( [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)768)] () => { - if (ReferenceEquals(perResolveM03D12di34_Dependency, null)) + if (ReferenceEquals(perResolveM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(perResolveM03D12di34_Dependency, null)) + if (ReferenceEquals(perResolveM03D13di34_Dependency, null)) { - perResolveM03D12di34_Dependency = new Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Dependency(); + perResolveM03D13di34_Dependency = new Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Dependency(); } } } - var factory_M03D12di1 = (perResolveM03D12di34_Dependency, perResolveM03D12di34_Dependency); - return factory_M03D12di1; + var factory_M03D13di1 = (perResolveM03D13di34_Dependency, perResolveM03D13di34_Dependency); + return factory_M03D13di1; }); - System.Lazy<(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep4)> transientM03D12di1_Lazy; + System.Lazy<(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep4)> transientM03D13di1_Lazy; { - var factory_M03D12di2 = perResolveM03D12di40_Func; - transientM03D12di1_Lazy = new global::System.Lazy<(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep4)>(factory_M03D12di2, true); + var factory_M03D13di2 = perResolveM03D13di40_Func; + transientM03D13di1_Lazy = new global::System.Lazy<(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep3, Pure.DI.UsageTests.Lifetimes.PerResolveScenario.IDependency dep4)>(factory_M03D13di2, true); } - if (ReferenceEquals(perResolveM03D12di34_Dependency, null)) + if (ReferenceEquals(perResolveM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(perResolveM03D12di34_Dependency, null)) + if (ReferenceEquals(perResolveM03D13di34_Dependency, null)) { - perResolveM03D12di34_Dependency = new Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Dependency(); + perResolveM03D13di34_Dependency = new Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Dependency(); } } } - return new Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Service(perResolveM03D12di34_Dependency, perResolveM03D12di34_Dependency, transientM03D12di1_Lazy); + return new Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Service(perResolveM03D13di34_Dependency, perResolveM03D13di34_Dependency, transientM03D13di1_Lazy); } } #endregion @@ -192,7 +204,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -206,7 +218,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -219,10 +231,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -243,10 +255,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -291,31 +303,31 @@ partial class Composition " Service o-- \"PerResolve\" Dependency : IDependency\n" + " Service o-- \"PerResolve\" Dependency : IDependency\n" + " Service *-- LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ\n" + - " Composition ..> Service : Service Root\n" + + " Composition ..> Service : Service Root
provides Service\n" + " LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ o-- \"PerResolve\" FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ\n" + " FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ *-- ValueTupleᐸIDependencyˏIDependencyᐳ : ValueTupleᐸIDependencyˏIDependencyᐳ"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Service), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Service), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -328,7 +340,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.PerResolveScenario.Service Resolve(Composition composition) { diff --git a/readme/property-injection.md b/readme/property-injection.md index f423223e9..17f1b0e53 100644 --- a/readme/property-injection.md +++ b/readme/property-injection.md @@ -57,7 +57,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -67,7 +67,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -75,7 +75,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.PropertyInjectionScenario.IService>() ///
/// /// Provides a composition root of type . @@ -83,6 +83,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -90,21 +91,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -113,10 +115,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.PropertyInjectionScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -124,9 +136,9 @@ partial class Composition #endif get { - var transientM03D12di0_Service = new Pure.DI.UsageTests.Basics.PropertyInjectionScenario.Service(); - transientM03D12di0_Service.Dependency = new Pure.DI.UsageTests.Basics.PropertyInjectionScenario.Dependency(); - return transientM03D12di0_Service; + var transientM03D13di0_Service = new Pure.DI.UsageTests.Basics.PropertyInjectionScenario.Service(); + transientM03D13di0_Service.Dependency = new Pure.DI.UsageTests.Basics.PropertyInjectionScenario.Dependency(); + return transientM03D13di0_Service; } } #endregion @@ -142,7 +154,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -156,7 +168,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -169,10 +181,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -193,10 +205,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -237,29 +249,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.PropertyInjectionScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.PropertyInjectionScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -272,7 +284,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.PropertyInjectionScenario.IService Resolve(Composition composition) { diff --git a/readme/required-properties-or-fields.md b/readme/required-properties-or-fields.md index 4917d7cad..e1db17f08 100644 --- a/readme/required-properties-or-fields.md +++ b/readme/required-properties-or-fields.md @@ -67,7 +67,7 @@ classDiagram } Service o-- String : Argument "name" Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -77,7 +77,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -85,7 +85,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.RequiredPropertiesOrFieldsScenario.IService>() ///
/// /// Provides a composition root of type . @@ -93,22 +93,24 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// -/// var composition = new Composition(name); +/// var composition = new Composition(_argM03D13di_name); /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly string _argM03D12di_name; + private readonly Composition _rootM03D13di; + private readonly string _argM03D13di_name; /// /// This parameterized constructor creates a new instance of with arguments. @@ -116,13 +118,13 @@ partial class Composition /// The composition argument of type . public Composition(string name) { - _rootM03D12di = this; + _rootM03D13di = this; if (ReferenceEquals(name, null)) { throw new global::System.ArgumentNullException("name"); } - _argM03D12di_name = name; + _argM03D13di_name = name; } /// @@ -131,11 +133,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _argM03D12di_name = baseComposition._argM03D12di_name; + _rootM03D13di = baseComposition._rootM03D13di; + _argM03D13di_name = baseComposition._argM03D13di_name; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(_argM03D13di_name); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.RequiredPropertiesOrFieldsScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -145,7 +157,7 @@ partial class Composition { return new Pure.DI.UsageTests.Basics.RequiredPropertiesOrFieldsScenario.Service() { - ServiceNameField = _argM03D12di_name, + ServiceNameField = _argM03D13di_name, Dependency = new Pure.DI.UsageTests.Basics.RequiredPropertiesOrFieldsScenario.Dependency() }; } @@ -163,7 +175,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -177,7 +189,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -190,10 +202,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -214,10 +226,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -261,29 +273,29 @@ partial class Composition " }\n" + " Service o-- String : Argument \"name\"\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.RequiredPropertiesOrFieldsScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.RequiredPropertiesOrFieldsScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -296,7 +308,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.RequiredPropertiesOrFieldsScenario.IService Resolve(Composition composition) { diff --git a/readme/resolve-hint.md b/readme/resolve-hint.md index 8458d6232..7f55b0413 100644 --- a/readme/resolve-hint.md +++ b/readme/resolve-hint.md @@ -52,8 +52,8 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Dependency : IDependency DependencyRoot - Composition ..> Service : IService Root + Composition ..> Dependency : IDependency DependencyRoot
provides IDependency + Composition ..> Service : IService Root
provides IService ``` @@ -63,7 +63,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -71,7 +71,7 @@ classDiagram /// /// /// -/// DependencyRoot +///
or using method: Resolve<Pure.DI.UsageTests.Hints.ResolveHintScenario.IDependency>() ///
/// /// Provides a composition root of type . @@ -79,7 +79,7 @@ classDiagram ///
/// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Hints.ResolveHintScenario.IService>() ///
/// /// Provides a composition root of type . @@ -87,6 +87,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -94,21 +95,22 @@ classDiagram /// var instance = composition.DependencyRoot; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -117,10 +119,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.DependencyRoot; + /// + /// public Pure.DI.UsageTests.Hints.ResolveHintScenario.IDependency DependencyRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -132,6 +144,16 @@ partial class Composition } } + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Hints.ResolveHintScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -170,8 +192,8 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Dependency : IDependency DependencyRoot\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Dependency : IDependency DependencyRoot
provides IDependency\n" + + " Composition ..> Service : IService Root
provides IService"; } } ``` diff --git a/readme/resolve-methods.md b/readme/resolve-methods.md index a6dbf0731..ccf362ea0 100644 --- a/readme/resolve-methods.md +++ b/readme/resolve-methods.md @@ -47,7 +47,7 @@ classDiagram class Composition { +IDependency DependencySingleton +IService OtherService - -IService RootM03D12di0002 + -IService RootM03D13di0002 + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -72,9 +72,9 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Dependency : IDependency DependencySingleton - Composition ..> Service : IService RootM03D12di0002 - Composition ..> OtherService : "Other" IService OtherService + Composition ..> Dependency : IDependency DependencySingleton
provides IDependency + Composition ..> Service : IService RootM03D13di0002
provides IService + Composition ..> OtherService : IService OtherService
provides "Other" IService ``` @@ -84,7 +84,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -92,7 +92,7 @@ classDiagram /// /// /// -/// DependencySingleton +///
or using method: Resolve<Pure.DI.UsageTests.Basics.ResolveScenario.IDependency>() ///
/// /// Specifies to create a regular public composition root
@@ -101,7 +101,7 @@ classDiagram ///
/// /// -/// OtherService +///
or using method: Resolve<Pure.DI.UsageTests.Basics.ResolveScenario.IService>("Other") ///
/// /// Specifies to create a public root named _OtherService_
@@ -110,7 +110,7 @@ classDiagram ///
/// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.Basics.ResolveScenario.IService>() ///
/// /// Specifies to create a private root
@@ -119,6 +119,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -126,21 +127,22 @@ classDiagram /// var instance = composition.DependencySingleton; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -149,7 +151,7 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots @@ -157,6 +159,13 @@ partial class Composition /// Specifies to create a regular public composition root
/// of type "IDependency" with the name "DependencySingleton" ///
+ /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.DependencySingleton; + /// + /// public Pure.DI.UsageTests.Basics.ResolveScenario.IDependency DependencySingleton { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -172,6 +181,13 @@ partial class Composition /// Specifies to create a public root named _OtherService_
/// using the _Other_ tag ///
+ /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.OtherService; + /// + /// public Pure.DI.UsageTests.Basics.ResolveScenario.IService OtherService { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -187,7 +203,7 @@ partial class Composition /// Specifies to create a private root
/// that is only accessible from _Resolve_ methods ///
- public Pure.DI.UsageTests.Basics.ResolveScenario.IService RootM03D12di0002 + public Pure.DI.UsageTests.Basics.ResolveScenario.IService RootM03D13di0002 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] @@ -210,7 +226,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -224,7 +240,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -237,10 +253,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -261,10 +277,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -285,7 +301,7 @@ partial class Composition " class Composition {\n" + " +IDependency DependencySingleton\n" + " +IService OtherService\n" + - " -IService RootM03D12di0002\n" + + " -IService RootM03D13di0002\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -310,34 +326,34 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Dependency : IDependency DependencySingleton\n" + - " Composition ..> Service : IService RootM03D12di0002\n" + - " Composition ..> OtherService : \"Other\" IService OtherService"; + " Composition ..> Dependency : IDependency DependencySingleton
provides IDependency\n" + + " Composition ..> Service : IService RootM03D13di0002
provides IService\n" + + " Composition ..> OtherService : IService OtherService
provides \"Other\" IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.ResolveScenario.IDependency), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.ResolveScenario.IService), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.ResolveScenario.IDependency), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.ResolveScenario.IService), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -350,7 +366,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.ResolveScenario.IDependency Resolve(Composition composition) { @@ -368,11 +384,11 @@ partial class Composition } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.ResolveScenario.IService Resolve(Composition composition) { - return composition.RootM03D12di0002; + return composition.RootM03D13di0002; } public Pure.DI.UsageTests.Basics.ResolveScenario.IService ResolveByTag(Composition composition, object tag) @@ -382,7 +398,7 @@ partial class Composition case "Other": return composition.OtherService; case null: - return composition.RootM03D12di0002; + return composition.RootM03D13di0002; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.Basics.ResolveScenario.IService."); } diff --git a/readme/root-arguments.md b/readme/root-arguments.md index 1647fbc33..ae3126714 100644 --- a/readme/root-arguments.md +++ b/readme/root-arguments.md @@ -87,7 +87,7 @@ classDiagram Dependency o-- String : Argument "dependencyName" Service o-- String : "forService" Argument "serviceName" Service *-- Dependency : IDependency - Composition ..> Service : IService CreateService + Composition ..> Service : IService CreateService(int id, string dependencyName, string serviceName)
provides IService ``` @@ -97,7 +97,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -105,7 +105,7 @@ classDiagram /// /// /// -/// CreateService +/// /// /// /// Provides a composition root of type . @@ -113,28 +113,30 @@ classDiagram /// /// ///
+///
/// -/// This shows how to get an instance of type using the composition root : +/// This shows how to get an instance of type using the composition root : /// -/// var composition = new Composition(id, dependencyName, serviceName); +/// var composition = new Composition(); /// var instance = composition.CreateService(id, dependencyName, serviceName); /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This parameterized constructor creates a new instance of with arguments. /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -143,10 +145,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.CreateService(id, dependencyName, serviceName); + /// + /// #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif @@ -186,7 +198,7 @@ partial class Composition " Dependency o-- String : Argument \"dependencyName\"\n" + " Service o-- String : \"forService\" Argument \"serviceName\"\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService CreateService"; + " Composition ..> Service : IService CreateService(int id, string dependencyName, string serviceName)
provides IService"; } } ``` diff --git a/readme/scope.md b/readme/scope.md index e23be8b8d..1bbb163bb 100644 --- a/readme/scope.md +++ b/readme/scope.md @@ -115,8 +115,8 @@ classDiagram Session *-- Composition : Composition Program o-- "PerResolve" FuncᐸSessionᐳ : FuncᐸSessionᐳ Service o-- "Scoped" Dependency : IDependency - Composition ..> Service : IService SessionRoot - Composition ..> Program : Program ProgramRoot + Composition ..> Service : IService SessionRoot
provides IService + Composition ..> Program : Program ProgramRoot
provides Program FuncᐸSessionᐳ *-- Session : Session ``` @@ -127,7 +127,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -135,7 +135,7 @@ classDiagram /// /// /// -/// ProgramRoot +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.ScopeScenario.Program>() ///
/// /// Program composition root @@ -143,7 +143,7 @@ classDiagram ///
/// /// -/// SessionRoot +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.ScopeScenario.IService>() ///
/// /// Session composition root @@ -151,6 +151,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -158,27 +159,28 @@ classDiagram /// var instance = composition.ProgramRoot; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition: global::System.IDisposable { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private readonly global::System.IDisposable[] _disposablesM03D12di; - private int _disposeIndexM03D12di; - private Pure.DI.UsageTests.Lifetimes.ScopeScenario.Dependency _scopedM03D12di34_Dependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private readonly global::System.IDisposable[] _disposablesM03D13di; + private int _disposeIndexM03D13di; + private Pure.DI.UsageTests.Lifetimes.ScopeScenario.Dependency _scopedM03D13di34_Dependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); - _disposablesM03D12di = new global::System.IDisposable[1]; + _rootM03D13di = this; + _lockM03D13di = new object(); + _disposablesM03D13di = new global::System.IDisposable[1]; } /// @@ -187,15 +189,22 @@ partial class Composition: global::System.IDisposable /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; - _disposablesM03D12di = new global::System.IDisposable[1]; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; + _disposablesM03D13di = new global::System.IDisposable[1]; } #region Composition Roots /// /// Session composition root /// + /// + /// This shows how to get an instance of type : + /// + /// using var composition = new Composition(); + /// var instance = composition.SessionRoot; + /// + /// public Pure.DI.UsageTests.Lifetimes.ScopeScenario.IService SessionRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -203,24 +212,31 @@ partial class Composition: global::System.IDisposable #endif get { - if (ReferenceEquals(_scopedM03D12di34_Dependency, null)) + if (ReferenceEquals(_scopedM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_scopedM03D12di34_Dependency, null)) + if (ReferenceEquals(_scopedM03D13di34_Dependency, null)) { - _scopedM03D12di34_Dependency = new Pure.DI.UsageTests.Lifetimes.ScopeScenario.Dependency(); - _disposablesM03D12di[_disposeIndexM03D12di++] = _scopedM03D12di34_Dependency; + _scopedM03D13di34_Dependency = new Pure.DI.UsageTests.Lifetimes.ScopeScenario.Dependency(); + _disposablesM03D13di[_disposeIndexM03D13di++] = _scopedM03D13di34_Dependency; } } } - return new Pure.DI.UsageTests.Lifetimes.ScopeScenario.Service(_scopedM03D12di34_Dependency); + return new Pure.DI.UsageTests.Lifetimes.ScopeScenario.Service(_scopedM03D13di34_Dependency); } } /// /// Program composition root /// + /// + /// This shows how to get an instance of type : + /// + /// using var composition = new Composition(); + /// var instance = composition.ProgramRoot; + /// + /// public Pure.DI.UsageTests.Lifetimes.ScopeScenario.Program ProgramRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -228,16 +244,16 @@ partial class Composition: global::System.IDisposable #endif get { - var perResolveM03D12di40_Func = default(System.Func); - perResolveM03D12di40_Func = new global::System.Func( + var perResolveM03D13di40_Func = default(System.Func); + perResolveM03D13di40_Func = new global::System.Func( [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)768)] () => { - var transientM03D12di2_Composition = this; - var factory_M03D12di1 = new Pure.DI.UsageTests.Lifetimes.ScopeScenario.Session(transientM03D12di2_Composition); - return factory_M03D12di1; + var transientM03D13di2_Composition = this; + var factory_M03D13di1 = new Pure.DI.UsageTests.Lifetimes.ScopeScenario.Session(transientM03D13di2_Composition); + return factory_M03D13di1; }); - return new Pure.DI.UsageTests.Lifetimes.ScopeScenario.Program(perResolveM03D12di40_Func); + return new Pure.DI.UsageTests.Lifetimes.ScopeScenario.Program(perResolveM03D13di40_Func); } } #endregion @@ -253,7 +269,7 @@ partial class Composition: global::System.IDisposable #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -267,7 +283,7 @@ partial class Composition: global::System.IDisposable #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -280,10 +296,10 @@ partial class Composition: global::System.IDisposable #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -304,10 +320,10 @@ partial class Composition: global::System.IDisposable #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -324,11 +340,11 @@ partial class Composition: global::System.IDisposable /// public void Dispose() { - lock (_lockM03D12di) + lock (_lockM03D13di) { - while (_disposeIndexM03D12di > 0) + while (_disposeIndexM03D13di > 0) { - var disposableInstance = _disposablesM03D12di[--_disposeIndexM03D12di]; + var disposableInstance = _disposablesM03D13di[--_disposeIndexM03D13di]; try { disposableInstance.Dispose(); @@ -339,7 +355,7 @@ partial class Composition: global::System.IDisposable } } - _scopedM03D12di34_Dependency = null; + _scopedM03D13di34_Dependency = null; } } @@ -386,34 +402,34 @@ partial class Composition: global::System.IDisposable " Session *-- Composition : Composition\n" + " Program o-- \"PerResolve\" FuncᐸSessionᐳ : FuncᐸSessionᐳ\n" + " Service o-- \"Scoped\" Dependency : IDependency\n" + - " Composition ..> Service : IService SessionRoot\n" + - " Composition ..> Program : Program ProgramRoot\n" + + " Composition ..> Service : IService SessionRoot
provides IService\n" + + " Composition ..> Program : Program ProgramRoot
provides Program\n" + " FuncᐸSessionᐳ *-- Session : Session"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.ScopeScenario.IService), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.ScopeScenario.Program), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.ScopeScenario.IService), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.ScopeScenario.Program), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -426,7 +442,7 @@ partial class Composition: global::System.IDisposable } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.ScopeScenario.IService Resolve(Composition composition) { @@ -444,7 +460,7 @@ partial class Composition: global::System.IDisposable } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.ScopeScenario.Program Resolve(Composition composition) { diff --git a/readme/service-collection.md b/readme/service-collection.md index 2456a0071..5916720cd 100644 --- a/readme/service-collection.md +++ b/readme/service-collection.md @@ -47,8 +47,8 @@ service.Dependency.ShouldBe(dependency); ```mermaid classDiagram class Composition { - -IDependency RootM03D12di0001 - -IService RootM03D12di0002 + -IDependency RootM03D13di0001 + -IService RootM03D13di0002 + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object Resolve(Type type) @@ -69,8 +69,8 @@ classDiagram <> } Service o-- "Singleton" Dependency : "Dependency Key" IDependency - Composition ..> Dependency : "Dependency Key" IDependency RootM03D12di0001 - Composition ..> Service : IService RootM03D12di0002 + Composition ..> Dependency : IDependency RootM03D13di0001
provides "Dependency Key" IDependency + Composition ..> Service : IService RootM03D13di0002
provides IService ``` @@ -80,7 +80,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -88,7 +88,7 @@ classDiagram /// /// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IDependency>("Dependency Key") ///
/// /// Provides a composition root of type . @@ -96,7 +96,7 @@ classDiagram ///
/// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IService>() ///
/// /// Provides a composition root of type . @@ -104,24 +104,26 @@ classDiagram ///
///
///
-/// Class diagram
-/// This class was created by Pure.DI source code generator. ///
+/// Class diagram
+/// This class was created by Pure.DI source code generator. /// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.BCL.ServiceCollectionScenario.Dependency _singletonM03D12di34_Dependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.BCL.ServiceCollectionScenario.Dependency _singletonM03D13di34_Dependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -130,52 +132,58 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots - public Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IDependency RootM03D12di0001 + /// + /// Provides a composition root of type . + /// + public Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IDependency RootM03D13di0001 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceCollectionScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceCollectionScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } } } - return _rootM03D12di._singletonM03D12di34_Dependency; + return _rootM03D13di._singletonM03D13di34_Dependency; } } - public Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IService RootM03D12di0002 + /// + /// Provides a composition root of type . + /// + public Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IService RootM03D13di0002 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceCollectionScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceCollectionScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } } } - return new Pure.DI.UsageTests.BCL.ServiceCollectionScenario.Service(_rootM03D12di._singletonM03D12di34_Dependency); + return new Pure.DI.UsageTests.BCL.ServiceCollectionScenario.Service(_rootM03D13di._singletonM03D13di34_Dependency); } } #endregion @@ -191,7 +199,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -205,7 +213,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -218,10 +226,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -242,10 +250,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -264,8 +272,8 @@ partial class Composition return "classDiagram\n" + " class Composition {\n" + - " -IDependency RootM03D12di0001\n" + - " -IService RootM03D12di0002\n" + + " -IDependency RootM03D13di0001\n" + + " -IService RootM03D13di0002\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object Resolve(Type type)\n" + @@ -286,35 +294,35 @@ partial class Composition " <>\n" + " }\n" + " Service o-- \"Singleton\" Dependency : \"Dependency Key\" IDependency\n" + - " Composition ..> Dependency : \"Dependency Key\" IDependency RootM03D12di0001\n" + - " Composition ..> Service : IService RootM03D12di0002"; + " Composition ..> Dependency : IDependency RootM03D13di0001
provides \"Dependency Key\" IDependency\n" + + " Composition ..> Service : IService RootM03D13di0002
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - OnNewRoot(valResolverM03D12di_0000, "RootM03D12di0001", "Dependency Key", Pure.DI.Lifetime.Singleton); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - OnNewRoot(valResolverM03D12di_0001, "RootM03D12di0002", null, Pure.DI.Lifetime.Transient); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + OnNewRoot(valResolverM03D13di_0000, "RootM03D13di0001", "Dependency Key", Pure.DI.Lifetime.Singleton); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + OnNewRoot(valResolverM03D13di_0001, "RootM03D13di0002", null, Pure.DI.Lifetime.Transient); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IDependency), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IService), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IDependency), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IService), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -327,7 +335,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IDependency Resolve(Composition composition) { @@ -339,17 +347,17 @@ partial class Composition switch (tag) { case "Dependency Key": - return composition.RootM03D12di0001; + return composition.RootM03D13di0001; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IDependency."); } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IService Resolve(Composition composition) { - return composition.RootM03D12di0002; + return composition.RootM03D13di0002; } public Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IService ResolveByTag(Composition composition, object tag) @@ -357,7 +365,7 @@ partial class Composition switch (tag) { case null: - return composition.RootM03D12di0002; + return composition.RootM03D13di0002; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.BCL.ServiceCollectionScenario.IService."); } diff --git a/readme/service-provider-with-scope.md b/readme/service-provider-with-scope.md index 90dc4b9a6..7b8679c82 100644 --- a/readme/service-provider-with-scope.md +++ b/readme/service-provider-with-scope.md @@ -73,8 +73,8 @@ dependency1.ShouldBe(dependency2); ```mermaid classDiagram class Composition { - -IDependency RootM03D12di0001 - -IService RootM03D12di0002 + -IDependency RootM03D13di0001 + -IService RootM03D13di0002 + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object GetService(Type type) @@ -96,8 +96,8 @@ classDiagram <> } Service o-- "Singleton" Dependency : IDependency - Composition ..> Dependency : IDependency RootM03D12di0001 - Composition ..> Service : IService RootM03D12di0002 + Composition ..> Dependency : IDependency RootM03D13di0001
provides IDependency + Composition ..> Service : IService RootM03D13di0002
provides IService ``` @@ -112,7 +112,7 @@ classDiagram /// which implements the "IServiceProvider" interface: /// /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -120,7 +120,7 @@ classDiagram /// /// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IDependency>() ///
/// /// Provides a composition root of type . @@ -128,7 +128,7 @@ classDiagram ///
/// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IService>() ///
/// /// Provides a composition root of type . @@ -136,28 +136,30 @@ classDiagram ///
///
///
-/// Class diagram
-/// This class was created by Pure.DI source code generator. ///
+/// Class diagram
+/// This class was created by Pure.DI source code generator. /// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition: global::System.IDisposable { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private readonly global::System.IDisposable[] _disposablesM03D12di; - private int _disposeIndexM03D12di; - private Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Dependency _singletonM03D12di34_Dependency; - private Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Service _scopedM03D12di35_Service; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private readonly global::System.IDisposable[] _disposablesM03D13di; + private int _disposeIndexM03D13di; + private Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Dependency _singletonM03D13di34_Dependency; + private Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Service _scopedM03D13di35_Service; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); - _disposablesM03D12di = new global::System.IDisposable[1]; + _rootM03D13di = this; + _lockM03D13di = new object(); + _disposablesM03D13di = new global::System.IDisposable[1]; } /// @@ -166,58 +168,64 @@ partial class Composition: global::System.IDisposable /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; - _disposablesM03D12di = new global::System.IDisposable[1]; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; + _disposablesM03D13di = new global::System.IDisposable[1]; } #region Composition Roots - public Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IDependency RootM03D12di0001 + /// + /// Provides a composition root of type . + /// + public Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IDependency RootM03D13di0001 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } } } - return _rootM03D12di._singletonM03D12di34_Dependency; + return _rootM03D13di._singletonM03D13di34_Dependency; } } - public Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IService RootM03D12di0002 + /// + /// Provides a composition root of type . + /// + public Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IService RootM03D13di0002 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif get { - if (ReferenceEquals(_scopedM03D12di35_Service, null)) + if (ReferenceEquals(_scopedM03D13di35_Service, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_scopedM03D12di35_Service, null)) + if (ReferenceEquals(_scopedM03D13di35_Service, null)) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } - _scopedM03D12di35_Service = new Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Service(_rootM03D12di._singletonM03D12di34_Dependency); - _disposablesM03D12di[_disposeIndexM03D12di++] = _scopedM03D12di35_Service; + _scopedM03D13di35_Service = new Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.Service(_rootM03D13di._singletonM03D13di34_Dependency); + _disposablesM03D13di[_disposeIndexM03D13di++] = _scopedM03D13di35_Service; } } } - return _scopedM03D12di35_Service; + return _scopedM03D13di35_Service; } } #endregion @@ -233,7 +241,7 @@ partial class Composition: global::System.IDisposable #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -247,7 +255,7 @@ partial class Composition: global::System.IDisposable #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -260,10 +268,10 @@ partial class Composition: global::System.IDisposable #endif public object GetService(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -284,10 +292,10 @@ partial class Composition: global::System.IDisposable #endif public object GetRequiredKeyedService(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -304,11 +312,11 @@ partial class Composition: global::System.IDisposable /// public void Dispose() { - lock (_lockM03D12di) + lock (_lockM03D13di) { - while (_disposeIndexM03D12di > 0) + while (_disposeIndexM03D13di > 0) { - var disposableInstance = _disposablesM03D12di[--_disposeIndexM03D12di]; + var disposableInstance = _disposablesM03D13di[--_disposeIndexM03D13di]; try { disposableInstance.Dispose(); @@ -319,8 +327,8 @@ partial class Composition: global::System.IDisposable } } - _singletonM03D12di34_Dependency = null; - _scopedM03D12di35_Service = null; + _singletonM03D13di34_Dependency = null; + _scopedM03D13di35_Service = null; } } @@ -334,8 +342,8 @@ partial class Composition: global::System.IDisposable return "classDiagram\n" + " class Composition {\n" + - " -IDependency RootM03D12di0001\n" + - " -IService RootM03D12di0002\n" + + " -IDependency RootM03D13di0001\n" + + " -IService RootM03D13di0002\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object GetService(Type type)\n" + @@ -357,33 +365,33 @@ partial class Composition: global::System.IDisposable " <>\n" + " }\n" + " Service o-- \"Singleton\" Dependency : IDependency\n" + - " Composition ..> Dependency : IDependency RootM03D12di0001\n" + - " Composition ..> Service : IService RootM03D12di0002"; + " Composition ..> Dependency : IDependency RootM03D13di0001
provides IDependency\n" + + " Composition ..> Service : IService RootM03D13di0002
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IDependency), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IService), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IDependency), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IService), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -396,11 +404,11 @@ partial class Composition: global::System.IDisposable } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IDependency Resolve(Composition composition) { - return composition.RootM03D12di0001; + return composition.RootM03D13di0001; } public Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IDependency ResolveByTag(Composition composition, object tag) @@ -408,17 +416,17 @@ partial class Composition: global::System.IDisposable switch (tag) { case null: - return composition.RootM03D12di0001; + return composition.RootM03D13di0001; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IDependency."); } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IService Resolve(Composition composition) { - return composition.RootM03D12di0002; + return composition.RootM03D13di0002; } public Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IService ResolveByTag(Composition composition, object tag) @@ -426,7 +434,7 @@ partial class Composition: global::System.IDisposable switch (tag) { case null: - return composition.RootM03D12di0002; + return composition.RootM03D13di0002; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.BCL.ServiceProviderWithScopeScenario.IService."); } diff --git a/readme/service-provider.md b/readme/service-provider.md index cdbd38bdb..eb5daaba9 100644 --- a/readme/service-provider.md +++ b/readme/service-provider.md @@ -45,8 +45,8 @@ service.Dependency.ShouldBe(dependency); ```mermaid classDiagram class Composition { - -IDependency RootM03D12di0001 - -IService RootM03D12di0002 + -IDependency RootM03D13di0001 + -IService RootM03D13di0002 + T ResolveᐸTᐳ() + T ResolveᐸTᐳ(object? tag) + object GetService(Type type) @@ -67,8 +67,8 @@ classDiagram <> } Service o-- "Singleton" Dependency : IDependency - Composition ..> Dependency : IDependency RootM03D12di0001 - Composition ..> Service : IService RootM03D12di0002 + Composition ..> Dependency : IDependency RootM03D13di0001
provides IDependency + Composition ..> Service : IService RootM03D13di0002
provides IService ``` @@ -78,7 +78,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -86,7 +86,7 @@ classDiagram /// /// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.BCL.ServiceProviderScenario.IDependency>() ///
/// /// Provides a composition root of type . @@ -94,7 +94,7 @@ classDiagram ///
/// /// -/// is a private composition root that can be resolved by methods like . +/// is a private composition root that can be resolved by methods like .
or using method: Resolve<Pure.DI.UsageTests.BCL.ServiceProviderScenario.IService>() ///
/// /// Provides a composition root of type . @@ -102,24 +102,26 @@ classDiagram ///
///
///
-/// Class diagram
-/// This class was created by Pure.DI source code generator. ///
+/// Class diagram
+/// This class was created by Pure.DI source code generator. /// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.BCL.ServiceProviderScenario.Dependency _singletonM03D12di34_Dependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.BCL.ServiceProviderScenario.Dependency _singletonM03D13di34_Dependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -128,52 +130,58 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots - public Pure.DI.UsageTests.BCL.ServiceProviderScenario.IDependency RootM03D12di0001 + /// + /// Provides a composition root of type . + /// + public Pure.DI.UsageTests.BCL.ServiceProviderScenario.IDependency RootM03D13di0001 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceProviderScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceProviderScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } } } - return _rootM03D12di._singletonM03D12di34_Dependency; + return _rootM03D13di._singletonM03D13di34_Dependency; } } - public Pure.DI.UsageTests.BCL.ServiceProviderScenario.IService RootM03D12di0002 + /// + /// Provides a composition root of type . + /// + public Pure.DI.UsageTests.BCL.ServiceProviderScenario.IService RootM03D13di0002 { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceProviderScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.BCL.ServiceProviderScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } } } - return new Pure.DI.UsageTests.BCL.ServiceProviderScenario.Service(_rootM03D12di._singletonM03D12di34_Dependency); + return new Pure.DI.UsageTests.BCL.ServiceProviderScenario.Service(_rootM03D13di._singletonM03D13di34_Dependency); } } #endregion @@ -189,7 +197,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -203,7 +211,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -216,10 +224,10 @@ partial class Composition #endif public object GetService(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -240,10 +248,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -262,8 +270,8 @@ partial class Composition return "classDiagram\n" + " class Composition {\n" + - " -IDependency RootM03D12di0001\n" + - " -IService RootM03D12di0002\n" + + " -IDependency RootM03D13di0001\n" + + " -IService RootM03D13di0002\n" + " + T ResolveᐸTᐳ()\n" + " + T ResolveᐸTᐳ(object? tag)\n" + " + object GetService(Type type)\n" + @@ -284,33 +292,33 @@ partial class Composition " <>\n" + " }\n" + " Service o-- \"Singleton\" Dependency : IDependency\n" + - " Composition ..> Dependency : IDependency RootM03D12di0001\n" + - " Composition ..> Service : IService RootM03D12di0002"; + " Composition ..> Dependency : IDependency RootM03D13di0001
provides IDependency\n" + + " Composition ..> Service : IService RootM03D13di0002
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceProviderScenario.IDependency), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceProviderScenario.IService), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceProviderScenario.IDependency), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ServiceProviderScenario.IService), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -323,11 +331,11 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.ServiceProviderScenario.IDependency Resolve(Composition composition) { - return composition.RootM03D12di0001; + return composition.RootM03D13di0001; } public Pure.DI.UsageTests.BCL.ServiceProviderScenario.IDependency ResolveByTag(Composition composition, object tag) @@ -335,17 +343,17 @@ partial class Composition switch (tag) { case null: - return composition.RootM03D12di0001; + return composition.RootM03D13di0001; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.BCL.ServiceProviderScenario.IDependency."); } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.ServiceProviderScenario.IService Resolve(Composition composition) { - return composition.RootM03D12di0002; + return composition.RootM03D13di0002; } public Pure.DI.UsageTests.BCL.ServiceProviderScenario.IService ResolveByTag(Composition composition, object tag) @@ -353,7 +361,7 @@ partial class Composition switch (tag) { case null: - return composition.RootM03D12di0002; + return composition.RootM03D13di0002; } throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type Pure.DI.UsageTests.BCL.ServiceProviderScenario.IService."); } diff --git a/readme/simplified-binding.md b/readme/simplified-binding.md index 75f44ea8d..f7d83d4a3 100644 --- a/readme/simplified-binding.md +++ b/readme/simplified-binding.md @@ -76,7 +76,7 @@ classDiagram Service o-- "PerBlock" Dependency : Dependency Service o-- "PerBlock" Dependency : IDependency Service o-- "PerBlock" Dependency : IOtherDependency - Composition ..> Service : Service MyService + Composition ..> Service : Service MyService
provides Service ``` @@ -89,7 +89,7 @@ classDiagram /// Specifies to create a partial class "Composition" /// /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -97,7 +97,7 @@ classDiagram /// /// /// -/// MyService +///
or using method: Resolve<Pure.DI.UsageTests.Basics.SimplifiedBindingScenario.Service>() ///
/// /// Specifies to create a property "MyService" @@ -105,6 +105,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -112,21 +113,22 @@ classDiagram /// var instance = composition.MyService; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -135,13 +137,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots /// /// Specifies to create a property "MyService" /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.MyService; + /// + /// public Pure.DI.UsageTests.Basics.SimplifiedBindingScenario.Service MyService { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -149,8 +158,8 @@ partial class Composition #endif get { - var perBlockM03D12di1_Dependency = new Pure.DI.UsageTests.Basics.SimplifiedBindingScenario.Dependency(); - return new Pure.DI.UsageTests.Basics.SimplifiedBindingScenario.Service(perBlockM03D12di1_Dependency, perBlockM03D12di1_Dependency, perBlockM03D12di1_Dependency); + var perBlockM03D13di1_Dependency = new Pure.DI.UsageTests.Basics.SimplifiedBindingScenario.Dependency(); + return new Pure.DI.UsageTests.Basics.SimplifiedBindingScenario.Service(perBlockM03D13di1_Dependency, perBlockM03D13di1_Dependency, perBlockM03D13di1_Dependency); } } #endregion @@ -182,7 +191,7 @@ partial class Composition " Service o-- \"PerBlock\" Dependency : Dependency\n" + " Service o-- \"PerBlock\" Dependency : IDependency\n" + " Service o-- \"PerBlock\" Dependency : IOtherDependency\n" + - " Composition ..> Service : Service MyService"; + " Composition ..> Service : Service MyService
provides Service"; } } ``` diff --git a/readme/singleton.md b/readme/singleton.md index 3e4a794f7..7e1201d7e 100644 --- a/readme/singleton.md +++ b/readme/singleton.md @@ -65,7 +65,7 @@ classDiagram } Service o-- "Singleton" Dependency : IDependency Service o-- "Singleton" Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -75,7 +75,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -83,7 +83,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.SingletonScenario.IService>() ///
/// /// Provides a composition root of type . @@ -91,6 +91,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -98,24 +99,25 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.Lifetimes.SingletonScenario.Dependency _singletonM03D12di34_Dependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.Lifetimes.SingletonScenario.Dependency _singletonM03D13di34_Dependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -124,11 +126,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Lifetimes.SingletonScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -136,18 +148,18 @@ partial class Composition #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di34_Dependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di34_Dependency, null)) { - _singletonM03D12di34_Dependency = new Pure.DI.UsageTests.Lifetimes.SingletonScenario.Dependency(); - _rootM03D12di._singletonM03D12di34_Dependency = _singletonM03D12di34_Dependency; + _singletonM03D13di34_Dependency = new Pure.DI.UsageTests.Lifetimes.SingletonScenario.Dependency(); + _rootM03D13di._singletonM03D13di34_Dependency = _singletonM03D13di34_Dependency; } } } - return new Pure.DI.UsageTests.Lifetimes.SingletonScenario.Service(_singletonM03D12di34_Dependency, _rootM03D12di._singletonM03D12di34_Dependency); + return new Pure.DI.UsageTests.Lifetimes.SingletonScenario.Service(_singletonM03D13di34_Dependency, _rootM03D13di._singletonM03D13di34_Dependency); } } #endregion @@ -163,7 +175,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -177,7 +189,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -190,10 +202,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -214,10 +226,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -258,29 +270,29 @@ partial class Composition " }\n" + " Service o-- \"Singleton\" Dependency : IDependency\n" + " Service o-- \"Singleton\" Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.SingletonScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.SingletonScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -293,7 +305,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.SingletonScenario.IService Resolve(Composition composition) { diff --git a/readme/span-and-readonlyspan.md b/readme/span-and-readonlyspan.md index 0c0fca39b..af59bd3bc 100644 --- a/readme/span-and-readonlyspan.md +++ b/readme/span-and-readonlyspan.md @@ -67,7 +67,7 @@ classDiagram ReadOnlySpanᐸDependencyᐳ *-- Dependency : 'b' Dependency ReadOnlySpanᐸDependencyᐳ *-- Dependency : 'c' Dependency Service *-- ReadOnlySpanᐸDependencyᐳ : ReadOnlySpanᐸDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -77,7 +77,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -85,7 +85,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.SpanScenario.IService>() ///
/// /// Provides a composition root of type . @@ -93,6 +93,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -100,21 +101,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -123,10 +125,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.SpanScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -134,13 +146,13 @@ partial class Composition #endif get { - System.ReadOnlySpan transientM03D12di1_ReadOnlySpan = stackalloc Pure.DI.UsageTests.BCL.SpanScenario.Dependency[3] + System.ReadOnlySpan transientM03D13di1_ReadOnlySpan = stackalloc Pure.DI.UsageTests.BCL.SpanScenario.Dependency[3] { new Pure.DI.UsageTests.BCL.SpanScenario.Dependency(), new Pure.DI.UsageTests.BCL.SpanScenario.Dependency(), new Pure.DI.UsageTests.BCL.SpanScenario.Dependency() }; - return new Pure.DI.UsageTests.BCL.SpanScenario.Service(transientM03D12di1_ReadOnlySpan); + return new Pure.DI.UsageTests.BCL.SpanScenario.Service(transientM03D13di1_ReadOnlySpan); } } #endregion @@ -156,7 +168,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -170,7 +182,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -183,10 +195,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -207,10 +219,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -250,29 +262,29 @@ partial class Composition " ReadOnlySpanᐸDependencyᐳ *-- Dependency : 'b' Dependency\n" + " ReadOnlySpanᐸDependencyᐳ *-- Dependency : 'c' Dependency\n" + " Service *-- ReadOnlySpanᐸDependencyᐳ : ReadOnlySpanᐸDependencyᐳ\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.SpanScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.SpanScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -285,7 +297,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.SpanScenario.IService Resolve(Composition composition) { diff --git a/readme/tag-attribute.md b/readme/tag-attribute.md index 1f1abb001..befe35e4a 100644 --- a/readme/tag-attribute.md +++ b/readme/tag-attribute.md @@ -75,7 +75,7 @@ classDiagram } Service *-- AbcDependency : "Abc" IDependency Service *-- XyzDependency : "Xyz" IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -85,7 +85,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -93,7 +93,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.TagAttributeScenario.IService>() ///
/// /// Provides a composition root of type . @@ -101,6 +101,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -108,21 +109,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -131,10 +133,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.TagAttributeScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -158,7 +170,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -172,7 +184,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -185,10 +197,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -209,10 +221,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -257,29 +269,29 @@ partial class Composition " }\n" + " Service *-- AbcDependency : \"Abc\" IDependency\n" + " Service *-- XyzDependency : \"Xyz\" IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagAttributeScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagAttributeScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -292,7 +304,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.TagAttributeScenario.IService Resolve(Composition composition) { diff --git a/readme/tag-type.md b/readme/tag-type.md index 0203cd3da..7663061ec 100644 --- a/readme/tag-type.md +++ b/readme/tag-type.md @@ -87,8 +87,8 @@ classDiagram Service *-- AbcDependency : typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.AbcDependency) IDependency Service o-- "Singleton" XyzDependency : typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency) IDependency Service *-- AbcDependency : IDependency - Composition ..> Service : IService Root - Composition ..> XyzDependency : typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency) IDependency XyzRoot + Composition ..> Service : IService Root
provides IService + Composition ..> XyzDependency : IDependency XyzRoot
provides typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency) IDependency ``` @@ -98,7 +98,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -106,7 +106,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.TagTypeScenario.IService>() ///
/// /// Provides a composition root of type . @@ -114,7 +114,7 @@ classDiagram ///
/// /// -/// XyzRoot +///
or using method: Resolve<Pure.DI.UsageTests.Basics.TagTypeScenario.IDependency>(typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency)) ///
/// /// "XyzRoot" is root name, typeof(XyzDependency) is tag @@ -122,6 +122,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -129,24 +130,25 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency _singletonM03D12di35_XyzDependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency _singletonM03D13di35_XyzDependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -155,14 +157,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots /// /// "XyzRoot" is root name, typeof(XyzDependency) is tag /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.XyzRoot; + /// + /// public Pure.DI.UsageTests.Basics.TagTypeScenario.IDependency XyzRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -170,21 +179,31 @@ partial class Composition #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_XyzDependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_XyzDependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_XyzDependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_XyzDependency, null)) { - _singletonM03D12di35_XyzDependency = new Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency(); - _rootM03D12di._singletonM03D12di35_XyzDependency = _singletonM03D12di35_XyzDependency; + _singletonM03D13di35_XyzDependency = new Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency(); + _rootM03D13di._singletonM03D13di35_XyzDependency = _singletonM03D13di35_XyzDependency; } } } - return _rootM03D12di._singletonM03D12di35_XyzDependency; + return _rootM03D13di._singletonM03D13di35_XyzDependency; } } + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.TagTypeScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -192,18 +211,18 @@ partial class Composition #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_XyzDependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_XyzDependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_XyzDependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_XyzDependency, null)) { - _singletonM03D12di35_XyzDependency = new Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency(); - _rootM03D12di._singletonM03D12di35_XyzDependency = _singletonM03D12di35_XyzDependency; + _singletonM03D13di35_XyzDependency = new Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency(); + _rootM03D13di._singletonM03D13di35_XyzDependency = _singletonM03D13di35_XyzDependency; } } } - return new Pure.DI.UsageTests.Basics.TagTypeScenario.Service(new Pure.DI.UsageTests.Basics.TagTypeScenario.AbcDependency(), _rootM03D12di._singletonM03D12di35_XyzDependency, new Pure.DI.UsageTests.Basics.TagTypeScenario.AbcDependency()); + return new Pure.DI.UsageTests.Basics.TagTypeScenario.Service(new Pure.DI.UsageTests.Basics.TagTypeScenario.AbcDependency(), _rootM03D13di._singletonM03D13di35_XyzDependency, new Pure.DI.UsageTests.Basics.TagTypeScenario.AbcDependency()); } } #endregion @@ -219,7 +238,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -233,7 +252,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -246,10 +265,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -270,10 +289,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -321,33 +340,33 @@ partial class Composition " Service *-- AbcDependency : typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.AbcDependency) IDependency\n" + " Service o-- \"Singleton\" XyzDependency : typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency) IDependency\n" + " Service *-- AbcDependency : IDependency\n" + - " Composition ..> Service : IService Root\n" + - " Composition ..> XyzDependency : typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency) IDependency XyzRoot"; + " Composition ..> Service : IService Root
provides IService\n" + + " Composition ..> XyzDependency : IDependency XyzRoot
provides typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.XyzDependency) IDependency"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.IDependency), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.IService), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.IDependency), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagTypeScenario.IService), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -360,7 +379,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.TagTypeScenario.IDependency Resolve(Composition composition) { @@ -377,7 +396,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.TagTypeScenario.IService Resolve(Composition composition) { diff --git a/readme/tag-unique.md b/readme/tag-unique.md index fb665b05e..27734af27 100644 --- a/readme/tag-unique.md +++ b/readme/tag-unique.md @@ -46,11 +46,11 @@ classDiagram + object Resolve(Type type, object? tag) } class IEnumerableᐸIDependencyᐸStringᐳᐳ - AbcDependencyᐸStringᐳ --|> IDependencyᐸStringᐳ : 545495d7-7038-4257-bedd-92a03cf2d43a + AbcDependencyᐸStringᐳ --|> IDependencyᐸStringᐳ : 60884a16-eca8-4574-bcef-46bf92e5efc2 class AbcDependencyᐸStringᐳ { +AbcDependency() } - XyzDependencyᐸStringᐳ --|> IDependencyᐸStringᐳ : c4091ca0-2d4d-4c77-8a4c-43d86861f3ba + XyzDependencyᐸStringᐳ --|> IDependencyᐸStringᐳ : 7ef283a0-501a-4996-94b0-8d865e55ab48 class XyzDependencyᐸStringᐳ { +XyzDependency() } @@ -64,9 +64,9 @@ classDiagram class IServiceᐸStringᐳ { <> } - IEnumerableᐸIDependencyᐸStringᐳᐳ *-- AbcDependencyᐸStringᐳ : 545495d7-7038-4257-bedd-92a03cf2d43a IDependencyᐸStringᐳ - IEnumerableᐸIDependencyᐸStringᐳᐳ *-- XyzDependencyᐸStringᐳ : c4091ca0-2d4d-4c77-8a4c-43d86861f3ba IDependencyᐸStringᐳ - Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ Root + IEnumerableᐸIDependencyᐸStringᐳᐳ *-- AbcDependencyᐸStringᐳ : 60884a16-eca8-4574-bcef-46bf92e5efc2 IDependencyᐸStringᐳ + IEnumerableᐸIDependencyᐸStringᐳᐳ *-- XyzDependencyᐸStringᐳ : 7ef283a0-501a-4996-94b0-8d865e55ab48 IDependencyᐸStringᐳ + Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ Root
provides IServiceᐸStringᐳ ServiceᐸStringᐳ o-- "PerBlock" IEnumerableᐸIDependencyᐸStringᐳᐳ : IEnumerableᐸIDependencyᐸStringᐳᐳ ``` @@ -77,7 +77,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -85,7 +85,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.TagUniqueScenario.IService<string>>() ///
/// /// Provides a composition root of type . @@ -93,6 +93,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -100,21 +101,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -123,10 +125,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.TagUniqueScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -135,13 +147,13 @@ partial class Composition get { [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x200)] - System.Collections.Generic.IEnumerable> LocalperBlockM03D12di1_IEnumerable() + System.Collections.Generic.IEnumerable> LocalperBlockM03D13di1_IEnumerable() { yield return new Pure.DI.UsageTests.Basics.TagUniqueScenario.AbcDependency(); yield return new Pure.DI.UsageTests.Basics.TagUniqueScenario.XyzDependency(); } - var perBlockM03D12di1_IEnumerable = LocalperBlockM03D12di1_IEnumerable(); - return new Pure.DI.UsageTests.Basics.TagUniqueScenario.Service(perBlockM03D12di1_IEnumerable); + var perBlockM03D13di1_IEnumerable = LocalperBlockM03D13di1_IEnumerable(); + return new Pure.DI.UsageTests.Basics.TagUniqueScenario.Service(perBlockM03D13di1_IEnumerable); } } #endregion @@ -157,7 +169,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -171,7 +183,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -184,10 +196,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -208,10 +220,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -237,11 +249,11 @@ partial class Composition " + object Resolve(Type type, object? tag)\n" + " }\n" + " class IEnumerableᐸIDependencyᐸStringᐳᐳ\n" + - " AbcDependencyᐸStringᐳ --|> IDependencyᐸStringᐳ : 545495d7-7038-4257-bedd-92a03cf2d43a \n" + + " AbcDependencyᐸStringᐳ --|> IDependencyᐸStringᐳ : 60884a16-eca8-4574-bcef-46bf92e5efc2 \n" + " class AbcDependencyᐸStringᐳ {\n" + " +AbcDependency()\n" + " }\n" + - " XyzDependencyᐸStringᐳ --|> IDependencyᐸStringᐳ : c4091ca0-2d4d-4c77-8a4c-43d86861f3ba \n" + + " XyzDependencyᐸStringᐳ --|> IDependencyᐸStringᐳ : 7ef283a0-501a-4996-94b0-8d865e55ab48 \n" + " class XyzDependencyᐸStringᐳ {\n" + " +XyzDependency()\n" + " }\n" + @@ -255,32 +267,32 @@ partial class Composition " class IServiceᐸStringᐳ {\n" + " <>\n" + " }\n" + - " IEnumerableᐸIDependencyᐸStringᐳᐳ *-- AbcDependencyᐸStringᐳ : 545495d7-7038-4257-bedd-92a03cf2d43a IDependencyᐸStringᐳ\n" + - " IEnumerableᐸIDependencyᐸStringᐳᐳ *-- XyzDependencyᐸStringᐳ : c4091ca0-2d4d-4c77-8a4c-43d86861f3ba IDependencyᐸStringᐳ\n" + - " Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ Root\n" + + " IEnumerableᐸIDependencyᐸStringᐳᐳ *-- AbcDependencyᐸStringᐳ : 60884a16-eca8-4574-bcef-46bf92e5efc2 IDependencyᐸStringᐳ\n" + + " IEnumerableᐸIDependencyᐸStringᐳᐳ *-- XyzDependencyᐸStringᐳ : 7ef283a0-501a-4996-94b0-8d865e55ab48 IDependencyᐸStringᐳ\n" + + " Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ Root
provides IServiceᐸStringᐳ\n" + " ServiceᐸStringᐳ o-- \"PerBlock\" IEnumerableᐸIDependencyᐸStringᐳᐳ : IEnumerableᐸIDependencyᐸStringᐳᐳ"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di>.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di>.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagUniqueScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagUniqueScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -293,7 +305,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver> + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver> { public Pure.DI.UsageTests.Basics.TagUniqueScenario.IService Resolve(Composition composition) { diff --git a/readme/tags.md b/readme/tags.md index 3caa93cb9..08d816f8e 100644 --- a/readme/tags.md +++ b/readme/tags.md @@ -89,8 +89,8 @@ classDiagram Service *-- AbcDependency : "Abc" IDependency Service o-- "Singleton" XyzDependency : "Xyz" IDependency Service *-- AbcDependency : IDependency - Composition ..> XyzDependency : "Xyz" IDependency XyzRoot - Composition ..> Service : IService Root + Composition ..> XyzDependency : IDependency XyzRoot
provides "Xyz" IDependency + Composition ..> Service : IService Root
provides IService ``` @@ -100,7 +100,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -108,7 +108,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.TagsScenario.IService>() ///
/// /// Provides a composition root of type . @@ -116,7 +116,7 @@ classDiagram ///
/// /// -/// XyzRoot +///
or using method: Resolve<Pure.DI.UsageTests.Basics.TagsScenario.IDependency>("Xyz") ///
/// /// "XyzRoot" is root name, "Xyz" is tag @@ -124,6 +124,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -131,24 +132,25 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; - private Pure.DI.UsageTests.Basics.TagsScenario.XyzDependency _singletonM03D12di35_XyzDependency; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; + private Pure.DI.UsageTests.Basics.TagsScenario.XyzDependency _singletonM03D13di35_XyzDependency; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -157,14 +159,21 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots /// /// "XyzRoot" is root name, "Xyz" is tag /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.XyzRoot; + /// + /// public Pure.DI.UsageTests.Basics.TagsScenario.IDependency XyzRoot { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -172,21 +181,31 @@ partial class Composition #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_XyzDependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_XyzDependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_XyzDependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_XyzDependency, null)) { - _singletonM03D12di35_XyzDependency = new Pure.DI.UsageTests.Basics.TagsScenario.XyzDependency(); - _rootM03D12di._singletonM03D12di35_XyzDependency = _singletonM03D12di35_XyzDependency; + _singletonM03D13di35_XyzDependency = new Pure.DI.UsageTests.Basics.TagsScenario.XyzDependency(); + _rootM03D13di._singletonM03D13di35_XyzDependency = _singletonM03D13di35_XyzDependency; } } } - return _rootM03D12di._singletonM03D12di35_XyzDependency; + return _rootM03D13di._singletonM03D13di35_XyzDependency; } } + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.TagsScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -194,18 +213,18 @@ partial class Composition #endif get { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_XyzDependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_XyzDependency, null)) { - lock (_lockM03D12di) + lock (_lockM03D13di) { - if (ReferenceEquals(_rootM03D12di._singletonM03D12di35_XyzDependency, null)) + if (ReferenceEquals(_rootM03D13di._singletonM03D13di35_XyzDependency, null)) { - _singletonM03D12di35_XyzDependency = new Pure.DI.UsageTests.Basics.TagsScenario.XyzDependency(); - _rootM03D12di._singletonM03D12di35_XyzDependency = _singletonM03D12di35_XyzDependency; + _singletonM03D13di35_XyzDependency = new Pure.DI.UsageTests.Basics.TagsScenario.XyzDependency(); + _rootM03D13di._singletonM03D13di35_XyzDependency = _singletonM03D13di35_XyzDependency; } } } - return new Pure.DI.UsageTests.Basics.TagsScenario.Service(new Pure.DI.UsageTests.Basics.TagsScenario.AbcDependency(), _rootM03D12di._singletonM03D12di35_XyzDependency, new Pure.DI.UsageTests.Basics.TagsScenario.AbcDependency()); + return new Pure.DI.UsageTests.Basics.TagsScenario.Service(new Pure.DI.UsageTests.Basics.TagsScenario.AbcDependency(), _rootM03D13di._singletonM03D13di35_XyzDependency, new Pure.DI.UsageTests.Basics.TagsScenario.AbcDependency()); } } #endregion @@ -221,7 +240,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -235,7 +254,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -248,10 +267,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -272,10 +291,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -323,33 +342,33 @@ partial class Composition " Service *-- AbcDependency : \"Abc\" IDependency\n" + " Service o-- \"Singleton\" XyzDependency : \"Xyz\" IDependency\n" + " Service *-- AbcDependency : IDependency\n" + - " Composition ..> XyzDependency : \"Xyz\" IDependency XyzRoot\n" + - " Composition ..> Service : IService Root"; + " Composition ..> XyzDependency : IDependency XyzRoot
provides \"Xyz\" IDependency\n" + + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - var valResolverM03D12di_0001 = new ResolverM03D12di_0001(); - ResolverM03D12di.Value = valResolverM03D12di_0001; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + var valResolverM03D13di_0001 = new ResolverM03D13di_0001(); + ResolverM03D13di.Value = valResolverM03D13di_0001; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 4, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[2] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagsScenario.IDependency), valResolverM03D12di_0000) - ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagsScenario.IService), valResolverM03D12di_0001) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagsScenario.IDependency), valResolverM03D13di_0000) + ,new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TagsScenario.IService), valResolverM03D13di_0001) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -362,7 +381,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.TagsScenario.IDependency Resolve(Composition composition) { @@ -380,7 +399,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0001: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0001: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.TagsScenario.IService Resolve(Composition composition) { diff --git a/readme/task.md b/readme/task.md index bbb6426e1..5205ee563 100644 --- a/readme/task.md +++ b/readme/task.md @@ -89,7 +89,7 @@ classDiagram TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions TaskFactory *-- TaskScheduler : TaskScheduler Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ - Composition ..> Service : IService GetRoot + Composition ..> Service : IService GetRoot(System.Threading.CancellationToken cancellationToken)
provides IService TaskᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ TaskᐸIDependencyᐳ o-- "PerBlock" TaskFactoryᐸIDependencyᐳ : TaskFactoryᐸIDependencyᐳ FuncᐸIDependencyᐳ *-- Dependency : IDependency @@ -106,7 +106,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -114,7 +114,7 @@ classDiagram /// /// /// -/// GetRoot +/// /// /// /// Provides a composition root of type . @@ -122,30 +122,32 @@ classDiagram /// /// ///
+///
/// -/// This shows how to get an instance of type using the composition root : +/// This shows how to get an instance of type using the composition root : /// -/// var composition = new Composition(cancellationToken); +/// var composition = new Composition(); /// var instance = composition.GetRoot(cancellationToken); /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; - private readonly object _lockM03D12di; + private readonly Composition _rootM03D13di; + private readonly object _lockM03D13di; /// /// This parameterized constructor creates a new instance of with arguments. /// public Composition() { - _rootM03D12di = this; - _lockM03D12di = new object(); + _rootM03D13di = this; + _lockM03D13di = new object(); } /// @@ -154,42 +156,52 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; - _lockM03D12di = _rootM03D12di._lockM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; + _lockM03D13di = _rootM03D13di._lockM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.GetRoot(cancellationToken); + /// + /// #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET [global::System.Diagnostics.Contracts.Pure] #endif public Pure.DI.UsageTests.BCL.TaskScenario.IService GetRoot(System.Threading.CancellationToken cancellationToken) { - var perResolveM03D12di39_Func = default(System.Func); - System.Threading.Tasks.TaskScheduler transientM03D12di5_TaskScheduler = TaskScheduler.Current; - System.Threading.Tasks.TaskContinuationOptions transientM03D12di4_TaskContinuationOptions = global::System.Threading.Tasks.TaskContinuationOptions.None; - System.Threading.Tasks.TaskCreationOptions transientM03D12di3_TaskCreationOptions = global::System.Threading.Tasks.TaskCreationOptions.None; - System.Threading.Tasks.TaskFactory perBlockM03D12di2_TaskFactory; + var perResolveM03D13di39_Func = default(System.Func); + System.Threading.Tasks.TaskScheduler transientM03D13di5_TaskScheduler = TaskScheduler.Current; + System.Threading.Tasks.TaskContinuationOptions transientM03D13di4_TaskContinuationOptions = global::System.Threading.Tasks.TaskContinuationOptions.None; + System.Threading.Tasks.TaskCreationOptions transientM03D13di3_TaskCreationOptions = global::System.Threading.Tasks.TaskCreationOptions.None; + System.Threading.Tasks.TaskFactory perBlockM03D13di2_TaskFactory; { - var cancellationToken_M03D12di1 = cancellationToken; - var taskCreationOptions_M03D12di2 = transientM03D12di3_TaskCreationOptions; - var taskContinuationOptions_M03D12di3 = transientM03D12di4_TaskContinuationOptions; - var taskScheduler_M03D12di4 = transientM03D12di5_TaskScheduler; - perBlockM03D12di2_TaskFactory = new global::System.Threading.Tasks.TaskFactory(cancellationToken_M03D12di1, taskCreationOptions_M03D12di2, taskContinuationOptions_M03D12di3, taskScheduler_M03D12di4); + var cancellationToken_M03D13di1 = cancellationToken; + var taskCreationOptions_M03D13di2 = transientM03D13di3_TaskCreationOptions; + var taskContinuationOptions_M03D13di3 = transientM03D13di4_TaskContinuationOptions; + var taskScheduler_M03D13di4 = transientM03D13di5_TaskScheduler; + perBlockM03D13di2_TaskFactory = new global::System.Threading.Tasks.TaskFactory(cancellationToken_M03D13di1, taskCreationOptions_M03D13di2, taskContinuationOptions_M03D13di3, taskScheduler_M03D13di4); } - perResolveM03D12di39_Func = new global::System.Func( + perResolveM03D13di39_Func = new global::System.Func( [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)768)] () => { - var factory_M03D12di5 = new Pure.DI.UsageTests.BCL.TaskScenario.Dependency(); - return factory_M03D12di5; + var factory_M03D13di5 = new Pure.DI.UsageTests.BCL.TaskScenario.Dependency(); + return factory_M03D13di5; }); - System.Threading.Tasks.Task transientM03D12di1_Task; + System.Threading.Tasks.Task transientM03D13di1_Task; { - var factory_M03D12di6 = perResolveM03D12di39_Func; - var taskFactory_M03D12di7 = perBlockM03D12di2_TaskFactory; - transientM03D12di1_Task = taskFactory_M03D12di7.StartNew(factory_M03D12di6); + var factory_M03D13di6 = perResolveM03D13di39_Func; + var taskFactory_M03D13di7 = perBlockM03D13di2_TaskFactory; + transientM03D13di1_Task = taskFactory_M03D13di7.StartNew(factory_M03D13di6); } - return new Pure.DI.UsageTests.BCL.TaskScenario.Service(transientM03D12di1_Task); + return new Pure.DI.UsageTests.BCL.TaskScenario.Service(transientM03D13di1_Task); } #endregion @@ -230,7 +242,7 @@ partial class Composition " TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions\n" + " TaskFactory *-- TaskScheduler : TaskScheduler\n" + " Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ\n" + - " Composition ..> Service : IService GetRoot\n" + + " Composition ..> Service : IService GetRoot(System.Threading.CancellationToken cancellationToken)
provides IService\n" + " TaskᐸIDependencyᐳ o-- \"PerResolve\" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ\n" + " TaskᐸIDependencyᐳ o-- \"PerBlock\" TaskFactoryᐸIDependencyᐳ : TaskFactoryᐸIDependencyᐳ\n" + " FuncᐸIDependencyᐳ *-- Dependency : IDependency\n" + diff --git a/readme/threadsafe-hint.md b/readme/threadsafe-hint.md index 5b053bac6..8f840cb34 100644 --- a/readme/threadsafe-hint.md +++ b/readme/threadsafe-hint.md @@ -54,7 +54,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -64,7 +64,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -72,7 +72,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Hints.ThreadSafeHintScenario.IService>() ///
/// /// Provides a composition root of type . @@ -80,6 +80,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -87,21 +88,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -110,10 +112,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Hints.ThreadSafeHintScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -137,7 +149,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -151,7 +163,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -164,10 +176,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -188,10 +200,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -231,29 +243,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.ThreadSafeHintScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.ThreadSafeHintScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -266,7 +278,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Hints.ThreadSafeHintScenario.IService Resolve(Composition composition) { diff --git a/readme/tostring-hint.md b/readme/tostring-hint.md index 6b98be9d3..c69860b34 100644 --- a/readme/tostring-hint.md +++ b/readme/tostring-hint.md @@ -52,7 +52,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService MyService + Composition ..> Service : IService MyService
provides IService ``` @@ -62,7 +62,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -70,7 +70,7 @@ classDiagram /// /// /// -/// MyService +///
or using method: Resolve<Pure.DI.UsageTests.Hints.ToStringHintScenario.IService>() ///
/// /// Provides a composition root of type . @@ -78,6 +78,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -85,21 +86,22 @@ classDiagram /// var instance = composition.MyService; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -108,10 +110,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.MyService; + /// + /// public Pure.DI.UsageTests.Hints.ToStringHintScenario.IService MyService { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -135,7 +147,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -149,7 +161,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -162,10 +174,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -186,10 +198,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -229,29 +241,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService MyService"; + " Composition ..> Service : IService MyService
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.ToStringHintScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Hints.ToStringHintScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -264,7 +276,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Hints.ToStringHintScenario.IService Resolve(Composition composition) { diff --git a/readme/tracking-disposable-instances.md b/readme/tracking-disposable-instances.md index 32426908a..930f0a4dc 100644 --- a/readme/tracking-disposable-instances.md +++ b/readme/tracking-disposable-instances.md @@ -107,7 +107,7 @@ classDiagram <> } Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -117,7 +117,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -125,7 +125,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Basics.TrackingDisposableInstancesScenario.IService>() ///
/// /// Provides a composition root of type . @@ -133,6 +133,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -140,21 +141,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -163,10 +165,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Basics.TrackingDisposableInstancesScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -174,11 +186,11 @@ partial class Composition #endif get { - var transientM03D12di1_Dependency = new Pure.DI.UsageTests.Basics.TrackingDisposableInstancesScenario.Dependency(); - OnNewInstance(ref transientM03D12di1_Dependency, null, Pure.DI.Lifetime.Transient); - var transientM03D12di0_Service = new Pure.DI.UsageTests.Basics.TrackingDisposableInstancesScenario.Service(transientM03D12di1_Dependency); - OnNewInstance(ref transientM03D12di0_Service, null, Pure.DI.Lifetime.Transient); - return transientM03D12di0_Service; + var transientM03D13di1_Dependency = new Pure.DI.UsageTests.Basics.TrackingDisposableInstancesScenario.Dependency(); + OnNewInstance(ref transientM03D13di1_Dependency, null, Pure.DI.Lifetime.Transient); + var transientM03D13di0_Service = new Pure.DI.UsageTests.Basics.TrackingDisposableInstancesScenario.Service(transientM03D13di1_Dependency); + OnNewInstance(ref transientM03D13di0_Service, null, Pure.DI.Lifetime.Transient); + return transientM03D13di0_Service; } } #endregion @@ -194,7 +206,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -208,7 +220,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -221,10 +233,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -245,10 +257,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -290,29 +302,29 @@ partial class Composition " <>\n" + " }\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TrackingDisposableInstancesScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Basics.TrackingDisposableInstancesScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -325,7 +337,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Basics.TrackingDisposableInstancesScenario.IService Resolve(Composition composition) { diff --git a/readme/transient.md b/readme/transient.md index 9701f6811..3a6a81fc2 100644 --- a/readme/transient.md +++ b/readme/transient.md @@ -65,7 +65,7 @@ classDiagram } Service *-- Dependency : IDependency Service *-- Dependency : IDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -75,7 +75,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -83,7 +83,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Lifetimes.TransientScenario.IService>() ///
/// /// Provides a composition root of type . @@ -91,6 +91,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -98,21 +99,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -121,10 +123,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Lifetimes.TransientScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -148,7 +160,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -162,7 +174,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -175,10 +187,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -199,10 +211,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -243,29 +255,29 @@ partial class Composition " }\n" + " Service *-- Dependency : IDependency\n" + " Service *-- Dependency : IDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.TransientScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Lifetimes.TransientScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -278,7 +290,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Lifetimes.TransientScenario.IService Resolve(Composition composition) { diff --git a/readme/tuple.md b/readme/tuple.md index 790bc629b..c706c8aae 100644 --- a/readme/tuple.md +++ b/readme/tuple.md @@ -63,7 +63,7 @@ classDiagram ValueTupleᐸPointˏIDependencyᐳ *-- Point : Point ValueTupleᐸPointˏIDependencyᐳ *-- Dependency : IDependency Service *-- ValueTupleᐸPointˏIDependencyᐳ : ValueTupleᐸPointˏIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -73,7 +73,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -81,7 +81,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.TupleScenario.IService>() ///
/// /// Provides a composition root of type . @@ -89,6 +89,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -96,21 +97,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -119,10 +121,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.TupleScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -130,8 +142,8 @@ partial class Composition #endif get { - Pure.DI.UsageTests.BCL.TupleScenario.Point transientM03D12di2_Point = new Point(7, 9); - return new Pure.DI.UsageTests.BCL.TupleScenario.Service((transientM03D12di2_Point, new Pure.DI.UsageTests.BCL.TupleScenario.Dependency())); + Pure.DI.UsageTests.BCL.TupleScenario.Point transientM03D13di2_Point = new Point(7, 9); + return new Pure.DI.UsageTests.BCL.TupleScenario.Service((transientM03D13di2_Point, new Pure.DI.UsageTests.BCL.TupleScenario.Dependency())); } } #endregion @@ -147,7 +159,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -161,7 +173,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -174,10 +186,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -198,10 +210,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -247,29 +259,29 @@ partial class Composition " ValueTupleᐸPointˏIDependencyᐳ *-- Point : Point\n" + " ValueTupleᐸPointˏIDependencyᐳ *-- Dependency : IDependency\n" + " Service *-- ValueTupleᐸPointˏIDependencyᐳ : ValueTupleᐸPointˏIDependencyᐳ\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.TupleScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.TupleScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -282,7 +294,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.TupleScenario.IService Resolve(Composition composition) { diff --git a/readme/type-attribute.md b/readme/type-attribute.md index a1cf2f5a4..9a2abfda4 100644 --- a/readme/type-attribute.md +++ b/readme/type-attribute.md @@ -66,7 +66,7 @@ classDiagram } Service *-- AbcDependency : AbcDependency Service *-- XyzDependency : XyzDependency - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -76,7 +76,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -84,7 +84,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.Attributes.TypeAttributeScenario.IService>() ///
/// /// Provides a composition root of type . @@ -92,6 +92,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -99,21 +100,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -122,10 +124,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.Attributes.TypeAttributeScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -149,7 +161,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -163,7 +175,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -176,10 +188,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -200,10 +212,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -243,29 +255,29 @@ partial class Composition " }\n" + " Service *-- AbcDependency : AbcDependency\n" + " Service *-- XyzDependency : XyzDependency\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Attributes.TypeAttributeScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.Attributes.TypeAttributeScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -278,7 +290,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.Attributes.TypeAttributeScenario.IService Resolve(Composition composition) { diff --git a/readme/valuetask.md b/readme/valuetask.md index 644d9d217..6e2800ac9 100644 --- a/readme/valuetask.md +++ b/readme/valuetask.md @@ -64,7 +64,7 @@ classDiagram <> } Service *-- ValueTaskᐸIDependencyᐳ : ValueTaskᐸIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ValueTaskᐸIDependencyᐳ *-- Dependency : IDependency ``` @@ -75,7 +75,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -83,7 +83,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.ValueTaskScenario.IService>() ///
/// /// Provides a composition root of type . @@ -91,6 +91,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -98,21 +99,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -121,10 +123,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.ValueTaskScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -132,12 +144,12 @@ partial class Composition #endif get { - System.Threading.Tasks.ValueTask transientM03D12di1_ValueTask; + System.Threading.Tasks.ValueTask transientM03D13di1_ValueTask; { - var value_M03D12di1 = new Pure.DI.UsageTests.BCL.ValueTaskScenario.Dependency(); - transientM03D12di1_ValueTask = new global::System.Threading.Tasks.ValueTask(value_M03D12di1); + var value_M03D13di1 = new Pure.DI.UsageTests.BCL.ValueTaskScenario.Dependency(); + transientM03D13di1_ValueTask = new global::System.Threading.Tasks.ValueTask(value_M03D13di1); } - return new Pure.DI.UsageTests.BCL.ValueTaskScenario.Service(transientM03D12di1_ValueTask); + return new Pure.DI.UsageTests.BCL.ValueTaskScenario.Service(transientM03D13di1_ValueTask); } } #endregion @@ -153,7 +165,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -167,7 +179,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -180,10 +192,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -204,10 +216,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -248,30 +260,30 @@ partial class Composition " <>\n" + " }\n" + " Service *-- ValueTaskᐸIDependencyᐳ : ValueTaskᐸIDependencyᐳ\n" + - " Composition ..> Service : IService Root\n" + + " Composition ..> Service : IService Root
provides IService\n" + " ValueTaskᐸIDependencyᐳ *-- Dependency : IDependency"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ValueTaskScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.ValueTaskScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -284,7 +296,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.ValueTaskScenario.IService Resolve(Composition composition) { diff --git a/readme/weak-reference.md b/readme/weak-reference.md index 1d3a3dbed..c404fb9aa 100644 --- a/readme/weak-reference.md +++ b/readme/weak-reference.md @@ -56,7 +56,7 @@ classDiagram } WeakReferenceᐸIDependencyᐳ *-- Dependency : IDependency Service *-- WeakReferenceᐸIDependencyᐳ : WeakReferenceᐸIDependencyᐳ - Composition ..> Service : IService Root + Composition ..> Service : IService Root
provides IService ``` @@ -66,7 +66,7 @@ classDiagram ```c# /// -/// Composition roots:
+/// Composition roots
/// /// /// Root @@ -74,7 +74,7 @@ classDiagram /// /// /// -/// Root +///
or using method: Resolve<Pure.DI.UsageTests.BCL.WeakReferenceScenario.IService>() ///
/// /// Provides a composition root of type . @@ -82,6 +82,7 @@ classDiagram ///
///
///
+///
/// /// This shows how to get an instance of type using the composition root : /// @@ -89,21 +90,22 @@ classDiagram /// var instance = composition.Root; /// /// -/// Class diagram
+/// Class diagram
/// This class was created by Pure.DI source code generator. -///
/// +/// +/// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class Composition { - private readonly Composition _rootM03D12di; + private readonly Composition _rootM03D13di; /// /// This constructor creates a new instance of . /// public Composition() { - _rootM03D12di = this; + _rootM03D13di = this; } /// @@ -112,10 +114,20 @@ partial class Composition /// Base composition. internal Composition(Composition baseComposition) { - _rootM03D12di = baseComposition._rootM03D12di; + _rootM03D13di = baseComposition._rootM03D13di; } #region Composition Roots + /// + /// Provides a composition root of type . + /// + /// + /// This shows how to get an instance of type : + /// + /// var composition = new Composition(); + /// var instance = composition.Root; + /// + /// public Pure.DI.UsageTests.BCL.WeakReferenceScenario.IService Root { #if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER || NET @@ -139,7 +151,7 @@ partial class Composition #endif public T Resolve() { - return ResolverM03D12di.Value.Resolve(this); + return ResolverM03D13di.Value.Resolve(this); } /// @@ -153,7 +165,7 @@ partial class Composition #endif public T Resolve(object? tag) { - return ResolverM03D12di.Value.ResolveByTag(this, tag); + return ResolverM03D13di.Value.ResolveByTag(this, tag); } /// @@ -166,10 +178,10 @@ partial class Composition #endif public object Resolve(global::System.Type type) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); @@ -190,10 +202,10 @@ partial class Composition #endif public object Resolve(global::System.Type type, object? tag) { - var index = (int)(_bucketSizeM03D12di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - var finish = index + _bucketSizeM03D12di; + var index = (int)(_bucketSizeM03D13di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM03D13di; do { - ref var pair = ref _bucketsM03D12di[index]; + ref var pair = ref _bucketsM03D13di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); @@ -237,29 +249,29 @@ partial class Composition " }\n" + " WeakReferenceᐸIDependencyᐳ *-- Dependency : IDependency\n" + " Service *-- WeakReferenceᐸIDependencyᐳ : WeakReferenceᐸIDependencyᐳ\n" + - " Composition ..> Service : IService Root"; + " Composition ..> Service : IService Root
provides IService"; } - private readonly static int _bucketSizeM03D12di; - private readonly static global::Pure.DI.Pair>[] _bucketsM03D12di; + private readonly static int _bucketSizeM03D13di; + private readonly static global::Pure.DI.Pair>[] _bucketsM03D13di; static Composition() { - var valResolverM03D12di_0000 = new ResolverM03D12di_0000(); - ResolverM03D12di.Value = valResolverM03D12di_0000; - _bucketsM03D12di = global::Pure.DI.Buckets>.Create( + var valResolverM03D13di_0000 = new ResolverM03D13di_0000(); + ResolverM03D13di.Value = valResolverM03D13di_0000; + _bucketsM03D13di = global::Pure.DI.Buckets>.Create( 1, - out _bucketSizeM03D12di, + out _bucketSizeM03D13di, new global::Pure.DI.Pair>[1] { - new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.WeakReferenceScenario.IService), valResolverM03D12di_0000) + new global::Pure.DI.Pair>(typeof(Pure.DI.UsageTests.BCL.WeakReferenceScenario.IService), valResolverM03D13di_0000) }); } #region Resolvers - private sealed class ResolverM03D12di: global::Pure.DI.IResolver + private sealed class ResolverM03D13di: global::Pure.DI.IResolver { - public static global::Pure.DI.IResolver Value = new ResolverM03D12di(); + public static global::Pure.DI.IResolver Value = new ResolverM03D13di(); public T Resolve(Composition composite) { @@ -272,7 +284,7 @@ partial class Composition } } - private sealed class ResolverM03D12di_0000: global::Pure.DI.IResolver + private sealed class ResolverM03D13di_0000: global::Pure.DI.IResolver { public Pure.DI.UsageTests.BCL.WeakReferenceScenario.IService Resolve(Composition composition) { diff --git a/src/Pure.DI.Core/Core/Code/ClassDiagramBuilder.cs b/src/Pure.DI.Core/Core/Code/ClassDiagramBuilder.cs index 1bd0d56b2..27e852400 100644 --- a/src/Pure.DI.Core/Core/Code/ClassDiagramBuilder.cs +++ b/src/Pure.DI.Core/Core/Code/ClassDiagramBuilder.cs @@ -27,20 +27,7 @@ public LinesBuilder Build(CompositionCode composition) { foreach (var root in composition.Roots.OrderByDescending(i => i.IsPublic).ThenBy(i => i.Name)) { - var typeArgsStr = ""; - var typeArgs = root.TypeDescription.TypeArgs; - if (typeArgs.Count > 0) - { - typeArgsStr = $"{DefaultFormatOptions.StartGenericArgsSymbol}{string.Join(DefaultFormatOptions.TypeArgsSeparator, typeArgs.Select(arg => $"{arg}"))}{DefaultFormatOptions.FinishGenericArgsSymbol}"; - } - - var rootArgsStr = ""; - if (root.IsMethod) - { - rootArgsStr = $"({string.Join(", ", root.Args.Select(arg => $"{typeResolver.Resolve(arg.InstanceType)} {arg.VariableName}"))})"; - } - - lines.AppendLine($"{(root.IsPublic ? "+" : "-")}{FormatType(root.Injection.Type, DefaultFormatOptions)} {root.DisplayName}{typeArgsStr}{rootArgsStr}"); + lines.AppendLine($"{(root.IsPublic ? "+" : "-")}{FormatRoot(root)}"); } if (hasResolveMethods) @@ -132,7 +119,7 @@ public LinesBuilder Build(CompositionCode composition) cancellationToken.ThrowIfCancellationRequested(); if (dependency.Target.Root is not null && rootProperties.TryGetValue(dependency.Injection, out var root)) { - lines.AppendLine($"{composition.Source.Source.Name.ClassName} ..> {FormatType(dependency.Source.Type, DefaultFormatOptions)} : {FormatInjection(root.Injection, DefaultFormatOptions)} {root.DisplayName}"); + lines.AppendLine($"{composition.Source.Source.Name.ClassName} ..> {FormatType(dependency.Source.Type, DefaultFormatOptions)} : {FormatRoot(root)}
provides {FormatInjection(root.Injection, DefaultFormatOptions)}"); } else { @@ -158,7 +145,25 @@ public LinesBuilder Build(CompositionCode composition) return lines; } - private string FormatCardinality(Lifetime lifetime) => + private string FormatRoot(Root root) + { + var typeArgsStr = ""; + var typeArgs = root.TypeDescription.TypeArgs; + if (typeArgs.Count > 0) + { + typeArgsStr = $"{DefaultFormatOptions.StartGenericArgsSymbol}{string.Join(DefaultFormatOptions.TypeArgsSeparator, typeArgs.Select(arg => $"{arg}"))}{DefaultFormatOptions.FinishGenericArgsSymbol}"; + } + + var rootArgsStr = ""; + if (root.IsMethod) + { + rootArgsStr = $"({string.Join(", ", root.Args.Select(arg => $"{typeResolver.Resolve(arg.InstanceType)} {arg.VariableName}"))})"; + } + + return $"{FormatType(root.Injection.Type, DefaultFormatOptions)} {root.DisplayName}{typeArgsStr}{rootArgsStr}"; + } + + private static string FormatCardinality(Lifetime lifetime) => lifetime switch { Lifetime.Transient => "",