diff --git a/Directory.Build.props b/Directory.Build.props index 8eedd821..e3ba1206 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 2.1.33 + 2.1.34 Pure.DI latest net8.0 diff --git a/readme/Avalonia.md b/readme/Avalonia.md index c44b7d4b..3e8ff0f4 100644 --- a/readme/Avalonia.md +++ b/readme/Avalonia.md @@ -122,7 +122,7 @@ The [project file](/samples/AvaloniaApp/AvaloniaApp.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/BlazorServerApp.md b/readme/BlazorServerApp.md index e645c3d9..0a0cdf42 100644 --- a/readme/BlazorServerApp.md +++ b/readme/BlazorServerApp.md @@ -67,7 +67,7 @@ The [project file](/samples/BlazorServerApp/BlazorServerApp.csproj) looks like t - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/BlazorWebAssemblyApp.md b/readme/BlazorWebAssemblyApp.md index 476df757..a064d6ae 100644 --- a/readme/BlazorWebAssemblyApp.md +++ b/readme/BlazorWebAssemblyApp.md @@ -66,7 +66,7 @@ The [project file](/samples/BlazorWebAssemblyApp/BlazorWebAssemblyApp.csproj) lo - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/Console.md b/readme/Console.md index 986a5ab0..33f4d366 100644 --- a/readme/Console.md +++ b/readme/Console.md @@ -85,7 +85,7 @@ The [project file](/samples/ShroedingersCat/ShroedingersCat.csproj) looks like t - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/ConsoleNativeAOT.md b/readme/ConsoleNativeAOT.md index 90dacb3f..9e08fddd 100644 --- a/readme/ConsoleNativeAOT.md +++ b/readme/ConsoleNativeAOT.md @@ -16,7 +16,7 @@ The [project file](/samples/ShroedingersCatNativeAOT/ShroedingersCatNativeAOT.cs - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/ConsoleTopLevelStatements.md b/readme/ConsoleTopLevelStatements.md index 8af9d2bf..86532e92 100644 --- a/readme/ConsoleTopLevelStatements.md +++ b/readme/ConsoleTopLevelStatements.md @@ -74,7 +74,7 @@ The [project file](/samples/ShroedingersCatTopLevelStatements/ShroedingersCatTop - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/FuncDetails.md b/readme/FuncDetails.md index 872afaf2..85ea3160 100644 --- a/readme/FuncDetails.md +++ b/readme/FuncDetails.md @@ -79,7 +79,8 @@ partial class Func [MethodImpl(MethodImplOptions.AggressiveInlining)] public partial CompositionRoot TestPureDIByCR() { - Func perBlockFunc10 = new Func( + var perBlockFunc10 = default(Func); + perBlockFunc10 = new Func( [MethodImpl(MethodImplOptions.AggressiveInlining)] () => { diff --git a/readme/GrpcService.md b/readme/GrpcService.md index c454ed8f..e9eb2ceb 100644 --- a/readme/GrpcService.md +++ b/readme/GrpcService.md @@ -52,7 +52,7 @@ The [project file](/samples/GrpcService/GrpcService.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/Maui.md b/readme/Maui.md index 3096ec65..bc0e48b9 100644 --- a/readme/Maui.md +++ b/readme/Maui.md @@ -208,7 +208,7 @@ The [project file](/samples/MAUIApp/MAUIApp.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/MinimalWebAPI.md b/readme/MinimalWebAPI.md index d1b8b971..a02ff20b 100644 --- a/readme/MinimalWebAPI.md +++ b/readme/MinimalWebAPI.md @@ -75,7 +75,7 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/SingletonDetails.md b/readme/SingletonDetails.md index 68813fd7..9a603ae5 100644 --- a/readme/SingletonDetails.md +++ b/readme/SingletonDetails.md @@ -63,8 +63,8 @@ partial class Singleton { private readonly Singleton _root; - private Service1? _scopedService140; - private Service4? _scopedService443; + private Service1? _scopedService139; + private Service4? _scopedService442; [OrdinalAttribute(20)] public Singleton() @@ -80,22 +80,22 @@ partial class Singleton [MethodImpl(MethodImplOptions.AggressiveInlining)] public partial CompositionRoot TestPureDIByCR() { - if (_scopedService443 == null) + if (_scopedService442 == null) { - _scopedService443 = new Service4(); + _scopedService442 = new Service4(); } - if (_scopedService140 == null) + if (_scopedService139 == null) { - if (_scopedService443 == null) + if (_scopedService442 == null) { - _scopedService443 = new Service4(); + _scopedService442 = new Service4(); } - _scopedService140 = new Service1(new Service2(new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!))); + _scopedService139 = new Service1(new Service2(new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!))); } - return new CompositionRoot(_scopedService140!, new Service2(new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!)), new Service2(new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!)), new Service2(new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!), new Service3(_scopedService443!, _scopedService443!)), new Service3(_scopedService443!, _scopedService443!), _scopedService443!, _scopedService443!); + return new CompositionRoot(_scopedService139!, new Service2(new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!)), new Service2(new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!)), new Service2(new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!), new Service3(_scopedService442!, _scopedService442!)), new Service3(_scopedService442!, _scopedService442!), _scopedService442!, _scopedService442!); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/readme/WebAPI.md b/readme/WebAPI.md index 2b431688..3fb81b2e 100644 --- a/readme/WebAPI.md +++ b/readme/WebAPI.md @@ -50,7 +50,7 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/WebApp.md b/readme/WebApp.md index 3ae1a242..aa42de45 100644 --- a/readme/WebApp.md +++ b/readme/WebApp.md @@ -50,7 +50,7 @@ The [project file](/samples/WebApp/WebApp.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/WinFormsApp.md b/readme/WinFormsApp.md index 313cb76f..0ca74d9a 100644 --- a/readme/WinFormsApp.md +++ b/readme/WinFormsApp.md @@ -57,7 +57,7 @@ The [project file](/samples/WinFormsApp/WinFormsApp.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/WinFormsAppNetCore.md b/readme/WinFormsAppNetCore.md index b4117c4f..f050102b 100644 --- a/readme/WinFormsAppNetCore.md +++ b/readme/WinFormsAppNetCore.md @@ -63,7 +63,7 @@ The [project file](/samples/WinFormsAppNetCore/WinFormsAppNetCore.csproj) looks - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/Wpf.md b/readme/Wpf.md index faad294d..225140fe 100644 --- a/readme/Wpf.md +++ b/readme/Wpf.md @@ -68,7 +68,7 @@ The [project file](/samples/WpfAppNetCore/WpfAppNetCore.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/async-disposable-scope.md b/readme/async-disposable-scope.md index 3d03d905..d683fb6a 100644 --- a/readme/async-disposable-scope.md +++ b/readme/async-disposable-scope.md @@ -136,24 +136,14 @@ partial class Composition: IDisposable, IAsyncDisposable [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perResolveFunc47 = default(Func); - if (perResolveFunc47 == null) + var perBlockFunc1 = default(Func ); + perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc47 == null) - { - perResolveFunc47 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - Composition transientComposition2 = this; - Session localValue63 = new Session(transientComposition2); - return localValue63; - }); - } - } - } - - return new Program(perResolveFunc47!); + Composition transientComposition3 = this; + Session localValue63 = new Session(transientComposition3); + return localValue63; + }); + return new Program(perBlockFunc1); } } @@ -267,7 +257,7 @@ classDiagram <> } Session *-- Composition : Composition - Program o-- "PerResolve" FuncᐸSessionᐳ : FuncᐸSessionᐳ + Program o-- "PerBlock" FuncᐸSessionᐳ : FuncᐸSessionᐳ Composition ..> Program : Program ProgramRoot Composition ..> Service : IService SessionRoot Service o-- "Scoped" Dependency : IDependency diff --git a/readme/async-root.md b/readme/async-root.md index dc980296..e99f1d16 100644 --- a/readme/async-root.md +++ b/readme/async-root.md @@ -35,52 +35,39 @@ The following partial class will be generated: partial class Composition { private readonly Composition _root; - private readonly object _lock; [OrdinalAttribute(10)] public Composition() { _root = this; - _lock = new object(); } internal Composition(Composition parentScope) { _root = (parentScope ?? throw new ArgumentNullException(nameof(parentScope)))._root; - _lock = _root._lock; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Task GetMyServiceAsync(CancellationToken cancellationToken) { - var perResolveFunc45 = default(Func); - TaskScheduler transientTaskScheduler4 = TaskScheduler.Default; - TaskContinuationOptions transientTaskContinuationOptions3 = TaskContinuationOptions.None; - TaskCreationOptions transientTaskCreationOptions2 = TaskCreationOptions.None; - TaskFactory perBlockTaskFactory1; + TaskScheduler transientTaskScheduler5 = TaskScheduler.Default; + TaskContinuationOptions transientTaskContinuationOptions4 = TaskContinuationOptions.None; + TaskCreationOptions transientTaskCreationOptions3 = TaskCreationOptions.None; + TaskFactory perBlockTaskFactory2; CancellationToken localCancellationToken17 = cancellationToken; - TaskCreationOptions localTaskCreationOptions18 = transientTaskCreationOptions2; - TaskContinuationOptions localTaskContinuationOptions19 = transientTaskContinuationOptions3; - TaskScheduler localTaskScheduler20 = transientTaskScheduler4; - perBlockTaskFactory1 = new TaskFactory(localCancellationToken17, localTaskCreationOptions18, localTaskContinuationOptions19, localTaskScheduler20); - if (perResolveFunc45 == null) + TaskCreationOptions localTaskCreationOptions18 = transientTaskCreationOptions3; + TaskContinuationOptions localTaskContinuationOptions19 = transientTaskContinuationOptions4; + TaskScheduler localTaskScheduler20 = transientTaskScheduler5; + perBlockTaskFactory2 = new TaskFactory(localCancellationToken17, localTaskCreationOptions18, localTaskContinuationOptions19, localTaskScheduler20); + var perBlockFunc1 = default(Func ); + perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc45 == null) - { - perResolveFunc45 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - IService localValue21 = new Service(new Dependency()); - return localValue21; - }); - } - } - } - + IService localValue21 = new Service(new Dependency()); + return localValue21; + }); Task transientTask0; - Func localFactory22 = perResolveFunc45!; - TaskFactory localTaskFactory23 = perBlockTaskFactory1; + Func localFactory22 = perBlockFunc1; + TaskFactory localTaskFactory23 = perBlockTaskFactory2; transientTask0 = localTaskFactory23.StartNew(localFactory22); return transientTask0; } @@ -122,7 +109,7 @@ classDiagram TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions TaskFactory *-- TaskScheduler : TaskScheduler Service *-- Dependency : IDependency - TaskᐸIServiceᐳ o-- "PerResolve" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ + TaskᐸIServiceᐳ o-- "PerBlock" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ TaskᐸIServiceᐳ o-- "PerBlock" TaskFactoryᐸIServiceᐳ : TaskFactoryᐸIServiceᐳ FuncᐸIServiceᐳ *-- Service : IService TaskFactoryᐸIServiceᐳ o-- CancellationToken : Argument "cancellationToken" diff --git a/readme/auto-scoped.md b/readme/auto-scoped.md index 3ad456cb..ca1f15b3 100644 --- a/readme/auto-scoped.md +++ b/readme/auto-scoped.md @@ -95,29 +95,19 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perResolveFunc46 = default(Func); - if (perResolveFunc46 == null) + var perBlockFunc1 = default(Func ); + perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc46 == null) - { - perResolveFunc46 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - Composition transientComposition2 = this; - IService transientIService1; - Composition localBaseComposition65 = transientComposition2; - // Creates a session - var localSession66= new Composition(localBaseComposition65); - transientIService1 = localSession66.SessionRoot; - IService localValue64 = transientIService1; - return localValue64; - }); - } - } - } - - return new Program(perResolveFunc46!); + Composition transientComposition3 = this; + IService transientIService2; + Composition localBaseComposition65 = transientComposition3; + // Creates a session + var localSession66= new Composition(localBaseComposition65); + transientIService2 = localSession66.SessionRoot; + IService localValue64 = transientIService2; + return localValue64; + }); + return new Program(perBlockFunc1); } } @@ -169,7 +159,7 @@ classDiagram <> } Service o-- "Scoped" Dependency : IDependency - Program o-- "PerResolve" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ + Program o-- "PerBlock" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ Composition ..> Program : Program ProgramRoot Composition ..> Service : Service SessionRoot IService *-- Composition : Composition diff --git a/readme/func-with-arguments.md b/readme/func-with-arguments.md index dcb23dac..b310412d 100644 --- a/readme/func-with-arguments.md +++ b/readme/func-with-arguments.md @@ -109,7 +109,8 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - Func transientFunc1 = + var transientFunc1 = default(Func); + transientFunc1 = [MethodImpl(MethodImplOptions.AggressiveInlining)] (dependencyId, subId) => { diff --git a/readme/func-with-tag.md b/readme/func-with-tag.md index d72ce9c7..d2e0a4cf 100644 --- a/readme/func-with-tag.md +++ b/readme/func-with-tag.md @@ -42,19 +42,16 @@ The following partial class will be generated: partial class Composition { private readonly Composition _root; - private readonly object _lock; [OrdinalAttribute(20)] public Composition() { _root = this; - _lock = new object(); } internal Composition(Composition parentScope) { _root = (parentScope ?? throw new ArgumentNullException(nameof(parentScope)))._root; - _lock = _root._lock; } public IService Root @@ -62,23 +59,13 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perResolveFunc42 = default(Func); - if (perResolveFunc42 == null) + var perBlockFunc1 = default(Func ); + perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc42 == null) - { - perResolveFunc42 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - IDependency localValue32 = new Dependency(); - return localValue32; - }); - } - } - } - - return new Service(perResolveFunc42!); + IDependency localValue32 = new Dependency(); + return localValue32; + }); + return new Service(perBlockFunc1); } } @@ -226,7 +213,7 @@ classDiagram <> } Composition ..> Service : IService Root - Service o-- "PerResolve" FuncᐸIDependencyᐳ : "my tag" FuncᐸIDependencyᐳ + Service o-- "PerBlock" FuncᐸIDependencyᐳ : "my tag" FuncᐸIDependencyᐳ FuncᐸIDependencyᐳ *-- Dependency : "my tag" IDependency ``` diff --git a/readme/func.md b/readme/func.md index 40d5f9db..26997d00 100644 --- a/readme/func.md +++ b/readme/func.md @@ -45,19 +45,16 @@ The following partial class will be generated: partial class Composition { private readonly Composition _root; - private readonly object _lock; [OrdinalAttribute(20)] public Composition() { _root = this; - _lock = new object(); } internal Composition(Composition parentScope) { _root = (parentScope ?? throw new ArgumentNullException(nameof(parentScope)))._root; - _lock = _root._lock; } public IService Root @@ -65,23 +62,13 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perResolveFunc42 = default(Func); - if (perResolveFunc42 == null) + var perBlockFunc1 = default(Func ); + perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc42 == null) - { - perResolveFunc42 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - IDependency localValue30 = new Dependency(); - return localValue30; - }); - } - } - } - - return new Service(perResolveFunc42!); + IDependency localValue30 = new Dependency(); + return localValue30; + }); + return new Service(perBlockFunc1); } } @@ -229,7 +216,7 @@ classDiagram <> } Composition ..> Service : IService Root - Service o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ + Service o-- "PerBlock" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ FuncᐸIDependencyᐳ *-- Dependency : IDependency ``` diff --git a/readme/generic-async-composition-roots-with-constraints.md b/readme/generic-async-composition-roots-with-constraints.md index f698cba4..ffe5c48a 100644 --- a/readme/generic-async-composition-roots-with-constraints.md +++ b/readme/generic-async-composition-roots-with-constraints.md @@ -68,56 +68,43 @@ The following partial class will be generated: partial class Composition { private readonly Composition _root; - private readonly object _lock; [OrdinalAttribute(10)] public Composition() { _root = this; - _lock = new object(); } internal Composition(Composition parentScope) { _root = (parentScope ?? throw new ArgumentNullException(nameof(parentScope)))._root; - _lock = _root._lock; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Task> GetOtherServiceAsync(CancellationToken cancellationToken) where T: IDisposable { - var perResolveFunc48 = default(Func>); - TaskScheduler transientTaskScheduler4 = TaskScheduler.Default; - TaskContinuationOptions transientTaskContinuationOptions3 = TaskContinuationOptions.None; - TaskCreationOptions transientTaskCreationOptions2 = TaskCreationOptions.None; - TaskFactory> perBlockTaskFactory1; + TaskScheduler transientTaskScheduler5 = TaskScheduler.Default; + TaskContinuationOptions transientTaskContinuationOptions4 = TaskContinuationOptions.None; + TaskCreationOptions transientTaskCreationOptions3 = TaskCreationOptions.None; + TaskFactory> perBlockTaskFactory2; CancellationToken localCancellationToken46 = cancellationToken; - TaskCreationOptions localTaskCreationOptions47 = transientTaskCreationOptions2; - TaskContinuationOptions localTaskContinuationOptions48 = transientTaskContinuationOptions3; - TaskScheduler localTaskScheduler49 = transientTaskScheduler4; - perBlockTaskFactory1 = new TaskFactory>(localCancellationToken46, localTaskCreationOptions47, localTaskContinuationOptions48, localTaskScheduler49); - if (perResolveFunc48 == null) + TaskCreationOptions localTaskCreationOptions47 = transientTaskCreationOptions3; + TaskContinuationOptions localTaskContinuationOptions48 = transientTaskContinuationOptions4; + TaskScheduler localTaskScheduler49 = transientTaskScheduler5; + perBlockTaskFactory2 = new TaskFactory>(localCancellationToken46, localTaskCreationOptions47, localTaskContinuationOptions48, localTaskScheduler49); + var perBlockFunc1 = default(Func> ); + perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc48 == null) - { - perResolveFunc48 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - OtherService transientOtherService5; - IDependency localDependency51 = new Dependency(); - transientOtherService5 = new OtherService(localDependency51); - IService localValue50 = transientOtherService5; - return localValue50; - }); - } - } - } - + OtherService transientOtherService6; + IDependency localDependency51 = new Dependency(); + transientOtherService6 = new OtherService(localDependency51); + IService localValue50 = transientOtherService6; + return localValue50; + }); Task> transientTask0; - Func> localFactory52 = perResolveFunc48!; - TaskFactory> localTaskFactory53 = perBlockTaskFactory1; + Func> localFactory52 = perBlockFunc1; + TaskFactory> localTaskFactory53 = perBlockTaskFactory2; transientTask0 = localTaskFactory53.StartNew(localFactory52); return transientTask0; } @@ -127,34 +114,24 @@ partial class Composition where T: IDisposable where T1: struct { - var perResolveFunc50 = default(Func>); - TaskScheduler transientTaskScheduler4 = TaskScheduler.Default; - TaskContinuationOptions transientTaskContinuationOptions3 = TaskContinuationOptions.None; - TaskCreationOptions transientTaskCreationOptions2 = TaskCreationOptions.None; - TaskFactory> perBlockTaskFactory1; + TaskScheduler transientTaskScheduler5 = TaskScheduler.Default; + TaskContinuationOptions transientTaskContinuationOptions4 = TaskContinuationOptions.None; + TaskCreationOptions transientTaskCreationOptions3 = TaskCreationOptions.None; + TaskFactory> perBlockTaskFactory2; CancellationToken localCancellationToken54 = cancellationToken; - TaskCreationOptions localTaskCreationOptions55 = transientTaskCreationOptions2; - TaskContinuationOptions localTaskContinuationOptions56 = transientTaskContinuationOptions3; - TaskScheduler localTaskScheduler57 = transientTaskScheduler4; - perBlockTaskFactory1 = new TaskFactory>(localCancellationToken54, localTaskCreationOptions55, localTaskContinuationOptions56, localTaskScheduler57); - if (perResolveFunc50 == null) + TaskCreationOptions localTaskCreationOptions55 = transientTaskCreationOptions3; + TaskContinuationOptions localTaskContinuationOptions56 = transientTaskContinuationOptions4; + TaskScheduler localTaskScheduler57 = transientTaskScheduler5; + perBlockTaskFactory2 = new TaskFactory>(localCancellationToken54, localTaskCreationOptions55, localTaskContinuationOptions56, localTaskScheduler57); + var perBlockFunc1 = default(Func> ); + perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc50 == null) - { - perResolveFunc50 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - IService localValue58 = new Service(new Dependency()); - return localValue58; - }); - } - } - } - + IService localValue58 = new Service(new Dependency()); + return localValue58; + }); Task> transientTask0; - Func> localFactory59 = perResolveFunc50!; - TaskFactory> localTaskFactory60 = perBlockTaskFactory1; + Func> localFactory59 = perBlockFunc1; + TaskFactory> localTaskFactory60 = perBlockTaskFactory2; transientTask0 = localTaskFactory60.StartNew(localFactory59); return transientTask0; } @@ -204,9 +181,9 @@ classDiagram TaskFactory *-- TaskCreationOptions : TaskCreationOptions TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions TaskFactory *-- TaskScheduler : TaskScheduler - TaskᐸIServiceᐸTˏBooleanᐳᐳ o-- "PerResolve" FuncᐸIServiceᐸTˏBooleanᐳᐳ : "Other" FuncᐸIServiceᐸTˏBooleanᐳᐳ + TaskᐸIServiceᐸTˏBooleanᐳᐳ o-- "PerBlock" FuncᐸIServiceᐸTˏBooleanᐳᐳ : "Other" FuncᐸIServiceᐸTˏBooleanᐳᐳ TaskᐸIServiceᐸTˏBooleanᐳᐳ o-- "PerBlock" TaskFactoryᐸIServiceᐸTˏBooleanᐳᐳ : TaskFactoryᐸIServiceᐸTˏBooleanᐳᐳ - TaskᐸIServiceᐸTˏT1ᐳᐳ o-- "PerResolve" FuncᐸIServiceᐸTˏT1ᐳᐳ : FuncᐸIServiceᐸTˏT1ᐳᐳ + TaskᐸIServiceᐸTˏT1ᐳᐳ o-- "PerBlock" FuncᐸIServiceᐸTˏT1ᐳᐳ : FuncᐸIServiceᐸTˏT1ᐳᐳ TaskᐸIServiceᐸTˏT1ᐳᐳ o-- "PerBlock" TaskFactoryᐸIServiceᐸTˏT1ᐳᐳ : TaskFactoryᐸIServiceᐸTˏT1ᐳᐳ FuncᐸIServiceᐸTˏBooleanᐳᐳ *-- OtherServiceᐸTᐳ : "Other" IServiceᐸTˏBooleanᐳ TaskFactoryᐸIServiceᐸTˏBooleanᐳᐳ o-- CancellationToken : Argument "cancellationToken" diff --git a/readme/lazy.md b/readme/lazy.md index 83ca1370..a153daa0 100644 --- a/readme/lazy.md +++ b/readme/lazy.md @@ -36,19 +36,16 @@ The following partial class will be generated: partial class Composition { private readonly Composition _root; - private readonly object _lock; [OrdinalAttribute(20)] public Composition() { _root = this; - _lock = new object(); } internal Composition(Composition parentScope) { _root = (parentScope ?? throw new ArgumentNullException(nameof(parentScope)))._root; - _lock = _root._lock; } public IService Root @@ -56,24 +53,14 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perResolveFunc43 = default(Func); - if (perResolveFunc43 == null) + var perBlockFunc2 = default(Func ); + perBlockFunc2 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc43 == null) - { - perResolveFunc43 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - IDependency localValue33 = new Dependency(); - return localValue33; - }); - } - } - } - + IDependency localValue33 = new Dependency(); + return localValue33; + }); Lazy transientLazy1; - Func localFactory34 = perResolveFunc43!; + Func localFactory34 = perBlockFunc2; transientLazy1 = new Lazy(localFactory34, true); return new Service(transientLazy1); } @@ -225,7 +212,7 @@ classDiagram } Composition ..> Service : IService Root Service *-- LazyᐸIDependencyᐳ : LazyᐸIDependencyᐳ - LazyᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ + LazyᐸIDependencyᐳ o-- "PerBlock" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ FuncᐸIDependencyᐳ *-- Dependency : IDependency ``` diff --git a/readme/manually-started-tasks.md b/readme/manually-started-tasks.md index 4773c52c..ddf03255 100644 --- a/readme/manually-started-tasks.md +++ b/readme/manually-started-tasks.md @@ -76,42 +76,29 @@ The following partial class will be generated: partial class Composition { private readonly Composition _root; - private readonly object _lock; [OrdinalAttribute(10)] public Composition() { _root = this; - _lock = new object(); } internal Composition(Composition parentScope) { _root = (parentScope ?? throw new ArgumentNullException(nameof(parentScope)))._root; - _lock = _root._lock; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public IService GetRoot(CancellationToken cancellationToken) { - var perResolveFunc45 = default(Func); - if (perResolveFunc45 == null) + var perBlockFunc2 = default(Func ); + perBlockFunc2 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc45 == null) - { - perResolveFunc45 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - IDependency localValue35 = new Dependency(); - return localValue35; - }); - } - } - } - + IDependency localValue35 = new Dependency(); + return localValue35; + }); Task transientTask1; - Func localFactory36 = perResolveFunc45!; + Func localFactory36 = perBlockFunc2; CancellationToken localCancellationToken37 = cancellationToken; transientTask1 = new Task(localFactory36, localCancellationToken37); return new Service(transientTask1); @@ -151,7 +138,7 @@ classDiagram TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions TaskFactory *-- TaskScheduler : TaskScheduler Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ - TaskᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ + TaskᐸIDependencyᐳ o-- "PerBlock" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ TaskᐸIDependencyᐳ o-- CancellationToken : Argument "cancellationToken" FuncᐸIDependencyᐳ *-- Dependency : IDependency ``` diff --git a/readme/scope.md b/readme/scope.md index f739d59b..718b31cc 100644 --- a/readme/scope.md +++ b/readme/scope.md @@ -134,24 +134,14 @@ partial class Composition: IDisposable [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perResolveFunc47 = default(Func); - if (perResolveFunc47 == null) + var perBlockFunc1 = default(Func ); + perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc47 == null) - { - perResolveFunc47 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - Composition transientComposition2 = this; - Session localValue67 = new Session(transientComposition2); - return localValue67; - }); - } - } - } - - return new Program(perResolveFunc47!); + Composition transientComposition3 = this; + Session localValue67 = new Session(transientComposition3); + return localValue67; + }); + return new Program(perBlockFunc1); } } @@ -223,7 +213,7 @@ classDiagram <> } Session *-- Composition : Composition - Program o-- "PerResolve" FuncᐸSessionᐳ : FuncᐸSessionᐳ + Program o-- "PerBlock" FuncᐸSessionᐳ : FuncᐸSessionᐳ Composition ..> Program : Program ProgramRoot Composition ..> Service : IService SessionRoot Service o-- "Scoped" Dependency : IDependency diff --git a/readme/task.md b/readme/task.md index 2d61eb34..cb718587 100644 --- a/readme/task.md +++ b/readme/task.md @@ -64,52 +64,39 @@ The following partial class will be generated: partial class Composition { private readonly Composition _root; - private readonly object _lock; [OrdinalAttribute(10)] public Composition() { _root = this; - _lock = new object(); } internal Composition(Composition parentScope) { _root = (parentScope ?? throw new ArgumentNullException(nameof(parentScope)))._root; - _lock = _root._lock; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public IService GetRoot(CancellationToken cancellationToken) { - var perResolveFunc45 = default(Func); - TaskScheduler transientTaskScheduler5 = TaskScheduler.Current; - TaskContinuationOptions transientTaskContinuationOptions4 = TaskContinuationOptions.None; - TaskCreationOptions transientTaskCreationOptions3 = TaskCreationOptions.None; - TaskFactory perBlockTaskFactory2; + TaskScheduler transientTaskScheduler6 = TaskScheduler.Current; + TaskContinuationOptions transientTaskContinuationOptions5 = TaskContinuationOptions.None; + TaskCreationOptions transientTaskCreationOptions4 = TaskCreationOptions.None; + TaskFactory perBlockTaskFactory3; CancellationToken localCancellationToken38 = cancellationToken; - TaskCreationOptions localTaskCreationOptions39 = transientTaskCreationOptions3; - TaskContinuationOptions localTaskContinuationOptions40 = transientTaskContinuationOptions4; - TaskScheduler localTaskScheduler41 = transientTaskScheduler5; - perBlockTaskFactory2 = new TaskFactory(localCancellationToken38, localTaskCreationOptions39, localTaskContinuationOptions40, localTaskScheduler41); - if (perResolveFunc45 == null) + TaskCreationOptions localTaskCreationOptions39 = transientTaskCreationOptions4; + TaskContinuationOptions localTaskContinuationOptions40 = transientTaskContinuationOptions5; + TaskScheduler localTaskScheduler41 = transientTaskScheduler6; + perBlockTaskFactory3 = new TaskFactory(localCancellationToken38, localTaskCreationOptions39, localTaskContinuationOptions40, localTaskScheduler41); + var perBlockFunc2 = default(Func ); + perBlockFunc2 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - lock (_lock) - { - if (perResolveFunc45 == null) - { - perResolveFunc45 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - IDependency localValue42 = new Dependency(); - return localValue42; - }); - } - } - } - + IDependency localValue42 = new Dependency(); + return localValue42; + }); Task transientTask1; - Func localFactory43 = perResolveFunc45!; - TaskFactory localTaskFactory44 = perBlockTaskFactory2; + Func localFactory43 = perBlockFunc2; + TaskFactory localTaskFactory44 = perBlockTaskFactory3; transientTask1 = localTaskFactory44.StartNew(localFactory43); return new Service(transientTask1); } @@ -152,7 +139,7 @@ classDiagram TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions TaskFactory *-- TaskScheduler : TaskScheduler Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ - TaskᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ + TaskᐸIDependencyᐳ o-- "PerBlock" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ TaskᐸIDependencyᐳ o-- "PerBlock" TaskFactoryᐸIDependencyᐳ : TaskFactoryᐸIDependencyᐳ FuncᐸIDependencyᐳ *-- Dependency : IDependency TaskFactoryᐸIDependencyᐳ o-- CancellationToken : Argument "cancellationToken" diff --git a/readme/tracking-async-disposable-instances-in-delegates.md b/readme/tracking-async-disposable-instances-in-delegates.md index 71def56b..6a702e0e 100644 --- a/readme/tracking-async-disposable-instances-in-delegates.md +++ b/readme/tracking-async-disposable-instances-in-delegates.md @@ -96,38 +96,28 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perResolveFunc42 = default(Func>); var accumulator41 = new Owned(); - if (perResolveFunc42 == null) + var perBlockFunc1 = default(Func> ); + perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { + var accumulator41 = new Owned(); + Dependency transientDependency4 = new Dependency(); lock (_lock) { - if (perResolveFunc42 == null) - { - perResolveFunc42 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - var accumulator41 = new Owned(); - Dependency transientDependency3 = new Dependency(); - lock (_lock) - { - accumulator41.Add(transientDependency3); - } - Owned perBlockOwned1; - Owned localOwned8 = accumulator41; - IDependency localValue9 = transientDependency3; - perBlockOwned1 = new Owned(localValue9, localOwned8); - lock (_lock) - { - accumulator41.Add(perBlockOwned1); - } - Owned localValue7 = perBlockOwned1; - return localValue7; - }); - } + accumulator41.Add(transientDependency4); } - } - - Service transientService0 = new Service(perResolveFunc42!); + Owned perBlockOwned2; + Owned localOwned8 = accumulator41; + IDependency localValue9 = transientDependency4; + perBlockOwned2 = new Owned(localValue9, localOwned8); + lock (_lock) + { + accumulator41.Add(perBlockOwned2); + } + Owned localValue7 = perBlockOwned2; + return localValue7; + }); + Service transientService0 = new Service(perBlockFunc1); lock (_lock) { accumulator41.Add(transientService0); @@ -275,7 +265,7 @@ classDiagram <> } Composition ..> Service : Service Root - Service o-- "PerResolve" FuncᐸOwnedᐸIDependencyᐳᐳ : FuncᐸOwnedᐸIDependencyᐳᐳ + Service o-- "PerBlock" FuncᐸOwnedᐸIDependencyᐳᐳ : FuncᐸOwnedᐸIDependencyᐳᐳ FuncᐸOwnedᐸIDependencyᐳᐳ o-- "PerBlock" OwnedᐸIDependencyᐳ : OwnedᐸIDependencyᐳ OwnedᐸIDependencyᐳ *-- Owned : Owned OwnedᐸIDependencyᐳ *-- Dependency : IDependency diff --git a/readme/tracking-disposable-instances-in-delegates.md b/readme/tracking-disposable-instances-in-delegates.md index 5a3c4547..5614fa97 100644 --- a/readme/tracking-disposable-instances-in-delegates.md +++ b/readme/tracking-disposable-instances-in-delegates.md @@ -89,38 +89,28 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perResolveFunc42 = default(Func>); var accumulator41 = new Owned(); - if (perResolveFunc42 == null) + var perBlockFunc1 = default(Func> ); + perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { + var accumulator41 = new Owned(); + Dependency transientDependency4 = new Dependency(); lock (_lock) { - if (perResolveFunc42 == null) - { - perResolveFunc42 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => - { - var accumulator41 = new Owned(); - Dependency transientDependency3 = new Dependency(); - lock (_lock) - { - accumulator41.Add(transientDependency3); - } - Owned perBlockOwned1; - Owned localOwned13 = accumulator41; - IDependency localValue14 = transientDependency3; - perBlockOwned1 = new Owned(localValue14, localOwned13); - lock (_lock) - { - accumulator41.Add(perBlockOwned1); - } - Owned localValue12 = perBlockOwned1; - return localValue12; - }); - } + accumulator41.Add(transientDependency4); } - } - - Service transientService0 = new Service(perResolveFunc42!); + Owned perBlockOwned2; + Owned localOwned13 = accumulator41; + IDependency localValue14 = transientDependency4; + perBlockOwned2 = new Owned(localValue14, localOwned13); + lock (_lock) + { + accumulator41.Add(perBlockOwned2); + } + Owned localValue12 = perBlockOwned2; + return localValue12; + }); + Service transientService0 = new Service(perBlockFunc1); lock (_lock) { accumulator41.Add(transientService0); @@ -268,7 +258,7 @@ classDiagram <> } Composition ..> Service : Service Root - Service o-- "PerResolve" FuncᐸOwnedᐸIDependencyᐳᐳ : FuncᐸOwnedᐸIDependencyᐳᐳ + Service o-- "PerBlock" FuncᐸOwnedᐸIDependencyᐳᐳ : FuncᐸOwnedᐸIDependencyᐳᐳ FuncᐸOwnedᐸIDependencyᐳᐳ o-- "PerBlock" OwnedᐸIDependencyᐳ : OwnedᐸIDependencyᐳ OwnedᐸIDependencyᐳ *-- Owned : Owned OwnedᐸIDependencyᐳ *-- Dependency : IDependency diff --git a/src/Pure.DI.Core/Components/Api.g.cs b/src/Pure.DI.Core/Components/Api.g.cs index 7da11dc6..78a002df 100644 --- a/src/Pure.DI.Core/Components/Api.g.cs +++ b/src/Pure.DI.Core/Components/Api.g.cs @@ -1,5 +1,5 @@ // -#if !PUREDI_API_SUPPRESSION || PUREDI_API_V2 +#if !PUREDI_API_SUPPRESSION || PUREDI_API_V1 #pragma warning disable #if !PUREDI_API_FUNC_SUPPRESSION diff --git a/src/Pure.DI.Core/Components/GenericTypeArguments.g.cs b/src/Pure.DI.Core/Components/GenericTypeArguments.g.cs index a2433b61..5e7bdbc7 100644 --- a/src/Pure.DI.Core/Components/GenericTypeArguments.g.cs +++ b/src/Pure.DI.Core/Components/GenericTypeArguments.g.cs @@ -1,5 +1,5 @@ // -#if !PUREDI_API_SUPPRESSION || PUREDI_API_V2 +#if !PUREDI_API_SUPPRESSION || PUREDI_API_V1 #pragma warning disable namespace Pure.DI { diff --git a/src/Pure.DI.Core/Features/Default.g.cs b/src/Pure.DI.Core/Features/Default.g.cs index cecd1436..1d84b36b 100644 --- a/src/Pure.DI.Core/Features/Default.g.cs +++ b/src/Pure.DI.Core/Features/Default.g.cs @@ -1,5 +1,5 @@ // -#if !PUREDI_API_SUPPRESSION || PUREDI_API_V2 +#if !PUREDI_API_SUPPRESSION || PUREDI_API_V1 #pragma warning disable namespace Pure.DI diff --git a/src/Pure.DI.Core/Pure.DI.Core.csproj b/src/Pure.DI.Core/Pure.DI.Core.csproj index 22f0cf0f..ccb232ab 100644 --- a/src/Pure.DI.Core/Pure.DI.Core.csproj +++ b/src/Pure.DI.Core/Pure.DI.Core.csproj @@ -3,7 +3,7 @@ netstandard2.0 $(BasePackageId) - $(DefineConstants);PUREDI_API_SUPPRESSION;PUREDI_API_V2 + $(DefineConstants);PUREDI_API_SUPPRESSION;PUREDI_API_V1