Skip to content

Commit

Permalink
"fixed" #577 (improving the Validate error message)
Browse files Browse the repository at this point in the history
  • Loading branch information
dadhi committed May 26, 2023
1 parent cb6d8c7 commit 8859960
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/DryIoc/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14528,7 +14528,8 @@ public static readonly int
NoServiceTypesToValidate = Of(
"The `serviceTypes` passed to Validate method is null or empty. Please pass the type(s) you want to Validate."),
ValidateFoundErrors = Of(
"Validate found the errors, please check the ContainerException.CollectedExceptions for details."),
"Validate method found the errors, please check the ContainerException.CollectedExceptions for the details." + NewLine +
"If you see too many (unexpected) errors, try narrowing the resolution roots by passing the selected service types or the condition to the Validate(AndThrow) method."),
UnableToInterpretTheNestedLambda = Of(
"Unable to interpret the nested lambda with Body:" + NewLine + "{0}"),
WaitForScopedServiceIsCreatedTimeoutExpired = Of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public int Run()
Test_factory_extension_method_for_the_factory_with_the_service_key();

Test_factory_extension_method_GHIssue577();

return 3;
}

Expand Down Expand Up @@ -79,8 +80,11 @@ public void Test_factory_extension_method_GHIssue577()

container.Register<Foo>();

var errors = container.Validate();
// Assert.IsEmpty(errors); // todo: @fixme fails here with the root ILogger
var errorsAllAreRoots = container.Validate();
Assert.AreEqual(1, errorsAllAreRoots.Length); // fails for the non-root logger

var errorsForLogger = container.Validate(typeof(ILogger));
Assert.IsEmpty(errorsForLogger); // fine to validate a specific service

var log = container.Resolve<ILogger>();
Assert.IsNull(((SerilogLogger)log).TypeName);
Expand Down

0 comments on commit 8859960

Please sign in to comment.