Skip to content

Commit

Permalink
Updating internal Pure.DI to 2.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Apr 3, 2024
1 parent 319ee7f commit f20a9ae
Show file tree
Hide file tree
Showing 99 changed files with 2,257 additions and 2,261 deletions.
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,20 @@ Add the _Pure.DI_ package to your project:
Let's bind the abstractions to their implementations and set up the creation of the object graph:

```c#
partial class Composition
{
void Setup() =>
DI.Setup(nameof(Composition))
// Models a random subatomic event that may or may not occur
.Bind().As(Singleton).To<Random>()
// Represents a quantum superposition of 2 states: Alive or Dead
.Bind().To(ctx =>
{
ctx.Inject<Random>(out var random);
return (State)random.Next(2);
})
.Bind().To<ShroedingersCat>()
// Represents a cardboard box with any contents
.Bind().To<CardboardBox<TT>>()
// Composition Root
.Root<Program>("Root");
}
DI.Setup(nameof(Composition))
// Models a random subatomic event that may or may not occur
.Bind().As(Singleton).To<Random>()
// Represents a quantum superposition of 2 states: Alive or Dead
.Bind().To(ctx =>
{
ctx.Inject<Random>(out var random);
return (State)random.Next(2);
})
.Bind().To<ShroedingersCat>()
// Represents a cardboard box with any contents
.Bind().To<CardboardBox<TT>>()
// Composition Root
.Root<Program>("Root");
```

The above code specifies the generation of a partial class named *__Composition__*, this name is defined in the `DI.Setup(nameof(Composition))` call. This class contains a *__Root__* property that returns a graph of objects with an object of type *__Program__* as the root. The type and name of the property is defined by calling `Root<Program>("Root")`. The code of the generated class looks as follows:
Expand Down
2 changes: 1 addition & 1 deletion build/build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="CSharpInteractive" Version="1.0.7" />
<PackageReference Include="Pure.DI" Version="2.1.7">
<PackageReference Include="Pure.DI" Version="2.1.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
46 changes: 23 additions & 23 deletions readme/ArrayDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ classDiagram
```c#
partial class Array
{
private readonly Array _rootM03D28di;
private readonly Array _rootM04D03di;

public Array()
{
_rootM03D28di = this;
_rootM04D03di = this;
}

internal Array(Array baseComposition)
{
_rootM03D28di = baseComposition._rootM03D28di;
_rootM04D03di = baseComposition._rootM04D03di;
}

public partial Pure.DI.Benchmarks.Model.CompositionRoot PureDIByCR()
Expand All @@ -107,21 +107,21 @@ partial class Array

public T Resolve<T>()
{
return ResolverM03D28di<T>.Value.Resolve(this);
return ResolverM04D03di<T>.Value.Resolve(this);
}

public T Resolve<T>(object? tag)
{
return ResolverM03D28di<T>.Value.ResolveByTag(this, tag);
return ResolverM04D03di<T>.Value.ResolveByTag(this, tag);
}

public object Resolve(global::System.Type type)
{
var index = (int)(_bucketSizeM03D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM03D28di;
var index = (int)(_bucketSizeM04D03di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM04D03di;
do {
ref var pair = ref _bucketsM03D28di[index];
if (ReferenceEquals(pair.Key, type))
ref var pair = ref _bucketsM04D03di[index];
if (pair.Key == type)
{
return pair.Value.Resolve(this);
}
Expand All @@ -132,11 +132,11 @@ partial class Array

public object Resolve(global::System.Type type, object? tag)
{
var index = (int)(_bucketSizeM03D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM03D28di;
var index = (int)(_bucketSizeM04D03di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM04D03di;
do {
ref var pair = ref _bucketsM03D28di[index];
if (ReferenceEquals(pair.Key, type))
ref var pair = ref _bucketsM04D03di[index];
if (pair.Key == type)
{
return pair.Value.ResolveByTag(this, tag);
}
Expand Down Expand Up @@ -224,25 +224,25 @@ partial class Array
" Array ..> CompositionRoot : CompositionRoot PureDIByCR()";
}

private readonly static int _bucketSizeM03D28di;
private readonly static global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Array, object>>[] _bucketsM03D28di;
private readonly static int _bucketSizeM04D03di;
private readonly static global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Array, object>>[] _bucketsM04D03di;

static Array()
{
var valResolverM03D28di_0000 = new ResolverM03D28di_0000();
ResolverM03D28di<Pure.DI.Benchmarks.Model.CompositionRoot>.Value = valResolverM03D28di_0000;
_bucketsM03D28di = global::Pure.DI.Buckets<global::System.Type, global::Pure.DI.IResolver<Array, object>>.Create(
var valResolverM04D03di_0000 = new ResolverM04D03di_0000();
ResolverM04D03di<Pure.DI.Benchmarks.Model.CompositionRoot>.Value = valResolverM04D03di_0000;
_bucketsM04D03di = global::Pure.DI.Buckets<global::System.Type, global::Pure.DI.IResolver<Array, object>>.Create(
1,
out _bucketSizeM03D28di,
out _bucketSizeM04D03di,
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.CompositionRoot), valResolverM03D28di_0000)
new global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Array, object>>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM04D03di_0000)
});
}

private sealed class ResolverM03D28di<T>: global::Pure.DI.IResolver<Array, T>
private sealed class ResolverM04D03di<T>: global::Pure.DI.IResolver<Array, T>
{
public static global::Pure.DI.IResolver<Array, T> Value = new ResolverM03D28di<T>();
public static global::Pure.DI.IResolver<Array, T> Value = new ResolverM04D03di<T>();

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

private sealed class ResolverM03D28di_0000: global::Pure.DI.IResolver<Array, Pure.DI.Benchmarks.Model.CompositionRoot>
private sealed class ResolverM04D03di_0000: global::Pure.DI.IResolver<Array, Pure.DI.Benchmarks.Model.CompositionRoot>
{
public Pure.DI.Benchmarks.Model.CompositionRoot Resolve(Array composition)
{
Expand Down
2 changes: 1 addition & 1 deletion readme/Avalonia.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The [project file](/samples/AvaloniaApp/AvaloniaApp.csproj) looks like this:
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.0">
<PackageReference Include="Pure.DI" Version="2.1.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions readme/BlazorServerApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ The [project file](/samples/BlazorServerApp/BlazorServerApp.csproj) looks like t
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.0">
<PackageReference Include="Pure.DI" Version="2.1.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pure.DI.MS" Version="2.1.0" />
<PackageReference Include="Pure.DI.MS" Version="2.1.6" />
</ItemGroup>

</Project>
Expand Down
4 changes: 2 additions & 2 deletions readme/BlazorWebAssemblyApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ The [project file](/samples/BlazorWebAssemblyApp/BlazorWebAssemblyApp.csproj) lo
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.0">
<PackageReference Include="Pure.DI" Version="2.1.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pure.DI.MS" Version="2.1.0" />
<PackageReference Include="Pure.DI.MS" Version="2.1.6" />
</ItemGroup>

</Project>
Expand Down
2 changes: 1 addition & 1 deletion readme/Console.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ The [project file](/samples/ShroedingersCat/ShroedingersCat.csproj) looks like t
</PropertyGroup>

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

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.0">
<PackageReference Include="Pure.DI" Version="2.1.8">
<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 @@ -78,7 +78,7 @@ The [project file](/samples/ShroedingersCatTopLevelStatements/ShroedingersCatTop
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.0">
<PackageReference Include="Pure.DI" Version="2.1.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
52 changes: 26 additions & 26 deletions readme/EnumDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,49 +88,49 @@ classDiagram
```c#
partial class Enum
{
private readonly Enum _rootM03D28di;
private readonly Enum _rootM04D03di;

public Enum()
{
_rootM03D28di = this;
_rootM04D03di = this;
}

internal Enum(Enum baseComposition)
{
_rootM03D28di = baseComposition._rootM03D28di;
_rootM04D03di = baseComposition._rootM04D03di;
}

public partial Pure.DI.Benchmarks.Model.CompositionRoot PureDIByCR()
{
[global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x200)]
System.Collections.Generic.IEnumerable<Pure.DI.Benchmarks.Model.IService3> LocalperBlockM03D28di10_IEnumerable()
System.Collections.Generic.IEnumerable<Pure.DI.Benchmarks.Model.IService3> LocalperBlockM04D03di10_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());
}
System.Collections.Generic.IEnumerable<Pure.DI.Benchmarks.Model.IService3> perBlockM03D28di10_IEnumerable = LocalperBlockM03D28di10_IEnumerable();
return new Pure.DI.Benchmarks.Model.CompositionRoot(new Pure.DI.Benchmarks.Model.Service1(new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D28di10_IEnumerable)), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D28di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D28di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM03D28di10_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());
System.Collections.Generic.IEnumerable<Pure.DI.Benchmarks.Model.IService3> perBlockM04D03di10_IEnumerable = LocalperBlockM04D03di10_IEnumerable();
return new Pure.DI.Benchmarks.Model.CompositionRoot(new Pure.DI.Benchmarks.Model.Service1(new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM04D03di10_IEnumerable)), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM04D03di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM04D03di10_IEnumerable), new Pure.DI.Benchmarks.Model.Service2Enum(perBlockM04D03di10_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());
}

public T Resolve<T>()
{
return ResolverM03D28di<T>.Value.Resolve(this);
return ResolverM04D03di<T>.Value.Resolve(this);
}

public T Resolve<T>(object? tag)
{
return ResolverM03D28di<T>.Value.ResolveByTag(this, tag);
return ResolverM04D03di<T>.Value.ResolveByTag(this, tag);
}

public object Resolve(global::System.Type type)
{
var index = (int)(_bucketSizeM03D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM03D28di;
var index = (int)(_bucketSizeM04D03di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM04D03di;
do {
ref var pair = ref _bucketsM03D28di[index];
if (ReferenceEquals(pair.Key, type))
ref var pair = ref _bucketsM04D03di[index];
if (pair.Key == type)
{
return pair.Value.Resolve(this);
}
Expand All @@ -141,11 +141,11 @@ partial class Enum

public object Resolve(global::System.Type type, object? tag)
{
var index = (int)(_bucketSizeM03D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM03D28di;
var index = (int)(_bucketSizeM04D03di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1));
var finish = index + _bucketSizeM04D03di;
do {
ref var pair = ref _bucketsM03D28di[index];
if (ReferenceEquals(pair.Key, type))
ref var pair = ref _bucketsM04D03di[index];
if (pair.Key == type)
{
return pair.Value.ResolveByTag(this, tag);
}
Expand Down Expand Up @@ -233,25 +233,25 @@ partial class Enum
" Enum ..> CompositionRoot : CompositionRoot PureDIByCR()";
}

private readonly static int _bucketSizeM03D28di;
private readonly static global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Enum, object>>[] _bucketsM03D28di;
private readonly static int _bucketSizeM04D03di;
private readonly static global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Enum, object>>[] _bucketsM04D03di;

static Enum()
{
var valResolverM03D28di_0000 = new ResolverM03D28di_0000();
ResolverM03D28di<Pure.DI.Benchmarks.Model.CompositionRoot>.Value = valResolverM03D28di_0000;
_bucketsM03D28di = global::Pure.DI.Buckets<global::System.Type, global::Pure.DI.IResolver<Enum, object>>.Create(
var valResolverM04D03di_0000 = new ResolverM04D03di_0000();
ResolverM04D03di<Pure.DI.Benchmarks.Model.CompositionRoot>.Value = valResolverM04D03di_0000;
_bucketsM04D03di = global::Pure.DI.Buckets<global::System.Type, global::Pure.DI.IResolver<Enum, object>>.Create(
1,
out _bucketSizeM03D28di,
out _bucketSizeM04D03di,
new global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Enum, object>>[1]
{
new global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Enum, object>>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM03D28di_0000)
new global::Pure.DI.Pair<global::System.Type, global::Pure.DI.IResolver<Enum, object>>(typeof(Pure.DI.Benchmarks.Model.CompositionRoot), valResolverM04D03di_0000)
});
}

private sealed class ResolverM03D28di<T>: global::Pure.DI.IResolver<Enum, T>
private sealed class ResolverM04D03di<T>: global::Pure.DI.IResolver<Enum, T>
{
public static global::Pure.DI.IResolver<Enum, T> Value = new ResolverM03D28di<T>();
public static global::Pure.DI.IResolver<Enum, T> Value = new ResolverM04D03di<T>();

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

private sealed class ResolverM03D28di_0000: global::Pure.DI.IResolver<Enum, Pure.DI.Benchmarks.Model.CompositionRoot>
private sealed class ResolverM04D03di_0000: global::Pure.DI.IResolver<Enum, Pure.DI.Benchmarks.Model.CompositionRoot>
{
public Pure.DI.Benchmarks.Model.CompositionRoot Resolve(Enum composition)
{
Expand Down
Loading

0 comments on commit f20a9ae

Please sign in to comment.