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

feature resolvers changed to allow registration of null with a value type #721

Merged
merged 15 commits into from
Jul 25, 2021

Conversation

ChrisPulman
Copy link
Member

@ChrisPulman ChrisPulman commented Jun 30, 2021

What kind of change does this PR introduce?

fix for dryloc resolver
feature for some resolvers to use a null serviceType and a Func of value type to be registered

What is the current behaviour?

Presently only one resolver can resolve null service types
Dryloc resolver fails to resolve multiple services with the same type and differing contracts

What is the new behaviour?

increased the number of resolvers that can resolve Func of value type.
Dryloc resolver now resolves multiple services with the same type and differing contracts

What might this PR break?

people using dryloc may experience a different item being resolved now compared to previously, but will now return the correct service

Please check if the PR fulfils these requirements

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

Other information:

Test projects have the Func of value type and null serviceType applied

FuncDependencyResolver and SimpleInjectorDependencyResolver do not currently support Func of value type

Presently Getservice casts to a nullable return value object? or T?, now returns the value as a object or T
@codecov
Copy link

codecov bot commented Jun 30, 2021

Codecov Report

Merging #721 (a8a885b) into main (c54ef66) will increase coverage by 0.89%.
The diff coverage is 80.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #721      +/-   ##
==========================================
+ Coverage   73.31%   74.20%   +0.89%     
==========================================
  Files          98       99       +1     
  Lines        4835     4967     +132     
==========================================
+ Hits         3545     3686     +141     
+ Misses       1290     1281       -9     
Impacted Files Coverage Δ
src/Splat.Prism/SplatContainerExtension.cs 53.52% <0.00%> (ø)
...rc/Splat/ServiceLocation/FuncDependencyResolver.cs 30.00% <26.92%> (-4.55%) ⬇️
...SimpleInjector/SimpleInjectorDependencyResolver.cs 65.11% <55.55%> (-2.46%) ⬇️
.../Splat.SimpleInjector/SimpleInjectorInitializer.cs 52.17% <57.14%> (+11.54%) ⬆️
src/Splat.Autofac/AutofacDependencyResolver.cs 78.21% <82.05%> (+2.87%) ⬆️
...DependencyInjection/MicrosoftDependencyResolver.cs 86.07% <92.30%> (+2.43%) ⬆️
.../Splat/ServiceLocation/ModernDependencyResolver.cs 69.23% <93.93%> (+19.81%) ⬆️
src/Splat.DryIoc/DryIocDependencyResolver.cs 93.20% <100.00%> (+24.31%) ⬆️
src/Splat.Ninject/NinjectDependencyResolver.cs 83.92% <100.00%> (+9.35%) ⬆️
...pleInjector/TransientSimpleInjectorRegistration.cs 100.00% <100.00%> (ø)
... and 8 more

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 c54ef66...a8a885b. Read the comment docs.

@glennawatson
Copy link
Contributor

As discussed offline GetService probably should return nullable to indicate non registration or deliberate null.

… null if not valid

housekeeping on tests
fix ILogManager_Resolvable test
matched the GetServices to also return IEmeumerable<object?>
@ChrisPulman ChrisPulman changed the title fix GetService changed to return a non nullable fix GetServices changed to return a nullable Jul 1, 2021
@dpvreony
Copy link
Member

dpvreony commented Jul 7, 2021

i've done a branch f50a072 to think through the getservices bit. will look again over weekend

@dpvreony dpvreony self-assigned this Jul 9, 2021
@ChrisPulman ChrisPulman deleted the fix_GetServiceShouldntReturnANullable branch July 11, 2021 16:23
@dpvreony dpvreony restored the fix_GetServiceShouldntReturnANullable branch July 12, 2021 21:31
@dpvreony dpvreony reopened this Jul 12, 2021
@dpvreony
Copy link
Member

re-opening so i can track what i am looking at on getservices against this branch rather than diff master

ChrisPulman and others added 4 commits July 17, 2021 01:35
* WIP: tweaks for getservices

* warnings as errors for nullable

* attempt to tidy up getservices warnings

* remove bak files

* change autofac to use Enumerable.Empty
@ChrisPulman ChrisPulman marked this pull request as draft July 21, 2021 07:15
found an issue with Dryloc resolver with contracts, returns the wrong instance
@ChrisPulman ChrisPulman changed the title fix GetServices changed to return a nullable feature resolvers changed to allow registration of null with a value type Jul 21, 2021
items registered with Dryloc resolver were not retained but overwritten where multiple registrations were made with the same serviceType and different contracts
@ChrisPulman ChrisPulman marked this pull request as ready for review July 22, 2021 01:07
@glennawatson glennawatson merged commit 243dbfd into main Jul 25, 2021
@glennawatson glennawatson deleted the fix_GetServiceShouldntReturnANullable branch July 25, 2021 21:09
@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 Nov 23, 2021
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.

3 participants