-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Remove LINQ and reflection from EasingTypeConverter #19260
Conversation
Cleaned up the methods and added more up to date .NET syntax as well as removing the usage of LINQ.
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. |
As the switch makes use of nameof the usage of ToLowerInvariant is redundant.
@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); |
The value now returns an easing instead of a string (oops!), I have also implemented a local method to check case sensitive strings for the switch statement allowing the same functionality as previous.
@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 |
/rebase |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
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