Skip to content

Commit

Permalink
Merge pull request #115 from SharpAdb/feature/csupdate
Browse files Browse the repository at this point in the history
Upgrade C# language version to 13.0
  • Loading branch information
wherewhere authored Jan 5, 2025
2 parents 77db1e9 + b56b985 commit 4fa778f
Show file tree
Hide file tree
Showing 73 changed files with 513 additions and 261 deletions.
16 changes: 16 additions & 0 deletions .filenesting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"help": "https://go.microsoft.com/fwlink/?linkid=866610",
"dependentFileProviders": {
"add": {
"pathSegment": {
"add": {
".*": [
".bin",
".cs",
".txt"
]
}
}
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
workflow_dispatch:

env:
DOTNET_VERSION: '8.0.x' # The .NET SDK version to use
DOTNET_VERSION: '9.0.x' # The .NET SDK version to use

jobs:
build-and-test:
Expand Down
43 changes: 39 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

# User-specific files
*.rsuser
Expand Down Expand Up @@ -29,14 +29,11 @@ x86/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
#[Ll]ogs/

# Visual Studio 2015/2017 cache/options directory
.vs/
# JetBrains Rider options directory
.idea/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

Expand Down Expand Up @@ -85,6 +82,8 @@ StyleCopReport.xml
*.pgc
*.pgd
*.rsp
# but not Directory.Build.rsp, as it configures directory-level build defaults
!Directory.Build.rsp
*.sbr
*.tlb
*.tli
Expand All @@ -93,6 +92,7 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
Expand Down Expand Up @@ -296,6 +296,17 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw

# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp

# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp

# Visual Studio 6 technical files
*.ncb
*.aps

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
Expand Down Expand Up @@ -352,6 +363,9 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/

# Visual Studio History (VSHistory) files
.vshistory/

# BeatPulse healthcheck temp database
healthchecksdb

Expand All @@ -363,3 +377,24 @@ MigrationBackup/

# Fody - auto-generated XML schema
FodyWeavers.xsd

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp

# JetBrains Rider
*.sln.iml
16 changes: 7 additions & 9 deletions AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -367,7 +365,7 @@ await File.ReadAllBytesAsync("Assets/Framebuffer.bin")
Assert.Equal(1u, header.Version);
Assert.Equal(0u, header.ColorSpace);

#if WINDOWS
#if HAS_IMAGING
if (!OperatingSystem.IsWindows()) { return; }

using Bitmap image = framebuffer.ToImage();
Expand Down Expand Up @@ -937,7 +935,7 @@ await RunTestAsync(
() => TestClient.InstallCommitAsync(Device, "936013062"));
}

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

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

StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
using (IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync())
{
string[] requests =
Expand Down Expand Up @@ -1012,7 +1010,7 @@ public async Task InstallMultipleWinRTAsyncTest()
}
}

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

string[] requests =
Expand Down Expand Up @@ -1086,9 +1084,9 @@ public async Task InstallMultipleWinRTWithBaseAsyncTest()
}
}

StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
using IRandomAccessStreamWithContentType baseStream = await storageFile.OpenReadAsync();
storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\split_config.arm64_v8a.apk"));
storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/split_config.arm64_v8a.apk"));
using IRandomAccessStreamWithContentType abiStream = await storageFile.OpenReadAsync();

string[] requests =
Expand Down Expand Up @@ -1153,7 +1151,7 @@ public async Task InstallWriteWinRTAsyncTest()
}
}

StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
using (IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync())
{
string[] requests =
Expand Down
6 changes: 2 additions & 4 deletions AdvancedSharpAdbClient.Tests/AdbClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -489,7 +487,7 @@ public void GetFrameBufferTest()
Assert.Equal(1u, header.Version);
Assert.Equal(0u, header.ColorSpace);

#if WINDOWS
#if HAS_IMAGING
if (!OperatingSystem.IsWindows()) { return; }

using Bitmap image = framebuffer.ToImage();
Expand Down Expand Up @@ -1141,7 +1139,7 @@ public void GetFeatureSetTest()
public void CloneTest()
{
Assert.True(TestClient is ICloneable<IAdbClient>);
#if WINDOWS10_0_17763_0_OR_GREATER
#if WINDOWS10_0_18362_0_OR_GREATER
Assert.True(TestClient is ICloneable<IAdbClient.IWinRT>);
#endif
AdbClient client = TestClient.Clone();
Expand Down
17 changes: 11 additions & 6 deletions AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>

<Choose>
<When Condition="'$(IsWindows)' == 'True' and '$(IsStandard)' != 'True'">
<PropertyGroup>
Expand All @@ -19,13 +20,13 @@
</Choose>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.2" PrivateAssets="all">
<PackageReference Include="coverlet.msbuild" Version="6.0.3" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
Expand All @@ -39,5 +40,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net1.1'))">
<DefineConstants>$(DefineConstants);HAS_IMAGING</DefineConstants>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public async Task DumpScreenAsyncTest()
Assert.Equal(doc, xml);
}

#if WINDOWS10_0_17763_0_OR_GREATER
#if WINDOWS10_0_18362_0_OR_GREATER
/// <summary>
/// Tests the <see cref="DeviceClient.DumpScreenWinRTAsync(CancellationToken)"/> method.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void DumpScreenTest()
Assert.Equal(doc, xml);
}

#if WINDOWS10_0_17763_0_OR_GREATER
#if WINDOWS10_0_18362_0_OR_GREATER
/// <summary>
/// Tests the <see cref="DeviceClient.DumpScreenWinRT()"/> method.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void TryAsVersionTest(int versionCode, string versionName, bool expected)
}
}

#if WINDOWS10_0_17763_0_OR_GREATER
#if WINDOWS10_0_18362_0_OR_GREATER
/// <summary>
/// Tests the <see cref="VersionInfo.TryAsPackageVersion(out PackageVersion)"/> method.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void ListPropertiesTest()
};

DummyAdbClient client = new();
client.Commands["shell:/system/bin/getprop"] =
client.Commands["shell:/system/bin/getprop"] =
"""
[init.svc.BGW]: [running]
[init.svc.MtkCodecService]: [running]
Expand Down
20 changes: 10 additions & 10 deletions AdvancedSharpAdbClient.Tests/Dummys/DummyAdbClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ public void ExecuteRemoteCommand(string command, DeviceData device) =>
public void ExecuteRemoteCommand(string command, DeviceData device, IShellOutputReceiver receiver, Encoding encoding) =>
ExecuteServerCommand("shell", command, receiver, encoding);

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

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

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

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

public void ExecuteServerCommand(string target, string command)
{
Expand Down Expand Up @@ -89,7 +89,7 @@ public void ExecuteServerCommand(string target, string command, IShellOutputRece
public void ExecuteServerCommand(string target, string command, IAdbSocket socket, IShellOutputReceiver receiver, Encoding encoding) =>
ExecuteServerCommand(target, command, receiver, encoding);

public IEnumerable<string> ExecuteServerCommand(string target, string command, Encoding encoding)
public IEnumerable<string> ExecuteServerEnumerable(string target, string command, Encoding encoding)
{
StringBuilder requestBuilder = new();
if (!StringExtensions.IsNullOrWhiteSpace(target))
Expand All @@ -115,8 +115,8 @@ public IEnumerable<string> ExecuteServerCommand(string target, string command, E
}
}

public IEnumerable<string> ExecuteServerCommand(string target, string command, IAdbSocket socket, Encoding encoding) =>
ExecuteServerCommand(target, command, encoding);
public IEnumerable<string> ExecuteServerEnumerable(string target, string command, IAdbSocket socket, Encoding encoding) =>
ExecuteServerEnumerable(target, command, encoding);

public async Task ExecuteServerCommandAsync(string target, string command, CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -171,7 +171,7 @@ public async Task ExecuteServerCommandAsync(string target, string command, IShel
public Task ExecuteServerCommandAsync(string target, string command, IAdbSocket socket, IShellOutputReceiver receiver, Encoding encoding, CancellationToken cancellationToken) =>
ExecuteServerCommandAsync(target, command, receiver, encoding, cancellationToken);

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

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

#region Not Implemented

Expand Down
4 changes: 1 addition & 3 deletions AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace AdvancedSharpAdbClient.Tests
/// <summary>
/// A mock implementation of the <see cref="IAdbSocket"/> class.
/// </summary>
internal class DummyAdbSocket : IDummyAdbSocket, ICloneable<DummyAdbSocket>
internal partial class DummyAdbSocket : IDummyAdbSocket, ICloneable<DummyAdbSocket>
{
/// <summary>
/// Use this message to cause <see cref="ReadString"/> and <see cref="ReadStringAsync(CancellationToken)"/> to throw
Expand Down Expand Up @@ -314,7 +314,5 @@ public async Task ReconnectAsync(bool isForce, CancellationToken cancellationTok
SyncRequests = SyncRequests,
ShellStreams = ShellStreams
};

object ICloneable.Clone() => Clone();
}
}
2 changes: 1 addition & 1 deletion AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace AdvancedSharpAdbClient.Tests
/// <summary>
/// A mock implementation of the <see cref="ISyncService"/> class.
/// </summary>
internal class DummySyncService : ISyncService
internal partial class DummySyncService : ISyncService
{
public Dictionary<string, Stream> UploadedFiles { get; } = [];

Expand Down
Loading

0 comments on commit 4fa778f

Please sign in to comment.