Skip to content

Commit 4fa778f

Browse files
authored
Merge pull request #115 from SharpAdb/feature/csupdate
Upgrade C# language version to 13.0
2 parents 77db1e9 + b56b985 commit 4fa778f

File tree

73 files changed

+513
-261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+513
-261
lines changed

.filenesting.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"help": "https://go.microsoft.com/fwlink/?linkid=866610",
3+
"dependentFileProviders": {
4+
"add": {
5+
"pathSegment": {
6+
"add": {
7+
".*": [
8+
".bin",
9+
".cs",
10+
".txt"
11+
]
12+
}
13+
}
14+
}
15+
}
16+
}

.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: '8.0.x' # The .NET SDK version to use
17+
DOTNET_VERSION: '9.0.x' # The .NET SDK version to use
1818

1919
jobs:
2020
build-and-test:

.gitignore

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Ignore Visual Studio temporary files, build results, and
22
## files generated by popular Visual Studio add-ons.
33
##
4-
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
4+
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
55

66
# User-specific files
77
*.rsuser
@@ -29,14 +29,11 @@ x86/
2929
bld/
3030
[Bb]in/
3131
[Oo]bj/
32-
[Oo]ut/
3332
[Ll]og/
3433
#[Ll]ogs/
3534

3635
# Visual Studio 2015/2017 cache/options directory
3736
.vs/
38-
# JetBrains Rider options directory
39-
.idea/
4037
# Uncomment if you have tasks that create the project's static files in wwwroot
4138
#wwwroot/
4239

@@ -85,6 +82,8 @@ StyleCopReport.xml
8582
*.pgc
8683
*.pgd
8784
*.rsp
85+
# but not Directory.Build.rsp, as it configures directory-level build defaults
86+
!Directory.Build.rsp
8887
*.sbr
8988
*.tlb
9089
*.tli
@@ -93,6 +92,7 @@ StyleCopReport.xml
9392
*.tmp_proj
9493
*_wpftmp.csproj
9594
*.log
95+
*.tlog
9696
*.vspscc
9797
*.vssscc
9898
.builds
@@ -296,6 +296,17 @@ node_modules/
296296
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
297297
*.vbw
298298

299+
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
300+
*.vbp
301+
302+
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
303+
*.dsw
304+
*.dsp
305+
306+
# Visual Studio 6 technical files
307+
*.ncb
308+
*.aps
309+
299310
# Visual Studio LightSwitch build output
300311
**/*.HTMLClient/GeneratedArtifacts
301312
**/*.DesktopClient/GeneratedArtifacts
@@ -352,6 +363,9 @@ ASALocalRun/
352363
# Local History for Visual Studio
353364
.localhistory/
354365

366+
# Visual Studio History (VSHistory) files
367+
.vshistory/
368+
355369
# BeatPulse healthcheck temp database
356370
healthchecksdb
357371

@@ -363,3 +377,24 @@ MigrationBackup/
363377

364378
# Fody - auto-generated XML schema
365379
FodyWeavers.xsd
380+
381+
# VS Code files for those working on multiple tools
382+
.vscode/*
383+
!.vscode/settings.json
384+
!.vscode/tasks.json
385+
!.vscode/launch.json
386+
!.vscode/extensions.json
387+
*.code-workspace
388+
389+
# Local History for Visual Studio Code
390+
.history/
391+
392+
# Windows Installer files from build outputs
393+
*.cab
394+
*.msi
395+
*.msix
396+
*.msm
397+
*.msp
398+
399+
# JetBrains Rider
400+
*.sln.iml

AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Drawing;
4-
using System.Drawing.Imaging;
53
using System.Globalization;
64
using System.IO;
75
using System.Linq;
@@ -367,7 +365,7 @@ await File.ReadAllBytesAsync("Assets/Framebuffer.bin")
367365
Assert.Equal(1u, header.Version);
368366
Assert.Equal(0u, header.ColorSpace);
369367

370-
#if WINDOWS
368+
#if HAS_IMAGING
371369
if (!OperatingSystem.IsWindows()) { return; }
372370

373371
using Bitmap image = framebuffer.ToImage();
@@ -937,7 +935,7 @@ await RunTestAsync(
937935
() => TestClient.InstallCommitAsync(Device, "936013062"));
938936
}
939937

940-
#if WINDOWS10_0_17763_0_OR_GREATER
938+
#if WINDOWS10_0_18362_0_OR_GREATER
941939
/// <summary>
942940
/// Tests the <see cref="AdbClient.InstallAsync(DeviceData, IRandomAccessStream, Action{InstallProgressEventArgs}?, CancellationToken, string[])"/> method.
943941
/// </summary>
@@ -963,7 +961,7 @@ public async Task InstallWinRTAsyncTest()
963961

964962
byte[] response = "Success\n"u8.ToArray();
965963

966-
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
964+
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
967965
using (IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync())
968966
{
969967
string[] requests =
@@ -1012,7 +1010,7 @@ public async Task InstallMultipleWinRTAsyncTest()
10121010
}
10131011
}
10141012

1015-
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\split_config.arm64_v8a.apk"));
1013+
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/split_config.arm64_v8a.apk"));
10161014
using IRandomAccessStreamWithContentType abiStream = await storageFile.OpenReadAsync();
10171015

10181016
string[] requests =
@@ -1086,9 +1084,9 @@ public async Task InstallMultipleWinRTWithBaseAsyncTest()
10861084
}
10871085
}
10881086

1089-
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
1087+
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
10901088
using IRandomAccessStreamWithContentType baseStream = await storageFile.OpenReadAsync();
1091-
storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\split_config.arm64_v8a.apk"));
1089+
storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/split_config.arm64_v8a.apk"));
10921090
using IRandomAccessStreamWithContentType abiStream = await storageFile.OpenReadAsync();
10931091

10941092
string[] requests =
@@ -1153,7 +1151,7 @@ public async Task InstallWriteWinRTAsyncTest()
11531151
}
11541152
}
11551153

1156-
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
1154+
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
11571155
using (IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync())
11581156
{
11591157
string[] requests =

AdvancedSharpAdbClient.Tests/AdbClientTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Drawing;
4-
using System.Drawing.Imaging;
53
using System.Globalization;
64
using System.IO;
75
using System.Linq;
@@ -489,7 +487,7 @@ public void GetFrameBufferTest()
489487
Assert.Equal(1u, header.Version);
490488
Assert.Equal(0u, header.ColorSpace);
491489

492-
#if WINDOWS
490+
#if HAS_IMAGING
493491
if (!OperatingSystem.IsWindows()) { return; }
494492

495493
using Bitmap image = framebuffer.ToImage();
@@ -1141,7 +1139,7 @@ public void GetFeatureSetTest()
11411139
public void CloneTest()
11421140
{
11431141
Assert.True(TestClient is ICloneable<IAdbClient>);
1144-
#if WINDOWS10_0_17763_0_OR_GREATER
1142+
#if WINDOWS10_0_18362_0_OR_GREATER
11451143
Assert.True(TestClient is ICloneable<IAdbClient.IWinRT>);
11461144
#endif
11471145
AdbClient client = TestClient.Clone();

AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj

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

33
<PropertyGroup>
4+
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
45
<LangVersion>latest</LangVersion>
56
<NoWarn>$(NoWarn);CS1591</NoWarn>
67
</PropertyGroup>
7-
8+
89
<Choose>
910
<When Condition="'$(IsWindows)' == 'True' and '$(IsStandard)' != 'True'">
1011
<PropertyGroup>
@@ -19,13 +20,13 @@
1920
</Choose>
2021

2122
<ItemGroup>
22-
<PackageReference Include="coverlet.msbuild" Version="6.0.2" PrivateAssets="all">
23+
<PackageReference Include="coverlet.msbuild" Version="6.0.3" PrivateAssets="all">
2324
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2425
</PackageReference>
25-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
26-
<PackageReference Include="NSubstitute" Version="5.1.0" />
27-
<PackageReference Include="xunit" Version="2.9.0" />
28-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all">
26+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
27+
<PackageReference Include="NSubstitute" Version="5.3.0" />
28+
<PackageReference Include="xunit" Version="2.9.2" />
29+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0" PrivateAssets="all">
2930
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3031
</PackageReference>
3132
</ItemGroup>
@@ -39,5 +40,9 @@
3940
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4041
</None>
4142
</ItemGroup>
43+
44+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net1.1'))">
45+
<DefineConstants>$(DefineConstants);HAS_IMAGING</DefineConstants>
46+
</PropertyGroup>
4247

4348
</Project>

AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public async Task DumpScreenAsyncTest()
105105
Assert.Equal(doc, xml);
106106
}
107107

108-
#if WINDOWS10_0_17763_0_OR_GREATER
108+
#if WINDOWS10_0_18362_0_OR_GREATER
109109
/// <summary>
110110
/// Tests the <see cref="DeviceClient.DumpScreenWinRTAsync(CancellationToken)"/> method.
111111
/// </summary>

AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void DumpScreenTest()
191191
Assert.Equal(doc, xml);
192192
}
193193

194-
#if WINDOWS10_0_17763_0_OR_GREATER
194+
#if WINDOWS10_0_18362_0_OR_GREATER
195195
/// <summary>
196196
/// Tests the <see cref="DeviceClient.DumpScreenWinRT()"/> method.
197197
/// </summary>

AdvancedSharpAdbClient.Tests/DeviceCommands/Models/VersionInfoTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void TryAsVersionTest(int versionCode, string versionName, bool expected)
3232
}
3333
}
3434

35-
#if WINDOWS10_0_17763_0_OR_GREATER
35+
#if WINDOWS10_0_18362_0_OR_GREATER
3636
/// <summary>
3737
/// Tests the <see cref="VersionInfo.TryAsPackageVersion(out PackageVersion)"/> method.
3838
/// </summary>

AdvancedSharpAdbClient.Tests/DeviceCommands/Receivers/GetPropReceiverTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void ListPropertiesTest()
1414
};
1515

1616
DummyAdbClient client = new();
17-
client.Commands["shell:/system/bin/getprop"] =
17+
client.Commands["shell:/system/bin/getprop"] =
1818
"""
1919
[init.svc.BGW]: [running]
2020
[init.svc.MtkCodecService]: [running]

AdvancedSharpAdbClient.Tests/Dummys/DummyAdbClient.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ public void ExecuteRemoteCommand(string command, DeviceData device) =>
2626
public void ExecuteRemoteCommand(string command, DeviceData device, IShellOutputReceiver receiver, Encoding encoding) =>
2727
ExecuteServerCommand("shell", command, receiver, encoding);
2828

29-
public IEnumerable<string> ExecuteRemoteCommand(string command, DeviceData device, Encoding encoding) =>
30-
ExecuteServerCommand("shell", command, encoding);
29+
public IEnumerable<string> ExecuteRemoteEnumerable(string command, DeviceData device, Encoding encoding) =>
30+
ExecuteServerEnumerable("shell", command, encoding);
3131

3232
public Task ExecuteRemoteCommandAsync(string command, DeviceData device, CancellationToken cancellationToken = default) =>
3333
ExecuteServerCommandAsync("shell", command, cancellationToken);
3434

3535
public Task ExecuteRemoteCommandAsync(string command, DeviceData device, IShellOutputReceiver receiver, Encoding encoding, CancellationToken cancellationToken = default) =>
3636
ExecuteServerCommandAsync("shell", command, receiver, encoding, cancellationToken);
3737

38-
public IAsyncEnumerable<string> ExecuteRemoteCommandAsync(string command, DeviceData device, Encoding encoding, CancellationToken cancellationToken) =>
39-
ExecuteServerCommandAsync("shell", command, encoding, cancellationToken);
38+
public IAsyncEnumerable<string> ExecuteRemoteEnumerableAsync(string command, DeviceData device, Encoding encoding, CancellationToken cancellationToken) =>
39+
ExecuteServerEnumerableAsync("shell", command, encoding, cancellationToken);
4040

4141
public void ExecuteServerCommand(string target, string command)
4242
{
@@ -89,7 +89,7 @@ public void ExecuteServerCommand(string target, string command, IShellOutputRece
8989
public void ExecuteServerCommand(string target, string command, IAdbSocket socket, IShellOutputReceiver receiver, Encoding encoding) =>
9090
ExecuteServerCommand(target, command, receiver, encoding);
9191

92-
public IEnumerable<string> ExecuteServerCommand(string target, string command, Encoding encoding)
92+
public IEnumerable<string> ExecuteServerEnumerable(string target, string command, Encoding encoding)
9393
{
9494
StringBuilder requestBuilder = new();
9595
if (!StringExtensions.IsNullOrWhiteSpace(target))
@@ -115,8 +115,8 @@ public IEnumerable<string> ExecuteServerCommand(string target, string command, E
115115
}
116116
}
117117

118-
public IEnumerable<string> ExecuteServerCommand(string target, string command, IAdbSocket socket, Encoding encoding) =>
119-
ExecuteServerCommand(target, command, encoding);
118+
public IEnumerable<string> ExecuteServerEnumerable(string target, string command, IAdbSocket socket, Encoding encoding) =>
119+
ExecuteServerEnumerable(target, command, encoding);
120120

121121
public async Task ExecuteServerCommandAsync(string target, string command, CancellationToken cancellationToken = default)
122122
{
@@ -171,7 +171,7 @@ public async Task ExecuteServerCommandAsync(string target, string command, IShel
171171
public Task ExecuteServerCommandAsync(string target, string command, IAdbSocket socket, IShellOutputReceiver receiver, Encoding encoding, CancellationToken cancellationToken) =>
172172
ExecuteServerCommandAsync(target, command, receiver, encoding, cancellationToken);
173173

174-
public async IAsyncEnumerable<string> ExecuteServerCommandAsync(string target, string command, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken)
174+
public async IAsyncEnumerable<string> ExecuteServerEnumerableAsync(string target, string command, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken)
175175
{
176176
StringBuilder requestBuilder = new();
177177
if (!StringExtensions.IsNullOrWhiteSpace(target))
@@ -197,8 +197,8 @@ public async IAsyncEnumerable<string> ExecuteServerCommandAsync(string target, s
197197
}
198198
}
199199

200-
public IAsyncEnumerable<string> ExecuteServerCommandAsync(string target, string command, IAdbSocket socket, Encoding encoding, CancellationToken cancellationToken = default) =>
201-
ExecuteServerCommandAsync(target, command, socket, encoding, cancellationToken);
200+
public IAsyncEnumerable<string> ExecuteServerEnumerableAsync(string target, string command, IAdbSocket socket, Encoding encoding, CancellationToken cancellationToken = default) =>
201+
ExecuteServerEnumerableAsync(target, command, socket, encoding, cancellationToken);
202202

203203
#region Not Implemented
204204

AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace AdvancedSharpAdbClient.Tests
1111
/// <summary>
1212
/// A mock implementation of the <see cref="IAdbSocket"/> class.
1313
/// </summary>
14-
internal class DummyAdbSocket : IDummyAdbSocket, ICloneable<DummyAdbSocket>
14+
internal partial class DummyAdbSocket : IDummyAdbSocket, ICloneable<DummyAdbSocket>
1515
{
1616
/// <summary>
1717
/// Use this message to cause <see cref="ReadString"/> and <see cref="ReadStringAsync(CancellationToken)"/> to throw
@@ -314,7 +314,5 @@ public async Task ReconnectAsync(bool isForce, CancellationToken cancellationTok
314314
SyncRequests = SyncRequests,
315315
ShellStreams = ShellStreams
316316
};
317-
318-
object ICloneable.Clone() => Clone();
319317
}
320318
}

AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace AdvancedSharpAdbClient.Tests
99
/// <summary>
1010
/// A mock implementation of the <see cref="ISyncService"/> class.
1111
/// </summary>
12-
internal class DummySyncService : ISyncService
12+
internal partial class DummySyncService : ISyncService
1313
{
1414
public Dictionary<string, Stream> UploadedFiles { get; } = [];
1515

0 commit comments

Comments
 (0)