Skip to content

Commit b2a9c72

Browse files
committed
@wip mangling with Request for #632
1 parent 2f66cac commit b2a9c72

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

src/DryIoc.Microsoft.DependencyInjection/DryIoc.Microsoft.DependencyInjection.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Product>DryIoc.Microsoft.DependencyInjection</Product>
77

88
<VersionPrefix>8.0.0</VersionPrefix>
9-
<VersionSuffix>preview-01</VersionSuffix>
9+
<VersionSuffix>preview-02</VersionSuffix>
1010

1111
<AssemblyName>$(Product)</AssemblyName>
1212
<AssemblyTitle>$(AssemblyName) $(TargetFramework)</AssemblyTitle>

src/DryIoc/Container.cs

+26-7
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ private object ResolveAndCacheKeyed(int serviceTypeHash, Type serviceType,
488488
// Cache is missed, so get the factory and put it into cache:
489489
ThrowIfRootContainerDisposed();
490490

491-
var request = Request.Create(this, serviceType, serviceKey, ifUnresolved, requiredServiceType, preResolveParent, default, args);
491+
var request = Request.Create(this, ServiceInfo.Of(serviceType, requiredServiceType, ifUnresolved, serviceKey), preResolveParent, default, args);
492492
var factory = ResolveFactory(request);
493493
if (factory == null)
494494
return null;
@@ -4827,7 +4827,7 @@ public static Expression GetRequestExpression(this IContainer container, Request
48274827
{
48284828
if (request.IsEmpty)
48294829
return (requestParentFlags & RequestFlags.OpensResolutionScope) != 0
4830-
? Field(typeof(Request).GetField(nameof(Request.EmptyOpensResolutionScope))) // we mat not refactor it to readonly field because it is rarely used
4830+
? Field(typeof(Request).GetField(nameof(Request.EmptyOpensResolutionScope))) // we may not refactor it to readonly field because it is rarely used
48314831
: Request.EmptyRequestExpr;
48324832

48334833
var flags = request.Flags | requestParentFlags;
@@ -10229,7 +10229,7 @@ internal static readonly RequestFlags InheritedFlags
1022910229
new Request(null, null, 0, 0, null, default, null, null, null);
1023010230

1023110231
internal static readonly Expression EmptyRequestExpr =
10232-
Field(typeof(Request).GetField(nameof(Empty)));
10232+
Field(typeof(Request).GetField(nameof(Empty))); // todo: @perf UnsafeAccessAttribute, wrap this thing into a util method
1023310233

1023410234
/// <summary>Empty request which opens resolution scope.</summary>
1023510235
public static readonly Request EmptyOpensResolutionScope =
@@ -10259,22 +10259,41 @@ public static Request Create(Container container, ServiceInfo serviceInfo,
1025910259
{
1026010260
var parentServiceType = preResolveParent.ActualServiceType;
1026110261
var parentDetails = preResolveParent.GetServiceDetails();
10262-
if (parentDetails != null && parentDetails != ServiceDetails.Default)
10262+
if (parentDetails != null & parentDetails != ServiceDetails.Default)
1026310263
serviceInfo = serviceInfo.InheritInfoFromDependencyOwner(parentServiceType, parentDetails, container, preResolveParent.FactoryType);
1026410264

1026510265
flags |= preResolveParent.Flags & InheritedFlags;
1026610266
}
1026710267
else
1026810268
flags |= preResolveParent.Flags; //inherits the OpensResolutionScope flag
1026910269

10270-
var inputArgExprs = inputArgs?.Map(a => Constant(a)); // todo: @check what happens if `a == null`, does the `object` type for is fine
10270+
var inputArgExprs = inputArgs?.Map(static a => Constant(a));
1027110271

1027210272
// we are re-starting the dependency depth count from `1`
1027310273
return new Request(container, preResolveParent, 1, 0, null, flags, serviceInfo, serviceInfo.GetActualServiceType(), inputArgExprs);
1027410274
}
1027510275

10276-
/// <summary>Creates the Resolve request. The container initiated the Resolve is stored within request.</summary>
10277-
public static Request CreateResolutionRoot(Container container, Type serviceType, IfUnresolved ifUnresolved = IfUnresolved.Throw)
10276+
/// <summary>Creates the Resolve request for the resolution root service.</summary>
10277+
public static Request CreateResolutionRoot(Container container, ServiceInfo serviceInfo,
10278+
object[] inputArgs = null)
10279+
{
10280+
Debug.Assert(serviceInfo != null);
10281+
10282+
var serviceType = serviceInfo.ServiceType;
10283+
if (serviceType != null && serviceType.IsOpenGeneric())
10284+
Throw.It(Error.ResolvingOpenGenericServiceTypeIsNotPossible, serviceType);
10285+
10286+
var inputArgExprs = inputArgs?.Map(a => Constant(a));
10287+
10288+
var req = RentRequestOrNull();
10289+
return req == null
10290+
? new Request(container, Empty, 1, 0, null, RequestFlags.IsResolutionCall, serviceInfo, serviceInfo.GetActualServiceType(), inputArgExprs)
10291+
: req.SetServiceInfo(container, Empty, 1, 0, null, RequestFlags.IsResolutionCall, serviceInfo, serviceInfo.GetActualServiceType(), inputArgExprs);
10292+
}
10293+
10294+
/// <summary>Creates the Resolve request for the resolution root service.</summary>
10295+
public static Request CreateResolutionRoot(Container container, Type serviceType,
10296+
IfUnresolved ifUnresolved = IfUnresolved.Throw)
1027810297
{
1027910298
if (serviceType != null && serviceType.IsOpenGeneric())
1028010299
Throw.It(Error.ResolvingOpenGenericServiceTypeIsNotPossible, serviceType);

src/DryIoc/DryIoc.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Product>DryIoc</Product>
77

88
<VersionPrefix>6.0.0</VersionPrefix>
9-
<VersionSuffix>preview-06</VersionSuffix>
9+
<VersionSuffix>preview-07</VersionSuffix>
1010

1111
<AssemblyName>$(Product)</AssemblyName>
1212
<AssemblyTitle>$(AssemblyName) $(TargetFramework)</AssemblyTitle>

test/DryIoc.TestRunner/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class Program
99
{
1010
public static void Main()
1111
{
12-
new GHIssue631_Conditional_registrations().Run();
12+
// new GHIssue631_Conditional_registrations().Run();
1313

1414
RunAllTests();
1515

0 commit comments

Comments
 (0)