Fix stack overflow and rename method

This commit is contained in:
Jackson Schuster 2024-02-26 09:29:22 -08:00
parent 8c32f67bad
commit 0eea7e0579
3 changed files with 4 additions and 4 deletions

View file

@ -16,7 +16,7 @@
<Output TaskParameter="ContentDifferences" ItemName="ContentDifferences" /> <Output TaskParameter="ContentDifferences" ItemName="ContentDifferences" />
</FindArchiveDiffs> </FindArchiveDiffs>
<Message Text="Difference in sdk archive: %(ContentDifferences.Kind): %(ContentDifferences.Identity)" Importance="High" Condition="'%(ContentDifferences.Kind)' != 'Unchanged'"/> <Message Text="Difference in sdk archive: %(ContentDifferences.Kind): %(ContentDifferences.Identity)" Importance="High" Condition="'%(ContentDifferences.Identity)' != '' AND '%(ContentDifferences.Kind)' != 'Unchanged'"/>
<Delete Files="$(ClosestOfficialSdkPath)" Condition="'$(ClosestOfficialSdkPath)' == ''"/> <Delete Files="$(ClosestOfficialSdkPath)" Condition="'$(ClosestOfficialSdkPath)' == ''"/>
</Target> </Target>

View file

@ -24,7 +24,7 @@ public class GetClosestOfficialSdk : Microsoft.Build.Utilities.Task
public async Task<bool> ExecuteAsync() public async Task<bool> ExecuteAsync()
{ {
var (versionString, rid, extension) = ExtractFromFilePath(BuiltSdkPath); var (versionString, rid, extension) = GetInfoFromArchivePath(BuiltSdkPath);
string downloadUrl = GetLatestOfficialSdkUrl(versionString, rid, extension); string downloadUrl = GetLatestOfficialSdkUrl(versionString, rid, extension);
@ -63,7 +63,7 @@ public class GetClosestOfficialSdk : Microsoft.Build.Utilities.Task
return $"https://aka.ms/dotnet/{channel}/daily/dotnet-sdk-{rid}{extension}"; return $"https://aka.ms/dotnet/{channel}/daily/dotnet-sdk-{rid}{extension}";
} }
static (string Version, string Rid, string extension) ExtractFromFilePath(string path) static (string Version, string Rid, string extension) GetInfoFromArchivePath(string path)
{ {
string extension; string extension;
if (path.EndsWith(".tar.gz")) if (path.EndsWith(".tar.gz"))

View file

@ -73,7 +73,7 @@ public static class PathWithVersions
public static string GetVersionAnonymousPath(string path) public static string GetVersionAnonymousPath(string path)
{ {
return GetVersionAnonymousPath(path).ToString(); return GetVersionAnonymousPath(path.AsSpan()).ToString();
} }
public static ReadOnlySpan<char> GetVersionAnonymousPath(ReadOnlySpan<char> path) public static ReadOnlySpan<char> GetVersionAnonymousPath(ReadOnlySpan<char> path)