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

Fix: 889 DryIoC creating instances at point of registration #934

Merged
merged 5 commits into from
Jul 14, 2022

Conversation

dpvreony
Copy link
Member

@dpvreony dpvreony commented Jul 13, 2022

What kind of change does this PR introduce?

Closes #889, but needs a look at as it feels dirty.
It stops the instant creation of objects during registration
But it also needs to use a cast because the factory func returns object, and DryIoC throws. So there's an expression used to do the casting.

The alternative might be to break the interface and add a generic Register method? (instead of the static extension that does to typeof(T) and ultimately ends up as Func<object?>)

I have also removed the NullServiceType registration as I can't see a way out of any pain of using it with DryIoC.

What is the current behavior?

objects registered via splat into DryIoc are instantly instantiated

What is the new behavior?

Delayed creation

What might this PR break?

Usages of null type registrations with DryIoC (but did it ever work correctly?)

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:

@codecov
Copy link

codecov bot commented Jul 13, 2022

Codecov Report

Merging #934 (ca698ed) into main (36af7e2) will increase coverage by 0.20%.
The diff coverage is 73.07%.

@@            Coverage Diff             @@
##             main     #934      +/-   ##
==========================================
+ Coverage   75.00%   75.21%   +0.20%     
==========================================
  Files          91       92       +1     
  Lines        4885     4894       +9     
==========================================
+ Hits         3664     3681      +17     
+ Misses       1221     1213       -8     
Impacted Files Coverage Δ
src/Splat.Common.Test/ViewThatShouldNotLoad.cs 40.00% <40.00%> (ø)
src/Splat.DryIoc/DryIocDependencyResolver.cs 85.96% <80.95%> (+1.41%) ⬆️
src/Splat/Logging/FullLoggerExtensions.cs 28.57% <0.00%> (+0.95%) ⬆️
src/Splat/Logging/WrappingFullLogger.cs 65.58% <0.00%> (+1.29%) ⬆️
...ceMonitoring/DefaultFeatureUsageTrackingSession.cs 72.00% <0.00%> (+4.00%) ⬆️
src/Splat/Logging/WrappingPrefixLogger.cs 70.58% <0.00%> (+5.88%) ⬆️
.../Splat.SimpleInjector/SimpleInjectorInitializer.cs 63.04% <0.00%> (+10.86%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 36af7e2...ca698ed. Read the comment docs.

Copy link
Member

@ChrisPulman ChrisPulman left a comment

Choose a reason for hiding this comment

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

NullServiceType removed

@ChrisPulman ChrisPulman merged commit 8b4e557 into main Jul 14, 2022
@ChrisPulman ChrisPulman deleted the issue-889 branch July 14, 2022 00:29
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] DryIoc resolves Views upon registration
2 participants