From f8cb6a0e691d5c16ebdc4f27b4d7e9038d9dc738 Mon Sep 17 00:00:00 2001 From: Kirill Osenkov Date: Thu, 14 Oct 2021 17:53:12 -0700 Subject: [PATCH] Use LastIndexOf in MSBuild for a single char 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. --- Directory.Build.props | 2 +- eng/SourceBuild.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 42d713f8e0d22d..9a7215424f7348 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -120,7 +120,7 @@ <_parseDistroRid>$(__DistroRid) <_parseDistroRid Condition="'$(_parseDistroRid)' == '' and '$(MSBuildRuntimeType)' == 'core'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier) <_parseDistroRid Condition="'$(_parseDistroRid)' == '' and '$(MSBuildRuntimeType)' != 'core'">win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant) - <_distroRidIndex>$(_parseDistroRid.LastIndexOfAny("-")) + <_distroRidIndex>$(_parseDistroRid.LastIndexOf('-')) <_runtimeOS>$(RuntimeOS) <_runtimeOS Condition="'$(_runtimeOS)' == ''">$(_parseDistroRid.SubString(0, $(_distroRidIndex))) diff --git a/eng/SourceBuild.props b/eng/SourceBuild.props index c9ac54d245a8bd..8db0cb0ee5c6cf 100644 --- a/eng/SourceBuild.props +++ b/eng/SourceBuild.props @@ -16,7 +16,7 @@ $(__DistroRid) - <_targetRidPlatformIndex>$(TargetRid.LastIndexOfAny("-")) + <_targetRidPlatformIndex>$(TargetRid.LastIndexOf('-')) $(TargetRid.Substring(0, $(_targetRidPlatformIndex))) $(TargetRid.Substring($(_targetRidPlatformIndex)).TrimStart('-'))