@@ -3199,7 +3199,6 @@ public Expression ToExpression<S>(S state, Func<S, object, Expression> fallbackC
3199
3199
///<summary>Hides/wraps object with disposable interface.</summary>
3200
3200
public sealed class HiddenDisposable
3201
3201
{
3202
- // todo: @perf use UnsafeAccessAttribute to avoid reflection
3203
3202
internal static ConstructorInfo Ctor = typeof(HiddenDisposable).GetConstructors()[0];
3204
3203
internal static FieldInfo ValueField = typeof(HiddenDisposable).GetField(nameof(Value));
3205
3204
/// <summary>Wrapped value</summary>
@@ -3236,7 +3235,7 @@ public static bool TryInterpretAndUnwrapContainerException(IResolverContext r, E
3236
3235
// and we will be operating with its Value only).
3237
3236
//
3238
3237
// Then traverse the scope items and find the first NoItem entry for the exceptional dependency.
3239
- // The first NoItem entry will be the one for the exception because Scope (except for the Singletons Scope) is
3238
+ // The first NoItem entry will be the one for the exception because Scope is
3240
3239
// not supposed to be modified concurrently - so only one NoItem entry is expected. Read-on for more the details.
3241
3240
//
3242
3241
// If found, then try to set the exception into the entry Value,
@@ -3247,17 +3246,16 @@ public static bool TryInterpretAndUnwrapContainerException(IResolverContext r, E
3247
3246
// but it is not a problem, because it will be overriden by the successful resolution - right?
3248
3247
// Or if unsuccessful, we may get the wrong exception, but it is even more unlikely the case.
3249
3248
// It is unlikely in the first place because the majority of cases the scope access is not concurrent.
3250
- // Comparing to the singletons where it is expected to be concurrent, but it does not addressed here.
3251
3249
//
3252
- var exSet = TrySetScopedItemException (r, ex);
3250
+ var exSet = TrySetScopedOrSingletonItemException (r, ex);
3253
3251
Debug.Assert(!exSet, $"The exception was not set in the scope item entry, ex message: {ex.Message}");
3254
3252
3255
3253
// todo: @improve should we try to `(ex as ContainerException)?.TryGetDetails(container)` here and include it into the cex message?
3256
3254
throw ex.TryRethrowWithPreservedStackTrace();
3257
3255
}
3258
3256
}
3259
3257
3260
- private static bool TrySetScopedItemException (IResolverContext r, Exception ex)
3258
+ private static bool TrySetScopedOrSingletonItemException (IResolverContext r, Exception ex)
3261
3259
{
3262
3260
ScopedItemException sex = null;
3263
3261
for (var s = r.CurrentScope; s != null; s = s.Parent)
@@ -3286,7 +3284,7 @@ static bool TryFindNoItemAndStoreWrappedException(IScope scope, Exception ex, re
3286
3284
// because the other thread has no way to notify us here of the wrong, because we are done already.
3287
3285
3288
3286
// So, slowing down and given a chance for the other thread to set the NoItem entry to the value.
3289
- Thread.Sleep(1); // per design, because Thead.Sleep(0) or Thread.Yield() are not reliable.
3287
+ Thread.Sleep(1); // per design, because Thead.Sleep(0) or Thread.Yield() are not reliable enough .
3290
3288
3291
3289
var actualValueWas = Interlocked.CompareExchange(ref entry.Value, sex, Scope.NoItem);
3292
3290
if (actualValueWas == Scope.NoItem)
0 commit comments