maui icon indicating copy to clipboard operation
maui copied to clipboard

Clean up / Linq removal

Open imememani opened this issue 1 year ago • 5 comments

Description of Change

Clean up (using switch in place of if chain) for better readability and used more up to date .NET syntax as well as removing the usage of LINQ.

Issues Fixed

N/A

Fixes #

N/A

imememani avatar Dec 06 '23 18:12 imememani

Hey there @imememani! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

ghost avatar Dec 06 '23 18:12 ghost

@dotnet-policy-service agree

imememani avatar Dec 06 '23 18:12 imememani

Switch expressions are much cleaner IMHO.

I recommend changing your switch statements to something like below (haven't tested the below code myself, just wrote it from my phone):

return strValue switch
{
    _ when Compare(nameof(Linear)) => Linear,
    _ when Compare(nameof(SinIn)) => SinIn,
    //  and so on...
    _ => "put default value here"
};

And add this local method for case insensitive comparison:

bool Compare(string right) => string.Equals(strValue, right, StringComparison.OrdinalIgnoreCase);

akhanalcs avatar Dec 06 '23 23:12 akhanalcs

@affableashish Great suggestion, it does look much more readable and allows case to be ignored, I've pushed some changes to factor the suggestions in.

imememani avatar Dec 10 '23 18:12 imememani

Is there a reason to not use Enum.TryParse (with case-insensitive bool parameter) and ToString instead of the two switch statements?

albyrock87 avatar Jan 04 '24 18:01 albyrock87

/rebase

mattleibow avatar Jun 06 '24 14:06 mattleibow

/azp run

mattleibow avatar Jun 06 '24 15:06 mattleibow

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Jun 06 '24 15:06 azure-pipelines[bot]