Skip to content

Commit

Permalink
Don't assume IValidatable to be validatable per-type, but per-instance
Browse files Browse the repository at this point in the history
This is required e.g. for stuff dynamically set up in prefabs
  • Loading branch information
sbergen committed Jan 13, 2025
1 parent 2425ace commit 62953e0
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class DiContainer : IInstantiator
readonly Queue<BindStatement> _currentBindings = new Queue<BindStatement>();
readonly List<BindStatement> _childBindings = new List<BindStatement>();

readonly HashSet<Type> _validatedTypes = new HashSet<Type>();
readonly List<IValidatable> _validationQueue = new List<IValidatable>();

#if !NOT_UNITY3D
Expand Down Expand Up @@ -192,16 +191,13 @@ object CreateLazyBinding(InjectContext context)

public void QueueForValidate(IValidatable validatable)
{
// Don't bother adding to queue if the initial resolve is already completed
if (!_hasResolvedRoots)
if (_hasResolvedRoots)
{
var concreteType = validatable.GetType();

if (!_validatedTypes.Contains(concreteType))
{
_validatedTypes.Add(concreteType);
_validationQueue.Add(validatable);
}
Log.Error($"Trying to queue '{validatable.GetType().PrettyName()}' for validation after resolving");
}
else
{
_validationQueue.Add(validatable);
}
}

Expand Down

0 comments on commit 62953e0

Please sign in to comment.