diff --git a/readme/async-disposable-scope.md b/readme/async-disposable-scope.md index d683fb6a..b45666ef 100644 --- a/readme/async-disposable-scope.md +++ b/readme/async-disposable-scope.md @@ -136,7 +136,7 @@ partial class Composition: IDisposable, IAsyncDisposable [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perBlockFunc1 = default(Func ); + var perBlockFunc1 = default(Func); perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { Composition transientComposition3 = this; diff --git a/readme/async-root.md b/readme/async-root.md index e99f1d16..dac1d841 100644 --- a/readme/async-root.md +++ b/readme/async-root.md @@ -59,7 +59,7 @@ partial class Composition TaskContinuationOptions localTaskContinuationOptions19 = transientTaskContinuationOptions4; TaskScheduler localTaskScheduler20 = transientTaskScheduler5; perBlockTaskFactory2 = new TaskFactory(localCancellationToken17, localTaskCreationOptions18, localTaskContinuationOptions19, localTaskScheduler20); - var perBlockFunc1 = default(Func ); + var perBlockFunc1 = default(Func); perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { IService localValue21 = new Service(new Dependency()); diff --git a/readme/auto-scoped.md b/readme/auto-scoped.md index ca1f15b3..e5908794 100644 --- a/readme/auto-scoped.md +++ b/readme/auto-scoped.md @@ -95,7 +95,7 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perBlockFunc1 = default(Func ); + var perBlockFunc1 = default(Func); perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { Composition transientComposition3 = this; diff --git a/readme/func-with-tag.md b/readme/func-with-tag.md index d2e0a4cf..03bdecc0 100644 --- a/readme/func-with-tag.md +++ b/readme/func-with-tag.md @@ -59,7 +59,7 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perBlockFunc1 = default(Func ); + var perBlockFunc1 = default(Func); perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { IDependency localValue32 = new Dependency(); diff --git a/readme/func.md b/readme/func.md index 26997d00..840e20c6 100644 --- a/readme/func.md +++ b/readme/func.md @@ -62,7 +62,7 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perBlockFunc1 = default(Func ); + var perBlockFunc1 = default(Func); perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { IDependency localValue30 = new Dependency(); diff --git a/readme/generic-async-composition-roots-with-constraints.md b/readme/generic-async-composition-roots-with-constraints.md index ffe5c48a..3ead1ebb 100644 --- a/readme/generic-async-composition-roots-with-constraints.md +++ b/readme/generic-async-composition-roots-with-constraints.md @@ -93,7 +93,7 @@ partial class Composition TaskContinuationOptions localTaskContinuationOptions48 = transientTaskContinuationOptions4; TaskScheduler localTaskScheduler49 = transientTaskScheduler5; perBlockTaskFactory2 = new TaskFactory>(localCancellationToken46, localTaskCreationOptions47, localTaskContinuationOptions48, localTaskScheduler49); - var perBlockFunc1 = default(Func> ); + var perBlockFunc1 = default(Func>); perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { OtherService transientOtherService6; @@ -123,7 +123,7 @@ partial class Composition TaskContinuationOptions localTaskContinuationOptions56 = transientTaskContinuationOptions4; TaskScheduler localTaskScheduler57 = transientTaskScheduler5; perBlockTaskFactory2 = new TaskFactory>(localCancellationToken54, localTaskCreationOptions55, localTaskContinuationOptions56, localTaskScheduler57); - var perBlockFunc1 = default(Func> ); + var perBlockFunc1 = default(Func>); perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { IService localValue58 = new Service(new Dependency()); diff --git a/readme/lazy.md b/readme/lazy.md index a153daa0..92138e41 100644 --- a/readme/lazy.md +++ b/readme/lazy.md @@ -53,7 +53,7 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perBlockFunc2 = default(Func ); + var perBlockFunc2 = default(Func); perBlockFunc2 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { IDependency localValue33 = new Dependency(); diff --git a/readme/manually-started-tasks.md b/readme/manually-started-tasks.md index ddf03255..8f68281f 100644 --- a/readme/manually-started-tasks.md +++ b/readme/manually-started-tasks.md @@ -91,7 +91,7 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] public IService GetRoot(CancellationToken cancellationToken) { - var perBlockFunc2 = default(Func ); + var perBlockFunc2 = default(Func); perBlockFunc2 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { IDependency localValue35 = new Dependency(); diff --git a/readme/scope.md b/readme/scope.md index 718b31cc..fa0e8166 100644 --- a/readme/scope.md +++ b/readme/scope.md @@ -134,7 +134,7 @@ partial class Composition: IDisposable [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var perBlockFunc1 = default(Func ); + var perBlockFunc1 = default(Func); perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { Composition transientComposition3 = this; diff --git a/readme/task.md b/readme/task.md index cb718587..b17c28ac 100644 --- a/readme/task.md +++ b/readme/task.md @@ -88,7 +88,7 @@ partial class Composition TaskContinuationOptions localTaskContinuationOptions40 = transientTaskContinuationOptions5; TaskScheduler localTaskScheduler41 = transientTaskScheduler6; perBlockTaskFactory3 = new TaskFactory(localCancellationToken38, localTaskCreationOptions39, localTaskContinuationOptions40, localTaskScheduler41); - var perBlockFunc2 = default(Func ); + var perBlockFunc2 = default(Func); perBlockFunc2 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { IDependency localValue42 = new Dependency(); diff --git a/readme/tracking-async-disposable-instances-in-delegates.md b/readme/tracking-async-disposable-instances-in-delegates.md index 6a702e0e..157dbe9e 100644 --- a/readme/tracking-async-disposable-instances-in-delegates.md +++ b/readme/tracking-async-disposable-instances-in-delegates.md @@ -97,7 +97,7 @@ partial class Composition get { var accumulator41 = new Owned(); - var perBlockFunc1 = default(Func> ); + var perBlockFunc1 = default(Func>); perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { var accumulator41 = new Owned(); diff --git a/readme/tracking-disposable-instances-in-delegates.md b/readme/tracking-disposable-instances-in-delegates.md index 5614fa97..df2b585c 100644 --- a/readme/tracking-disposable-instances-in-delegates.md +++ b/readme/tracking-disposable-instances-in-delegates.md @@ -90,7 +90,7 @@ partial class Composition get { var accumulator41 = new Owned(); - var perBlockFunc1 = default(Func> ); + var perBlockFunc1 = default(Func>); perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { var accumulator41 = new Owned(); diff --git a/src/Pure.DI.Core/Core/Code/BuildTools.cs b/src/Pure.DI.Core/Core/Code/BuildTools.cs index 47bfed2c..28c55422 100644 --- a/src/Pure.DI.Core/Core/Code/BuildTools.cs +++ b/src/Pure.DI.Core/Core/Code/BuildTools.cs @@ -15,8 +15,8 @@ public void AddPureHeader(LinesBuilder code) code.AppendLine("#endif"); } - public string GetDeclaration(Variable variable) => - variable.IsDeclared ? "" : $"{typeResolver.Resolve(variable.Setup, variable.InstanceType)} "; + public string GetDeclaration(Variable variable, string separator = " ") => + variable.IsDeclared ? "" : $"{typeResolver.Resolve(variable.Setup, variable.InstanceType)}{separator}"; public string OnInjected(BuildContext ctx, Variable variable) { diff --git a/src/Pure.DI.Core/Core/Code/FactoryCodeBuilder.cs b/src/Pure.DI.Core/Core/Code/FactoryCodeBuilder.cs index f68c94a3..a8233d45 100644 --- a/src/Pure.DI.Core/Core/Code/FactoryCodeBuilder.cs +++ b/src/Pure.DI.Core/Core/Code/FactoryCodeBuilder.cs @@ -163,7 +163,7 @@ public void Build(BuildContext ctx, in DpFactory factory) var lines = new List(); if (!variable.IsDeclared && variable.IsLazy) { - ctx.Code.AppendLine($"var {variable.VariableName} = default({ctx.BuildTools.GetDeclaration(variable)});"); + ctx.Code.AppendLine($"var {variable.VariableName} = default({ctx.BuildTools.GetDeclaration(variable, "")});"); variable.IsDeclared = true; } diff --git a/src/Pure.DI.Core/Core/Code/IBuildTools.cs b/src/Pure.DI.Core/Core/Code/IBuildTools.cs index 238ad8c7..24cfe95e 100644 --- a/src/Pure.DI.Core/Core/Code/IBuildTools.cs +++ b/src/Pure.DI.Core/Core/Code/IBuildTools.cs @@ -4,7 +4,7 @@ internal interface IBuildTools { void AddPureHeader(LinesBuilder code); - string GetDeclaration(Variable variable); + string GetDeclaration(Variable variable, string separator = " "); string OnInjected(BuildContext ctx, Variable variable);