-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Net 10] - Annotated remaining Converter classes for nullability - 2 #30777
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
Conversation
|
Hey there @@NirmalKumarYuvaraj! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run MAUI-UITests-public |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request enhances nullability annotations and type safety across multiple TypeConverter classes in the .NET MAUI Controls framework. The changes enable nullable reference types, improve null-checking patterns, and update code structure for better maintainability while ensuring the public API documentation reflects these improvements.
- Removes
#nullable disabledirectives and adds nullable annotations to method parameters and return types - Replaces legacy null checking patterns with modern C# patterns (
is not null,is null) - Improves code structure by adding braces to conditional blocks for consistency
- Updates PublicAPI.Unshipped.txt files across all platforms to reflect the new nullable method signatures
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| WebViewSourceTypeConverter.cs | Added nullable annotations and modernized null checking patterns |
| UriTypeConverter.cs | Updated with nullable reference types and improved null handling |
| TransformTypeConverter.cs | Enhanced with nullable annotations and structured conditional blocks |
| PointCollectionConverter.cs | Added comprehensive null validation and nullable type annotations |
| BoundsTypeConverter.cs | Improved null safety and added braces to conditional statements |
| ItemsLayoutTypeConverter.cs | Enhanced null checking and added structured conditional blocks |
| CarouselLayoutTypeConverter.cs | Updated with nullable annotations and improved code structure |
| PublicAPI.Unshipped.txt (multiple platforms) | Updated to reflect new nullable method signatures across all target frameworks |
| var strValue = value?.ToString(); | ||
| string[] points = strValue.Split(new char[] { ' ', ',' }); | ||
| if (string.IsNullOrWhiteSpace(strValue)) | ||
| { | ||
| throw new InvalidOperationException("Cannot convert null or empty string into PointCollection."); | ||
| } | ||
|
|
||
| string[] points = strValue!.Split(new char[] { ' ', ',' }); |
Copilot
AI
Jul 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The null-forgiving operator (!) is used after already checking for null or whitespace. Consider restructuring the logic to avoid the need for the null-forgiving operator, which can mask potential null reference issues.
Copilot uses AI. Check for mistakes.
Does this PR really contributes to this issue? |
…Collection (#30823) * Revert the exception Reverts part of https://github.com/dotnet/maui/pull/30777/files * Update src/Controls/src/Core/Shapes/PointCollectionConverter.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
This pull request improves type conversion in several classes by adding nullable reference type annotations, enhancing null-checking, and refining conversion logic. Additionally, it updates the public API documentation to reflect these changes.
Enhancements to Type Converters:
CarouselLayoutTypeConverter,ItemsLayoutTypeConverter, andBoundsTypeConverterto include nullable reference type annotations for method parameters and return types. This ensures better null-safety and aligns with modern C# practices. [1] [2] [3]ConvertFromandConvertTomethods across these converters to handle potential null values more explicitly. For example:ArgumentNullExceptionfor null string values inItemsLayoutTypeConverter.is not nullandis nullpatterns for better readability and safety.Conversion Logic Refinements:
ItemsLayoutTypeConverterandBoundsTypeConverterto include additional checks and structured return values:GridItemsLayoutandRectcreation based on input strings. [1] [2]Updates to Public API Documentation:
PublicAPI.Unshipped.txtfiles for Android and iOS to reflect the changes in nullable annotations and method signatures for the affected type converters. This ensures that the public API documentation is consistent with the updated codebase. [1] [2]These changes improve code quality, enhance null-safety, and ensure consistency across the type conversion logic and public API documentation.
Issues Fixed
Contributes to #28660