More robust CombinedServiceProvider #4182
Merged
+82
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch adds additional logic to guard against weird edge cases caused by the non-deterministic nature of LInQ + reflection.
Specifically, it adds more logic to a predicate (used by a utility method,
Utilities.CombinedServiceProvider.Any
) to ensure the correct overload ofEnumerable.Any
is selected. In a very small -- but impactful! -- percentage of deployments, the order of theMethodInfo
instances being processed changes. This change of order, though infrequent, leads to aTargetParameterCountException
when theMethodInfo
is ultimately invoked. Effectively, all this patch does is make certain assumptions explicit (namely, that we want to use the arity-1 overload rather than a different overload).This may (or may not) be related to the following issues:
But in any event, this was motivated by having three different services log run-time exceptions with the following stack trace:
Please note, the patch includes a (skipped) test which simulates the behavior against which the proposed changes will protect. As the actual issue occurs frequently enough to be unavoidable -- but not in a consistent and readily-reproducible fashion -- I hope this is sufficient (in lieu of an actual minimal reproduction).
Also, I am submitting this as a bugfix against the v11 branch, as that is what is currently deployed (we're hopeful for a small point-release in the near future 😉 ). However, I've noticed the v12 branch could also benefit from this patch.
Thanks!