Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed first-chance HandlerException for optional parameters #450

Merged
merged 2 commits into from
Oct 29, 2018

Conversation

jnm2
Copy link
Contributor

@jnm2 jnm2 commented Oct 26, 2018

Fixes #449.

handler = TryGetHandlerFromKernel(dependency, context);
}
catch (HandlerException exception)
if (!TryGetHandlerFromKernel(dependency, context, out var handler))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return false case looks almost identical to the handler = null; return true case below it.
There's a potentially a better factoring to indicate which of the two messages should be used?

@jnm2 jnm2 force-pushed the kill_first_chance_exceptions branch from 6e82f54 to 1f642df Compare October 27, 2018 16:43
@jnm2 jnm2 force-pushed the kill_first_chance_exceptions branch from 1f642df to 93ce46c Compare October 27, 2018 16:45
{
handlers = kernel.GetHandlers(dependency.TargetItemType);
}
catch (HandlerException)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this a valid refactoring, we have to be sure that this method can't throw HandlerException indirectly.
If you know that kernel.GetHandlers would not throw HandlerException, we can remove the try. Same for the try above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefaultNamingSubSystem doesn't appear to, however a custom INamingSubSystem or IHandlersFilter may. Sounds like a sensible way to write it.

Copy link
Member

@jonorossi jonorossi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to merge. Could you update the changelog.

@jnm2 jnm2 force-pushed the kill_first_chance_exceptions branch from 93ce46c to 74b1999 Compare October 29, 2018 12:38
CHANGELOG.md Outdated
@@ -33,6 +33,9 @@ Breaking Changes:
- Changed `IComponentModelBuilder.BuildModel` to use `Arguments` instead of `IDictionary`
- Changed `ILazyComponentLoader.Load` to use `Arguments` instead of `IDictionary`

Bugfixes:
- Fixed first-chance HandlerException for optional parameters (@jnm2, #450)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jnm2 You've added this inside the 5.0.0-beta001 section which has been released.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I'm sorry. Fixed!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, thanks.

@jnm2 jnm2 force-pushed the kill_first_chance_exceptions branch from 74b1999 to 82f86fb Compare October 29, 2018 13:24
@jonorossi jonorossi merged commit 603d78d into castleproject:master Oct 29, 2018
@jonorossi jonorossi added this to the v5.0 milestone Oct 29, 2018
@jnm2 jnm2 deleted the kill_first_chance_exceptions branch October 29, 2018 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants