KEMBAR78
[Net 10] - Annotated remaining Converter classes for nullability - 2 by NirmalKumarYuvaraj · Pull Request #30777 · dotnet/maui · GitHub
Skip to content

Conversation

NirmalKumarYuvaraj
Copy link
Contributor

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:

  • Updated CarouselLayoutTypeConverter, ItemsLayoutTypeConverter, and BoundsTypeConverter to 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]
  • Improved null-checking logic in ConvertFrom and ConvertTo methods across these converters to handle potential null values more explicitly. For example:
    • Added ArgumentNullException for null string values in ItemsLayoutTypeConverter.
    • Used is not null and is null patterns for better readability and safety.

Conversion Logic Refinements:

  • Refined conversion logic in ItemsLayoutTypeConverter and BoundsTypeConverter to include additional checks and structured return values:
    • Added braces for conditional blocks to improve readability and maintainability. [1] [2]
    • Enhanced handling of GridItemsLayout and Rect creation based on input strings. [1] [2]

Updates to Public API Documentation:

  • Updated the PublicAPI.Unshipped.txt files 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

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jul 23, 2025
@dotnet-policy-service
Copy link
Contributor

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.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jul 23, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@rmarinho rmarinho added this to the .NET 10.0-preview7 milestone Jul 23, 2025
@NirmalKumarYuvaraj NirmalKumarYuvaraj marked this pull request as ready for review July 24, 2025 11:18
@Copilot Copilot AI review requested due to automatic review settings July 24, 2025 11:18
@NirmalKumarYuvaraj NirmalKumarYuvaraj requested a review from a team as a code owner July 24, 2025 11:18
Copy link
Contributor

@Copilot Copilot AI left a 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 disable directives 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

Comment on lines 26 to +32
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[] { ' ', ',' });
Copy link

Copilot AI Jul 24, 2025

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.

@rmarinho rmarinho merged commit 5521734 into dotnet:net10.0 Jul 24, 2025
58 of 60 checks passed
@MartyIX
Copy link
Contributor

MartyIX commented Jul 24, 2025

Issues Fixed

Contributes to #28660

Does this PR really contributes to this issue?

@dotnet dotnet deleted a comment from azure-pipelines bot Jul 24, 2025
PureWeen pushed a commit that referenced this pull request Jul 25, 2025
…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>
@PureWeen PureWeen added the area-xaml XAML, CSS, Triggers, Behaviors label Aug 19, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants