Skip to content

Commit

Permalink
Memory optimization from #919: Autofac.Core.Resolving.CircularDepende…
Browse files Browse the repository at this point in the history
…ncyDetector.
  • Loading branch information
tillig committed Aug 16, 2018
1 parent 06a0bbf commit fc17758
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Autofac/Core/Resolving/CircularDependencyDetector.cs
Expand Up @@ -63,8 +63,13 @@ public static void CheckForCircularDependency(IComponentRegistration registratio
throw new DependencyResolutionException(string.Format(CultureInfo.CurrentCulture, CircularDependencyDetectorResources.MaxDepthExceeded, registration));

// Checks for circular dependency
if (activationStack.Any(a => a.ComponentRegistration == registration))
throw new DependencyResolutionException(string.Format(CultureInfo.CurrentCulture, CircularDependencyDetectorResources.CircularDependency, CreateDependencyGraphTo(registration, activationStack)));
foreach (var a in activationStack)
{
if (a.ComponentRegistration == registration)
{
throw new DependencyResolutionException(string.Format(CultureInfo.CurrentCulture, CircularDependencyDetectorResources.CircularDependency, CreateDependencyGraphTo(registration, activationStack)));
}
}
}
}
}

0 comments on commit fc17758

Please sign in to comment.