Skip to content

Commit

Permalink
Optimization of flow-safety of object creation within the composition…
Browse files Browse the repository at this point in the history
… of objects
  • Loading branch information
NikolayPianikov committed Sep 23, 2023
1 parent 594e677 commit 3e5d661
Show file tree
Hide file tree
Showing 72 changed files with 1,743 additions and 1,752 deletions.
2 changes: 1 addition & 1 deletion .run/Pack.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Pack" type="DotNetProject" factoryName=".NET Project">
<option name="EXE_PATH" value="$PROJECT_DIR$/build/bin/roslyn4.3/Debug/net7.0/build.exe" />
<option name="PROGRAM_PARAMETERS" value="-p:version=2.0.17-dev pack" />
<option name="PROGRAM_PARAMETERS" value="-p:version=2.0.18-dev pack" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
Expand Down
130 changes: 65 additions & 65 deletions readme/ArrayDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ classDiagram
```c#
partial class Array
{
private readonly System.IDisposable[] _disposableSingletonsM09D22di;
private readonly System.IDisposable[] _disposableSingletonsM09D23di;

public Array()
{
_disposableSingletonsM09D22di = new System.IDisposable[0];
_disposableSingletonsM09D23di = new System.IDisposable[0];
}

internal Array(Array parent)
{
_disposableSingletonsM09D22di = new System.IDisposable[0];
_disposableSingletonsM09D23di = new System.IDisposable[0];
}

#region Composition Roots
Expand All @@ -93,58 +93,58 @@ partial class Array
[global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)]
get
{
Pure.DI.Benchmarks.Model.Service3v4 transientM09D22di26 = new Pure.DI.Benchmarks.Model.Service3v4();
Pure.DI.Benchmarks.Model.Service3v3 transientM09D22di25 = new Pure.DI.Benchmarks.Model.Service3v3();
Pure.DI.Benchmarks.Model.Service3v2 transientM09D22di24 = new Pure.DI.Benchmarks.Model.Service3v2();
Pure.DI.Benchmarks.Model.Service3 transientM09D22di23 = new Pure.DI.Benchmarks.Model.Service3();
Pure.DI.Benchmarks.Model.IService3[] transientM09D22di22 = new Pure.DI.Benchmarks.Model.IService3[4]
var transientM09D23di26 = new Pure.DI.Benchmarks.Model.Service3v4();
var transientM09D23di25 = new Pure.DI.Benchmarks.Model.Service3v3();
var transientM09D23di24 = new Pure.DI.Benchmarks.Model.Service3v2();
var transientM09D23di23 = new Pure.DI.Benchmarks.Model.Service3();
var transientM09D23di22 = new Pure.DI.Benchmarks.Model.IService3[4]
{
transientM09D22di23,
transientM09D22di24,
transientM09D22di25,
transientM09D22di26
transientM09D23di23,
transientM09D23di24,
transientM09D23di25,
transientM09D23di26
};
Pure.DI.Benchmarks.Model.Service2Array transientM09D22di21 = new Pure.DI.Benchmarks.Model.Service2Array(transientM09D22di22);
Pure.DI.Benchmarks.Model.Service3v4 transientM09D22di20 = new Pure.DI.Benchmarks.Model.Service3v4();
Pure.DI.Benchmarks.Model.Service3v3 transientM09D22di19 = new Pure.DI.Benchmarks.Model.Service3v3();
Pure.DI.Benchmarks.Model.Service3v2 transientM09D22di18 = new Pure.DI.Benchmarks.Model.Service3v2();
Pure.DI.Benchmarks.Model.Service3 transientM09D22di17 = new Pure.DI.Benchmarks.Model.Service3();
Pure.DI.Benchmarks.Model.IService3[] transientM09D22di16 = new Pure.DI.Benchmarks.Model.IService3[4]
var transientM09D23di21 = new Pure.DI.Benchmarks.Model.Service2Array(transientM09D23di22);
var transientM09D23di20 = new Pure.DI.Benchmarks.Model.Service3v4();
var transientM09D23di19 = new Pure.DI.Benchmarks.Model.Service3v3();
var transientM09D23di18 = new Pure.DI.Benchmarks.Model.Service3v2();
var transientM09D23di17 = new Pure.DI.Benchmarks.Model.Service3();
var transientM09D23di16 = new Pure.DI.Benchmarks.Model.IService3[4]
{
transientM09D22di17,
transientM09D22di18,
transientM09D22di19,
transientM09D22di20
transientM09D23di17,
transientM09D23di18,
transientM09D23di19,
transientM09D23di20
};
Pure.DI.Benchmarks.Model.Service3v4 transientM09D22di15 = new Pure.DI.Benchmarks.Model.Service3v4();
Pure.DI.Benchmarks.Model.Service3v3 transientM09D22di14 = new Pure.DI.Benchmarks.Model.Service3v3();
Pure.DI.Benchmarks.Model.Service3v2 transientM09D22di13 = new Pure.DI.Benchmarks.Model.Service3v2();
Pure.DI.Benchmarks.Model.Service3 transientM09D22di12 = new Pure.DI.Benchmarks.Model.Service3();
Pure.DI.Benchmarks.Model.IService3[] transientM09D22di11 = new Pure.DI.Benchmarks.Model.IService3[4]
var transientM09D23di15 = new Pure.DI.Benchmarks.Model.Service3v4();
var transientM09D23di14 = new Pure.DI.Benchmarks.Model.Service3v3();
var transientM09D23di13 = new Pure.DI.Benchmarks.Model.Service3v2();
var transientM09D23di12 = new Pure.DI.Benchmarks.Model.Service3();
var transientM09D23di11 = new Pure.DI.Benchmarks.Model.IService3[4]
{
transientM09D22di12,
transientM09D22di13,
transientM09D22di14,
transientM09D22di15
transientM09D23di12,
transientM09D23di13,
transientM09D23di14,
transientM09D23di15
};
Pure.DI.Benchmarks.Model.Service3v4 transientM09D22di10 = new Pure.DI.Benchmarks.Model.Service3v4();
Pure.DI.Benchmarks.Model.Service3v3 transientM09D22di9 = new Pure.DI.Benchmarks.Model.Service3v3();
Pure.DI.Benchmarks.Model.Service3v2 transientM09D22di8 = new Pure.DI.Benchmarks.Model.Service3v2();
Pure.DI.Benchmarks.Model.Service3 transientM09D22di7 = new Pure.DI.Benchmarks.Model.Service3();
Pure.DI.Benchmarks.Model.IService3[] transientM09D22di6 = new Pure.DI.Benchmarks.Model.IService3[4]
var transientM09D23di10 = new Pure.DI.Benchmarks.Model.Service3v4();
var transientM09D23di9 = new Pure.DI.Benchmarks.Model.Service3v3();
var transientM09D23di8 = new Pure.DI.Benchmarks.Model.Service3v2();
var transientM09D23di7 = new Pure.DI.Benchmarks.Model.Service3();
var transientM09D23di6 = new Pure.DI.Benchmarks.Model.IService3[4]
{
transientM09D22di7,
transientM09D22di8,
transientM09D22di9,
transientM09D22di10
transientM09D23di7,
transientM09D23di8,
transientM09D23di9,
transientM09D23di10
};
Pure.DI.Benchmarks.Model.Service3 transientM09D22di5 = new Pure.DI.Benchmarks.Model.Service3();
Pure.DI.Benchmarks.Model.Service2Array transientM09D22di4 = new Pure.DI.Benchmarks.Model.Service2Array(transientM09D22di6);
Pure.DI.Benchmarks.Model.Service2Array transientM09D22di3 = new Pure.DI.Benchmarks.Model.Service2Array(transientM09D22di11);
Pure.DI.Benchmarks.Model.Service2Array transientM09D22di2 = new Pure.DI.Benchmarks.Model.Service2Array(transientM09D22di16);
Pure.DI.Benchmarks.Model.Service1 transientM09D22di1 = new Pure.DI.Benchmarks.Model.Service1(transientM09D22di21);
Pure.DI.Benchmarks.Model.CompositionRoot transientM09D22di0 = new Pure.DI.Benchmarks.Model.CompositionRoot(transientM09D22di1, transientM09D22di2, transientM09D22di3, transientM09D22di4, transientM09D22di5);
return transientM09D22di0;
var transientM09D23di5 = new Pure.DI.Benchmarks.Model.Service3();
var transientM09D23di4 = new Pure.DI.Benchmarks.Model.Service2Array(transientM09D23di6);
var transientM09D23di3 = new Pure.DI.Benchmarks.Model.Service2Array(transientM09D23di11);
var transientM09D23di2 = new Pure.DI.Benchmarks.Model.Service2Array(transientM09D23di16);
var transientM09D23di1 = new Pure.DI.Benchmarks.Model.Service1(transientM09D23di21);
var transientM09D23di0 = new Pure.DI.Benchmarks.Model.CompositionRoot(transientM09D23di1, transientM09D23di2, transientM09D23di3, transientM09D23di4, transientM09D23di5);
return transientM09D23di0;
}
}
#endregion
Expand All @@ -156,7 +156,7 @@ partial class Array
[global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)]
public T Resolve<T>()
{
return ResolverM09D22di<T>.Value.Resolve(this);
return ResolverM09D23di<T>.Value.Resolve(this);
}

#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER
Expand All @@ -165,7 +165,7 @@ partial class Array
[global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)]
public T Resolve<T>(object? tag)
{
return ResolverM09D22di<T>.Value.ResolveByTag(this, tag);
return ResolverM09D23di<T>.Value.ResolveByTag(this, tag);
}

#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP || NET40_OR_GREATER
Expand All @@ -174,10 +174,10 @@ partial class Array
[global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)]
public object Resolve(global::System.Type type)
{
var index = (int)(_bucketSizeM09D22di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM09D22di;
var index = (int)(_bucketSizeM09D23di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM09D23di;
do {
ref var pair = ref _bucketsM09D22di[index];
ref var pair = ref _bucketsM09D23di[index];
if (ReferenceEquals(pair.Key, type))
{
return pair.Value.Resolve(this);
Expand All @@ -193,10 +193,10 @@ partial class Array
[global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)]
public object Resolve(global::System.Type type, object? tag)
{
var index = (int)(_bucketSizeM09D22di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM09D22di;
var index = (int)(_bucketSizeM09D23di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM09D23di;
do {
ref var pair = ref _bucketsM09D22di[index];
ref var pair = ref _bucketsM09D23di[index];
if (ReferenceEquals(pair.Key, type))
{
return pair.Value.ResolveByTag(this, tag);
Expand Down Expand Up @@ -273,26 +273,26 @@ partial class Array
" Array ..> CompositionRoot : ICompositionRoot Root";
}

private readonly static int _bucketSizeM09D22di;
private readonly static global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Array, object>>[] _bucketsM09D22di;
private readonly static int _bucketSizeM09D23di;
private readonly static global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Array, object>>[] _bucketsM09D23di;

static Array()
{
var valResolverM09D22di_0000 = new ResolverM09D22di_0000();
ResolverM09D22di<Pure.DI.Benchmarks.Model.ICompositionRoot>.Value = valResolverM09D22di_0000;
_bucketsM09D22di = global::Pure.DI.Buckets<global::System.Type, global::Pure.DI.IResolver<Array, object>>.Create(
var valResolverM09D23di_0000 = new ResolverM09D23di_0000();
ResolverM09D23di<Pure.DI.Benchmarks.Model.ICompositionRoot>.Value = valResolverM09D23di_0000;
_bucketsM09D23di = global::Pure.DI.Buckets<global::System.Type, global::Pure.DI.IResolver<Array, object>>.Create(
1,
out _bucketSizeM09D22di,
out _bucketSizeM09D23di,
new global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Array, object>>[1]
{
new global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Array, object>>(typeof(Pure.DI.Benchmarks.Model.ICompositionRoot), valResolverM09D22di_0000)
new global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Array, object>>(typeof(Pure.DI.Benchmarks.Model.ICompositionRoot), valResolverM09D23di_0000)
});
}

#region Resolvers
private sealed class ResolverM09D22di<T>: global::Pure.DI.IResolver<Array, T>
private sealed class ResolverM09D23di<T>: global::Pure.DI.IResolver<Array, T>
{
public static global::Pure.DI.IResolver<Array, T> Value = new ResolverM09D22di<T>();
public static global::Pure.DI.IResolver<Array, T> Value = new ResolverM09D23di<T>();

public T Resolve(Array composite)
{
Expand All @@ -305,7 +305,7 @@ partial class Array
}
}

private sealed class ResolverM09D22di_0000: global::Pure.DI.IResolver<Array, Pure.DI.Benchmarks.Model.ICompositionRoot>
private sealed class ResolverM09D23di_0000: global::Pure.DI.IResolver<Array, Pure.DI.Benchmarks.Model.ICompositionRoot>
{
[global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)]
public Pure.DI.Benchmarks.Model.ICompositionRoot Resolve(Array composition)
Expand Down
2 changes: 1 addition & 1 deletion readme/Console.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ The [project file](/samples/ShroedingersCat/ShroedingersCat.csproj) looks like t
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.0.18">
<PackageReference Include="Pure.DI" Version="2.0.19">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion readme/ConsoleTopLevelStatements.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ The [project file](/samples/ShroedingersCatTopLevelStatements/ShroedingersCatTop
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.0.18">
<PackageReference Include="Pure.DI" Version="2.0.19">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit 3e5d661

Please sign in to comment.