Skip to content

Commit 9ad7024

Browse files
committed
Leverage new polyfills from PolyShim
1 parent e8b6529 commit 9ad7024

File tree

10 files changed

+14
-35
lines changed

10 files changed

+14
-35
lines changed

DotnetRuntimeBootstrapper.AppHost.Cli/DotnetRuntimeBootstrapper.AppHost.Cli.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="CSharpier.MsBuild" Version="1.2.1" PrivateAssets="all" />
19-
<PackageReference Include="PolyShim" Version="1.15.0" PrivateAssets="all" />
19+
<PackageReference Include="PolyShim" Version="2.0.0" PrivateAssets="all" />
2020
<PackageReference Include="QuickJson" Version="1.1.0" PrivateAssets="all" />
2121
</ItemGroup>
2222

DotnetRuntimeBootstrapper.AppHost.Core/BootstrapperBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public int Run(string[] args)
154154
{
155155
var targetAssembly = TargetAssembly.Resolve(
156156
Path.Combine(
157-
Path.GetDirectoryName(Environment.GetProcessPath())
157+
Path.GetDirectoryName(Environment.ProcessPath)
158158
?? AppDomain.CurrentDomain.BaseDirectory,
159159
Configuration.TargetFileName
160160
)

DotnetRuntimeBootstrapper.AppHost.Core/Dotnet/DotnetHost.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Runtime.InteropServices;
55
using System.Text;
66
using DotnetRuntimeBootstrapper.AppHost.Core.Native;
7-
using DotnetRuntimeBootstrapper.AppHost.Core.Utils.Extensions;
87

98
namespace DotnetRuntimeBootstrapper.AppHost.Core.Dotnet;
109

@@ -155,7 +154,7 @@ private static string GetHostResolverFilePath()
155154

156155
var hostResolverFilePath = (
157156
from dirPath in Directory.GetDirectories(hostResolverRootDirPath)
158-
let version = Version.TryParse(Path.GetFileName(dirPath))
157+
let version = Version.TryParse(Path.GetFileName(dirPath), out var v) ? v : null
159158
let filePath = Path.Combine(dirPath, "hostfxr.dll")
160159
where version is not null
161160
where File.Exists(filePath)

DotnetRuntimeBootstrapper.AppHost.Core/Dotnet/DotnetRuntime.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public static DotnetRuntime[] GetAllInstalled()
4444
from runtimeDirPath in Directory.GetDirectories(sharedDirPath)
4545
let name = Path.GetFileName(runtimeDirPath)
4646
from runtimeVersionDirPath in Directory.GetDirectories(runtimeDirPath)
47-
let version = Version.TryParse(Path.GetFileName(runtimeVersionDirPath))
47+
let version = Version.TryParse(Path.GetFileName(runtimeVersionDirPath), out var v)
48+
? v
49+
: null
4850
where version is not null
4951
select new DotnetRuntime(name, version)
5052
).ToArray();
@@ -55,7 +57,10 @@ public static DotnetRuntime[] GetAllTargets(string runtimeConfigFilePath)
5557
static DotnetRuntime ParseRuntime(JsonNode json)
5658
{
5759
var name = json.TryGetChild("name")?.TryGetString();
58-
var version = json.TryGetChild("version")?.TryGetString()?.Pipe(Version.TryParse);
60+
61+
var version = json.TryGetChild("version")
62+
?.TryGetString()
63+
?.Pipe(s => Version.TryParse(s, out var v) ? v : null);
5964

6065
return !string.IsNullOrEmpty(name) && version is not null
6166
? new DotnetRuntime(name, version)

DotnetRuntimeBootstrapper.AppHost.Core/DotnetRuntimeBootstrapper.AppHost.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<ItemGroup>
77
<PackageReference Include="CSharpier.MsBuild" Version="1.2.1" PrivateAssets="all" />
8-
<PackageReference Include="PolyShim" Version="1.15.0" PrivateAssets="all" />
8+
<PackageReference Include="PolyShim" Version="2.0.0" PrivateAssets="all" />
99
<PackageReference Include="QuickJson" Version="1.1.0" PrivateAssets="all" />
1010
</ItemGroup>
1111

DotnetRuntimeBootstrapper.AppHost.Core/Utils/Extensions/EnvironmentExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
using System;
22
using System.Collections;
33
using System.Linq;
4-
using System.Reflection;
54

65
namespace DotnetRuntimeBootstrapper.AppHost.Core.Utils.Extensions;
76

87
internal static class EnvironmentExtensions
98
{
109
extension(Environment)
1110
{
12-
public static string GetProcessPath() => Assembly.GetExecutingAssembly().Location;
13-
1411
public static void RefreshEnvironmentVariables()
1512
{
1613
var machineEnvironmentVariables = Environment

DotnetRuntimeBootstrapper.AppHost.Core/Utils/Extensions/PathExtensions.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Globalization;
43
using System.IO;
5-
using System.Linq;
64
using System.Text;
75

86
namespace DotnetRuntimeBootstrapper.AppHost.Core.Utils.Extensions;
97

108
internal static class PathExtensions
119
{
12-
private static readonly Random Random = new();
13-
1410
extension(Path)
1511
{
16-
public static string Combine(params IEnumerable<string> paths) =>
17-
paths.Aggregate(Path.Combine);
18-
1912
public static string GenerateTempFilePath(string fileNameBase)
2013
{
2114
static string GenerateSalt()
2215
{
2316
var buffer = new StringBuilder(8);
2417

2518
for (var i = 0; i < 8; i++)
26-
buffer.Append(Random.Next(0, 10).ToString(CultureInfo.InvariantCulture));
19+
buffer.Append(Random.Shared.Next(0, 10).ToString(CultureInfo.InvariantCulture));
2720

2821
return buffer.ToString();
2922
}

DotnetRuntimeBootstrapper.AppHost.Core/Utils/Extensions/VersionExtensions.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

DotnetRuntimeBootstrapper.AppHost.Gui/DotnetRuntimeBootstrapper.AppHost.Gui.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="CSharpier.MsBuild" Version="1.2.1" PrivateAssets="all" />
20-
<PackageReference Include="PolyShim" Version="1.15.0" PrivateAssets="all" />
20+
<PackageReference Include="PolyShim" Version="2.0.0" PrivateAssets="all" />
2121
<PackageReference Include="QuickJson" Version="1.1.0" PrivateAssets="all" />
2222
</ItemGroup>
2323

DotnetRuntimeBootstrapper/DotnetRuntimeBootstrapper.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
PrivateAssets="all"
4343
GeneratePathProperty="true"
4444
/>
45-
<PackageReference Include="PolyShim" Version="1.15.0" PrivateAssets="all" />
45+
<PackageReference Include="PolyShim" Version="2.0.0" PrivateAssets="all" />
4646
<PackageReference
4747
Include="Ressy"
4848
Version="1.0.3"

0 commit comments

Comments
 (0)