Skip to content

Commit 7e1139e

Browse files
committed
Add .net8 support
1 parent 536bbc3 commit 7e1139e

18 files changed

+68
-26
lines changed

AdvancedSharpAdbClient.Tests/AdbClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public void ExecuteRemoteCommandUnresponsiveTest()
289289
}
290290
else
291291
{
292-
throw ex;
292+
throw;
293293
}
294294
}
295295
}));

AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj

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

33
<PropertyGroup>
4-
<NoWarn>CS1591</NoWarn>
54
<LangVersion>latest</LangVersion>
65
<NoWarn>CS1591</NoWarn>
76
<TargetFramework>net6.0</TargetFramework>
87
</PropertyGroup>
98

109
<ItemGroup>
11-
<PackageReference Include="coverlet.msbuild" Version="3.2.0" PrivateAssets="all">
10+
<PackageReference Include="coverlet.msbuild" Version="6.0.0" PrivateAssets="all">
1211
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1312
</PackageReference>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
1514
<PackageReference Include="Moq" Version="4.18.4" />
1615
<PackageReference Include="xunit" Version="2.4.2" />
1716
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="all">
1817
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1918
</PackageReference>
20-
<PackageReference Include="coverlet.msbuild" Version="3.2.0" PrivateAssets="all">
21-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22-
</PackageReference>
2319
</ItemGroup>
2420

2521
<ItemGroup>

AdvancedSharpAdbClient/AdbServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public AdbServerStatus GetStatus()
183183
else
184184
{
185185
// An unexpected exception occurred; re-throw the exception
186-
throw ex;
186+
throw;
187187
}
188188
}
189189
}

AdvancedSharpAdbClient/AdbSocket.Async.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ public virtual async Task SendAsync(byte[] data, int offset, int length, Cancell
2828
throw new AdbException("channel EOF");
2929
}
3030
}
31+
#if HAS_LOGGER
3132
catch (SocketException ex)
3233
{
33-
#if HAS_LOGGER
3434
logger.LogError(ex, ex.Message);
35+
#else
36+
catch (SocketException)
37+
{
3538
#endif
36-
throw ex;
39+
throw;
3740
}
3841
}
3942

@@ -165,7 +168,7 @@ public async Task SetDeviceAsync(DeviceData device, CancellationToken cancellati
165168
}
166169
else
167170
{
168-
throw e;
171+
throw;
169172
}
170173
}
171174
}

AdvancedSharpAdbClient/AdbSocket.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,15 @@ public virtual void Send(byte[] data, int offset, int length)
123123
throw new AdbException("channel EOF");
124124
}
125125
}
126+
#if HAS_LOGGER
126127
catch (SocketException sex)
127128
{
128-
#if HAS_LOGGER
129129
logger.LogError(sex, sex.Message);
130+
#else
131+
catch (SocketException)
132+
{
130133
#endif
131-
throw sex;
134+
throw;
132135
}
133136
}
134137

@@ -326,7 +329,7 @@ public void SetDevice(DeviceData device)
326329
}
327330
else
328331
{
329-
throw e;
332+
throw;
330333
}
331334
}
332335
}

AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
<PropertyGroup Condition="'$(FullTargets)' != 'true'">
99
<TargetFramework Condition="'$(GITHUB_ACTIONS)' == 'true'">netstandard2.0</TargetFramework>
10-
<TargetFrameworks Condition="'$(GITHUB_ACTIONS)' != 'true' And '$(IsWindows)'">net3.5-client;net4.0-client;net4.5.2;net4.6.2;net4.7.2;net4.8.1;net6.0;netcoreapp3.1;netstandard1.3;netstandard2.0</TargetFrameworks>
11-
<TargetFrameworks Condition="'$(GITHUB_ACTIONS)' != 'true' And !'$(IsWindows)'">net6.0;netcoreapp3.1;netstandard1.3;netstandard2.0</TargetFrameworks>
10+
<TargetFrameworks Condition="'$(GITHUB_ACTIONS)' != 'true' And '$(IsWindows)'">net3.5-client;net4.0-client;net4.5.2;net4.6.2;net4.7.2;net4.8.1;net6.0;net8.0;netcoreapp3.1;netstandard1.3;netstandard2.0</TargetFrameworks>
11+
<TargetFrameworks Condition="'$(GITHUB_ACTIONS)' != 'true' And !'$(IsWindows)'">net6.0;net8.0;netcoreapp3.1;netstandard1.3;netstandard2.0</TargetFrameworks>
1212
</PropertyGroup>
1313

1414
<ItemGroup>
@@ -52,13 +52,15 @@
5252
or '$(TargetFramework)' == 'net4.7.2'
5353
or '$(TargetFramework)' == 'net4.8.1'
5454
or '$(TargetFramework)' == 'net6.0'
55+
or '$(TargetFramework)' == 'net8.0'
5556
or '$(TargetFramework)' == 'netcoreapp3.1'
5657
or '$(TargetFramework)' == 'netstandard2.0'
5758
or '$(TargetFramework)' == 'uap10.0'">
5859
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
5960
</ItemGroup>
6061

6162
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'
63+
or '$(TargetFramework)' == 'net8.0'
6264
or '$(TargetFramework)' == 'netcoreapp3.1'
6365
or '$(TargetFramework)' == 'netstandard2.0'
6466
or '$(TargetFramework)' == 'uap10.0'">

AdvancedSharpAdbClient/DeviceCommands/PackageManager.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,15 @@ private string SyncPackageToDevice(string localFilePath, Action<object, SyncProg
419419

420420
return remoteFilePath;
421421
}
422+
#if HAS_LOGGER
422423
catch (IOException e)
423424
{
424-
#if HAS_LOGGER
425425
logger.LogError(e, $"Unable to open sync connection! reason: {e.Message}");
426+
#else
427+
catch (IOException)
428+
{
426429
#endif
427-
throw e;
430+
throw;
428431
}
429432
}
430433

@@ -440,12 +443,15 @@ private void RemoveRemotePackage(string remoteFilePath)
440443
{
441444
client.ExecuteShellCommand(Device, $"rm \"{remoteFilePath}\"", null);
442445
}
446+
#if HAS_LOGGER
443447
catch (IOException e)
444448
{
445-
#if HAS_LOGGER
446449
logger.LogError(e, $"Failed to delete temporary package: {e.Message}");
450+
#else
451+
catch (IOException)
452+
{
447453
#endif
448-
throw e;
454+
throw;
449455
}
450456
}
451457

AdvancedSharpAdbClient/DeviceMonitor.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ private async Task DeviceMonitorLoopAsync(CancellationToken cancellationToken =
216216

217217
firstDeviceListParsed.Set();
218218
}
219+
#if HAS_LOGGER
219220
catch (TaskCanceledException ex)
221+
#else
222+
catch (TaskCanceledException)
223+
#endif
220224
{
221225
// We get a TaskCanceledException on Windows
222226
if (cancellationToken.IsCancellationRequested)
@@ -231,10 +235,14 @@ private async Task DeviceMonitorLoopAsync(CancellationToken cancellationToken =
231235
#if HAS_LOGGER
232236
logger.LogError(ex, ex.Message);
233237
#endif
234-
throw ex;
238+
throw;
235239
}
236240
}
241+
#if HAS_LOGGER
237242
catch (ObjectDisposedException ex)
243+
#else
244+
catch (ObjectDisposedException)
245+
#endif
238246
{
239247
// ... but an ObjectDisposedException on .NET Core on Linux and macOS.
240248
if (cancellationToken.IsCancellationRequested)
@@ -249,7 +257,7 @@ private async Task DeviceMonitorLoopAsync(CancellationToken cancellationToken =
249257
#if HAS_LOGGER
250258
logger.LogError(ex, ex.Message);
251259
#endif
252-
throw ex;
260+
throw;
253261
}
254262
}
255263
catch (AdbException adbException)
@@ -263,7 +271,7 @@ private async Task DeviceMonitorLoopAsync(CancellationToken cancellationToken =
263271
}
264272
else
265273
{
266-
throw adbException;
274+
throw;
267275
}
268276
}
269277
#if HAS_LOGGER

AdvancedSharpAdbClient/Exceptions/AdbException.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public AdbException(string message, AdbResponse response) : base(message)
5555
/// </summary>
5656
/// <param name="serializationInfo">The serialization info.</param>
5757
/// <param name="context">The context.</param>
58+
#if NET8_0_OR_GREATER
59+
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
60+
#endif
5861
public AdbException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context)
5962
{
6063
}

AdvancedSharpAdbClient/Exceptions/CommandAbortingException.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public CommandAbortingException(string message) : base(message)
3636
/// </summary>
3737
/// <param name="serializationInfo">The serialization info.</param>
3838
/// <param name="context">The context.</param>
39+
#if NET8_0_OR_GREATER
40+
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
41+
#endif
3942
public CommandAbortingException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context)
4043
{
4144
}

0 commit comments

Comments
 (0)