@@ -488,7 +488,7 @@ private object ResolveAndCacheKeyed(int serviceTypeHash, Type serviceType,
488
488
// Cache is missed, so get the factory and put it into cache:
489
489
ThrowIfRootContainerDisposed();
490
490
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);
492
492
var factory = ResolveFactory(request);
493
493
if (factory == null)
494
494
return null;
@@ -4827,7 +4827,7 @@ public static Expression GetRequestExpression(this IContainer container, Request
4827
4827
{
4828
4828
if (request.IsEmpty)
4829
4829
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
4831
4831
: Request.EmptyRequestExpr;
4832
4832
4833
4833
var flags = request.Flags | requestParentFlags;
@@ -10229,7 +10229,7 @@ internal static readonly RequestFlags InheritedFlags
10229
10229
new Request(null, null, 0, 0, null, default, null, null, null);
10230
10230
10231
10231
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
10233
10233
10234
10234
/// <summary>Empty request which opens resolution scope.</summary>
10235
10235
public static readonly Request EmptyOpensResolutionScope =
@@ -10259,22 +10259,41 @@ public static Request Create(Container container, ServiceInfo serviceInfo,
10259
10259
{
10260
10260
var parentServiceType = preResolveParent.ActualServiceType;
10261
10261
var parentDetails = preResolveParent.GetServiceDetails();
10262
- if (parentDetails != null && parentDetails != ServiceDetails.Default)
10262
+ if (parentDetails != null & parentDetails != ServiceDetails.Default)
10263
10263
serviceInfo = serviceInfo.InheritInfoFromDependencyOwner(parentServiceType, parentDetails, container, preResolveParent.FactoryType);
10264
10264
10265
10265
flags |= preResolveParent.Flags & InheritedFlags;
10266
10266
}
10267
10267
else
10268
10268
flags |= preResolveParent.Flags; //inherits the OpensResolutionScope flag
10269
10269
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));
10271
10271
10272
10272
// we are re-starting the dependency depth count from `1`
10273
10273
return new Request(container, preResolveParent, 1, 0, null, flags, serviceInfo, serviceInfo.GetActualServiceType(), inputArgExprs);
10274
10274
}
10275
10275
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)
10278
10297
{
10279
10298
if (serviceType != null && serviceType.IsOpenGeneric())
10280
10299
Throw.It(Error.ResolvingOpenGenericServiceTypeIsNotPossible, serviceType);
0 commit comments