Skip to content

Commit 0340b8a

Browse files
committed
Use OperatingSystem to check platform
Update to .NET Core App 10.0 Migrate to slnx
1 parent 7766fea commit 0340b8a

21 files changed

Lines changed: 170 additions & 142 deletions

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
workflow_dispatch:
1515

1616
env:
17-
DOTNET_VERSION: '9.0.x' # The .NET SDK version to use
17+
DOTNET_VERSION: '10.0.x' # The .NET SDK version to use
1818

1919
jobs:
2020
build-and-test:

AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<Choose>
1010
<When Condition="'$(IsWindows)' == 'True' and '$(IsStandard)' != 'True'">
1111
<PropertyGroup>
12-
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
12+
<TargetFramework>net10.0-windows10.0.17763.0</TargetFramework>
1313
</PropertyGroup>
1414
</When>
1515
<Otherwise>
1616
<PropertyGroup>
17-
<TargetFramework>net8.0</TargetFramework>
17+
<TargetFramework>net10.0</TargetFramework>
1818
</PropertyGroup>
1919
</Otherwise>
2020
</Choose>

AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.Async.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using NSubstitute;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Text;
45
using System.Threading;
56
using System.Threading.Tasks;

AdvancedSharpAdbClient.Tests/Dummys/Logs/DummyLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void Log(LogLevel logLevel, Exception exception, string message, params o
1313
}
1414
}
1515

16-
internal class DummyLogger<T> : DummyLogger, ILogger<T>
16+
internal class DummyLogger<T> : DummyLogger, ILogger<T> where T : allows ref struct
1717
{
1818
public Type Type { get; } = typeof(T);
1919
public DummyLogger() : base(typeof(T).Name) { }

AdvancedSharpAdbClient.Tests/Dummys/Logs/DummyLoggerFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ internal class DummyLoggerFactory : ILoggerFactory
44
{
55
public ILogger CreateLogger(string categoryName) => new DummyLogger(categoryName);
66

7-
public ILogger<T> CreateLogger<T>() => new DummyLogger<T>();
7+
public ILogger<T> CreateLogger<T>() where T : allows ref struct => new DummyLogger<T>();
88
}
99
}

AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Linq;
45
using System.Threading;
56
using System.Threading.Tasks;
67
using Xunit;

AdvancedSharpAdbClient.sln

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

AdvancedSharpAdbClient.slnx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Solution>
2+
<Configurations>
3+
<Platform Name="Any CPU" />
4+
<Platform Name="ARM" />
5+
<Platform Name="ARM64" />
6+
<Platform Name="x64" />
7+
<Platform Name="x86" />
8+
</Configurations>
9+
<Project Path="AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj" />
10+
<Project Path="AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj" />
11+
</Solution>

AdvancedSharpAdbClient/AdbCommandLineClient.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,15 @@ public partial class AdbCommandLineClient : IAdbCommandLineClient
3636
/// <param name="adbPath">The path to the <c>adb.exe</c> executable.</param>
3737
/// <param name="isForce">Doesn't check adb file when <see langword="true"/>.</param>
3838
/// <param name="logger">The logger to use when logging.</param>
39-
#if HAS_WINRT && NET
39+
#if NET
40+
#if HAS_WINRT
4041
[SupportedOSPlatform("Windows10.0.10240.0")]
42+
#else
43+
[SupportedOSPlatform("Windows")]
44+
[SupportedOSPlatform("Linux")]
45+
[SupportedOSPlatform("OSX")]
46+
[SupportedOSPlatform("FreeBSD")]
47+
#endif
4148
#endif
4249
public AdbCommandLineClient(string adbPath, bool isForce = false, ILogger<AdbCommandLineClient>? logger = null)
4350
{
@@ -143,21 +150,24 @@ public virtual bool CheckAdbFileExists(string adbPath) => adbPath == "adb" ||
143150
/// Throws an error if the path does not point to a valid instance of <c>adb.exe</c>.
144151
/// </summary>
145152
/// <param name="adbPath">The path to validate.</param>
153+
#if NET
154+
[SupportedOSPlatformGuard("Windows")]
155+
[SupportedOSPlatformGuard("Linux")]
156+
[SupportedOSPlatformGuard("OSX")]
157+
[SupportedOSPlatformGuard("FreeBSD")]
158+
#endif
146159
protected virtual void EnsureIsValidAdbFile(string adbPath)
147160
{
148161
if (adbPath == "adb") { return; }
149162

150-
bool isWindows = Extensions.IsWindowsPlatform();
151-
bool isUnix = Extensions.IsUnixPlatform();
152-
153-
if (isWindows)
163+
if (OperatingSystem.IsWindows())
154164
{
155165
if (!string.Equals(Path.GetFileName(adbPath), "adb.exe", StringComparison.OrdinalIgnoreCase))
156166
{
157167
throw new ArgumentOutOfRangeException(nameof(adbPath), $"{adbPath} does not seem to be a valid adb.exe executable. The path must end with `adb.exe`");
158168
}
159169
}
160-
else if (isUnix)
170+
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || OperatingSystem.IsFreeBSD())
161171
{
162172
if (!string.Equals(Path.GetFileName(adbPath), "adb", StringComparison.OrdinalIgnoreCase))
163173
{

AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<CheckNotRecommendedTargetFramework>False</CheckNotRecommendedTargetFramework>
45
<FullTargets>True</FullTargets>
56
<ImportAsync>True</ImportAsync>
67
<Nullable>Enable</Nullable>
78
<PackageIcon>Icon.png</PackageIcon>
89
<PackageReadmeFile>README.md</PackageReadmeFile>
10+
<SuppressTfmSupportBuildWarnings>False</SuppressTfmSupportBuildWarnings>
911
</PropertyGroup>
1012

1113
<Choose>
@@ -19,8 +21,8 @@
1921
<When Condition="'$(FullTargets)' == 'True'">
2022
<PropertyGroup>
2123
<NoWarn>$(NoWarn);NU1603;NU1605;NU1902;NU1903</NoWarn>
22-
<TargetFrameworks>net6.0;net8.0;net9.0;netcoreapp2.1;netcoreapp3.1;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
23-
<TargetFrameworks Condition="'$(IsWindows)' == 'True'">$(TargetFrameworks);net2.0;net3.5-client;net4.0-client;net4.5;net4.6.1;net4.8;net8.0-windows10.0.17763.0;net9.0-windows10.0.17763.0</TargetFrameworks>
24+
<TargetFrameworks>net6.0;net8.0;net10.0;netcoreapp2.1;netcoreapp3.1;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
25+
<TargetFrameworks Condition="'$(IsWindows)' == 'True'">$(TargetFrameworks);net2.0;net3.5-client;net4.0-client;net4.5;net4.6.1;net4.8;net8.0-windows10.0.17763.0;net10.0-windows10.0.17763.0</TargetFrameworks>
2426
<TargetFrameworks Condition="'$(GITHUB_ACTIONS)' != 'True' and '$(IsWindows)' == 'True'">$(TargetFrameworks);netcore5.0;uap10.0;uap10.0.15138.0</TargetFrameworks>
2527
</PropertyGroup>
2628
</When>

0 commit comments

Comments
 (0)