-
Notifications
You must be signed in to change notification settings - Fork 36
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
Support nullable parameters #147
Conversation
src/Jab.FunctionalTests.Common/Mocks/ServiceImplementationWithNullable.cs
Outdated
Show resolved
Hide resolved
Added diagnostic test |
Do you think that |
I think the warning should be something like "{} parameter will never be null when constructing using a service provider. Add a default value to make the service reference optional." and fire for all nullable required parameters. It feels like there is no point in defining a nullable non-optional parameter. Feel free to pull the warning out of this PR, I will be away from the computer for more than a week, so I'd rather get this PR in and you unblocked. |
I've created 2 diagnostics, one for non-registered nullable dependency and other for registered nullable dependency. And changed CodeWriter to always display type as not null. |
Great work! Thank you! |
Out it 0.8.7 |
Hi, could I ask about the reasoning behind "JAB0014: X parameter to construct Y will never be null when constructing using a service provider." my class that raises the warning looks like this: public Foo(Bar? service, Bar2 service2){
} I use Jab for my application, but construct the service manually in test cases. The warning is absolutely correct Jab will always provide a service for the nullable parameter but for convenience in test cases this parameter is optional. |
The issue or feature being addressed
Details on the issue fix or feature implementation
JAB0013
andJAB0014
requesting to define a default value for nullable dependency