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

Prevent first-chance exceptions #557

Open
dotnetjunkie opened this Issue May 16, 2018 · 2 comments

Comments

1 participant
@dotnetjunkie
Collaborator

dotnetjunkie commented May 16, 2018

There are still a few places in the Simple Injector code bases that swallow exceptions and continue. Newer versions of Visual Studio, however, show first chance exceptions by default in the debugger, and this behavior is quite hard to disable.

Because of this, it can lead to confusing situations, where users think there is a problem they need to fix, while everything is actually working fine.

Whenever possible, these first chance exceptions should be prevented.

@dotnetjunkie dotnetjunkie added the task label May 16, 2018

@dotnetjunkie dotnetjunkie modified the milestones: v5.0, Backlog May 16, 2018

@dotnetjunkie dotnetjunkie modified the milestones: Backlog, v4.4 May 29, 2018

@dotnetjunkie

This comment has been minimized.

Collaborator

dotnetjunkie commented Jul 14, 2018

There are four places in particular that swallor exceptions:

  • GenericTypeBuilder.IsImplementationApplicableToEveryGenericType
  • GenericTypeBuilder.BuildClosedGenericImplementationBasedOnMatchingServiceType
  • Container.SelectImplementationTypeConstructorOrNull
  • ContainerOptions.IsConstructableType

The first two, inside the GenericTypeBuilder, are places that can't be easily fixed. They work around corner case scenario's when dealing with generic type constraints.

The last two, however, are the cases that should be fixed.

@dotnetjunkie

This comment has been minimized.

Collaborator

dotnetjunkie commented Jul 17, 2018

Problem with both the SelectImplementationTypeConstructorOrNull and IsConstructableType methods, however, is that they wrap a call to IConstructorResolutionBehavior.GetConstructor, which by design either returns a valid constructor or throws an exception.

These fixes can, therefore, only be made by changing IConstructorResolutionBehavior and thus introducing a breaking change.

@dotnetjunkie dotnetjunkie modified the milestones: v4.4, v5.0 Jul 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment