[xbuild] Replace string.ToLower() comparison with OrdinalIgnoreCase comparison
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=10946
The scenario is the "turkish-i problem": Have an MSBuild Task Assembly
which calls ITaskItem.GetMetadata("Identity") (like, oh, the
Xamarin.Android build system...). Run in a Turkish locale (tr-TR), and
things fail badly:
Error executing task AndroidComputeResPaths: System.ArgumentException: Invalid reserved metadata name
at Mono.XBuild.Utilities.ReservedNameUtils.GetReservedMetadata (System.String itemSpec, System.String metadataName, IDictionary metadata) [0x00000] in <filename unknown>:0
at Microsoft.Build.Utilities.TaskItem.GetMetadata (System.String metadataName) [0x00000] in <filename unknown>:0
at Xamarin.Android.Tasks.AndroidComputeResPaths.Execute () [0x00000] in <filename unknown>:0
at Microsoft.Build.BuildEngine.TaskEngine.Execute () [0x00000] in <filename unknown>:0
at Microsoft.Build.BuildEngine.BuildTask.Execute () [0x00000] in <filename unknown>:0
Wat? Well, in tr-TR, "Identity".ToLower() is "ıdentity", which
doesn't match match anything in GetReservedMetadata()'s `switch`
statement, so it throws an ArgumentException. *BOOM*.
So, if you need a culture-invariant comparison, USE IT.
Related: We could have just s/ToLower/ToLowerInvariant/g, which would
have fixed the problem, but would still result in lots of string
temporaries that aren't really necessary. Use the appropriate
string.Compare() or string.Equals() methods instead to avoid the
string temporary as well.