Skip to content

[XABT] Replace String.Compare calls with a common helper method #10273

@grendello

Description

@grendello

Android framework version

net10.0-android (Preview)

Description

In the Xamarin.Android.Build.Tasks sources, we call the String.Compare method multiple times, repeating the same parameters. This runs counter to the DRY (Don't Repeat Yourself) principle and we should replace those calls with a helper method.

To do this, follow these steps:

  1. Find all String.Compare calls in the src/Xamarin.Android.Build.Tasks/Tasks/ and src/Xamarin.Android.Build.Tasks/Utilities/ directories, scanning all the .cs files.
  2. Generate a helper method in the MonoAndroidHelper class which will replace the calls found in above.
    The helper method must accept two string arguments and an argument specifying the mode of comparison, with default value set to StringComparison.OrdinalIgnoreCase. It will call String.Equals on one of the strings, passing the other as parameter together with comparison mode. Make sure none of the strings are null before using it.
    The method will return a bool value indicating whether comparison was successful or not.
    Place the helper method in the src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.Basic.cs file
  3. Replace all String.Compare calls with a call to the new helper method, omitting comparison mode argument unless it's different to StringComparison.OrdinalIgnoreCase.

Metadata

Metadata

Assignees

Labels

needs-triageIssues that need to be assigned.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions