Skip to content

Fix handling of parameters with default null #85

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

paramamue
Copy link

This in an attempt of improving handling of nullable parameters.
In our solution at work, all projects have <Nullable>disable</Nullable>. In some of the generated interfaces, we receive the warning warning CS8625: Cannot convert null literal to non-nullable reference type., because the interfaces are generated with #nullable enable and have parameters like string input = null.
I've changed the generator so that these parameters activate the nullable mode and add a ? if it's missing.
There were some changes in the tests I didn't expect, e.g. Misc.CustomNameSpace, but I think they're all correct like this.

Note that for 100% correctness, I think we would need to check the semantic model for every method and get the nullable context to decide if a parameter is actually nullable or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant