Use LastIndexOf in MSBuild for a single char#60450
Conversation
No need to call LastIndexOfAny for a single char. MSBuild doesn't (yet) have a shortcut for evaluating LastIndexOfAny, so it causes first-chance MissingMethodExceptions in MSBuild evaluator. Also strictly speaking passing a string to LastIndexOfAny doesn't make sense since it accepts a char array.
|
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
|
See related: dotnet/msbuild#6963 |
|
It was changed from LastIndexOf to LastIndexOfAny in #31701, then this code moved around.
is it non-fatal? I asked because it seems to be working so far. |
|
Yes the MSBuild "binder" is a bunch of reflection heuristics, some of which involve first chance exceptions, preceded by a hard coded list of common and builtin methods (like LastIndexOf) There wasn't a convenient binder around at the time so we wrote this custom one. |
|
I found the origin, dotnet/coreclr@9497910#diff-5076575030d3845a817fab2cd48d02742f0f90f479dcf582057a869f003f5502R11 That made a bit more sense. IIRC that also caused a first chance exception. |
No need to call LastIndexOfAny for a single char. MSBuild doesn't (yet) have a shortcut for evaluating LastIndexOfAny, so it causes first-chance MissingMethodExceptions in MSBuild evaluator.
Also strictly speaking passing a string to LastIndexOfAny doesn't make sense since it accepts a char array.