maui
maui copied to clipboard
Clean up / Linq removal
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
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.
@dotnet-policy-service agree
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);
@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.
Is there a reason to not use Enum.TryParse
(with case-insensitive bool parameter) and ToString
instead of the two switch statements?
/rebase
/azp run
Azure Pipelines successfully started running 3 pipeline(s).