Create Nullable IValueConverters, and Add Nullable Static Analyzers#200
Merged
TheCodeTraveler merged 9 commits intomainfrom Nov 23, 2021
Merged
Create Nullable IValueConverters, and Add Nullable Static Analyzers#200TheCodeTraveler merged 9 commits intomainfrom
IValueConverters, and Add Nullable Static Analyzers#200TheCodeTraveler merged 9 commits intomainfrom
Conversation
ICommunityToolkitValueConverter, and Add Nullable Static Analyzers
ICommunityToolkitValueConverter, and Add Nullable Static AnalyzersIValueConverters, and Add Nullable Static Analyzers
Takes advantage of the Nullable Static Analysis
VladislavAntonyuk
approved these changes
Nov 23, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
Create Nullable
IValueConvertersICommunityToolkitValueConverter
ICommunityToolkitIMultiValueConverter
This PR creates
ICommunityToolkitValueConverterandICommunityToolkitIMultiValueConverter.The MAUI team has not yet enabled nullable (
#nullable enable) forMicrosoft.Maui.Controls.IValueConverter. This means that, until they enable nullable, we have to assume that a nullable value can be passed into the methods and that a nullable value is required to return.The best way to enforce this going forward is to create our own nullable implementations of IValueConverter that will be used by each Converter in the toolkit.
We can also leverage
[return: Null]to let our users know that we are not returningnullwhen we are 100% sure thatConvertalways returns a non-null value. For example,BoolToObjectConverter.ConvertBackwill always return abool.Once the MAUI team enables nullable on
IValueConverter, and they've decided which parameters should/shouldn't be null forConvertandConvertBack, we can revisitICommunityToolkitValueConverterandICommunityToolkitIMultiValueConverter.Nullable Static Analyzers
This PR has a secondary goal of implementing Nullable Static Analyzers.
We have Nullable enabled by default, and, as responsible library maintainers, we owe a responsibility to our users to always handle
nullproperly to make their lives easier.Detailed Solution
TBD