Skip to content

Commit ae4842e

Browse files
committed
Add clone for Framebuffer
1 parent 6b3509f commit ae4842e

File tree

10 files changed

+29
-15
lines changed

10 files changed

+29
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ jobs:
6363
dotnet-version: ${{ env.DOTNET_VERSION }}
6464

6565
- name: Setup MSBuild.exe
66-
uses: microsoft/setup-msbuild@v1
66+
uses: microsoft/setup-msbuild@v2
6767
with:
6868
msbuild-architecture: x64
6969

7070
- name: Setup NuGet.exe
71-
uses: NuGet/setup-nuget@v1
71+
uses: NuGet/setup-nuget@v2
7272

7373
- name: Install Dependencies
7474
run: msbuild $env:Solution_Name /t:Restore /p:FullTargets=true /p:GITHUB_ACTIONS=false

AdvancedSharpAdbClient.Tests/AdbSocketTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.IO;
33
using System.Text;
4-
using System.Threading;
54
using Xunit;
65

76
namespace AdvancedSharpAdbClient.Tests

AdvancedSharpAdbClient.Tests/DeviceCommands/Models/VersionInfoTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void TryAsVersionTest(int versionCode, string versionName, bool expected)
2424
Assert.Equal(expected, result);
2525
if (expected)
2626
{
27-
Assert.Equal(versionCode, version.Major * 1000 + version.Minor * 100 + version.Build * 10 + version.Revision);
27+
Assert.Equal(versionCode, (version.Major * 1000) + (version.Minor * 100) + (version.Build * 10) + version.Revision);
2828
}
2929
else
3030
{
@@ -49,7 +49,7 @@ public void TryAsPackageVersionTest(int versionCode, string versionName, bool ex
4949
Assert.Equal(expected, result);
5050
if (expected)
5151
{
52-
Assert.Equal(versionCode, version.Major * 1000 + version.Minor * 100 + version.Build * 10 + version.Revision);
52+
Assert.Equal(versionCode, (version.Major * 1000) + (version.Minor * 100) + (version.Build * 10) + version.Revision);
5353
}
5454
else
5555
{

AdvancedSharpAdbClient.Tests/Models/AdbCommandLineStatusTests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62
using Xunit;
73

84
namespace AdvancedSharpAdbClient.Models.Tests

AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj

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

33
<PropertyGroup>
4-
<FullTargets>False</FullTargets>
4+
<FullTargets>True</FullTargets>
55
<ImportAsync>True</ImportAsync>
66
<Nullable>Enable</Nullable>
77
</PropertyGroup>
@@ -103,7 +103,7 @@
103103

104104
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-windows10.0.17763.0'
105105
or '$(TargetFramework)' == 'net8.0-windows10.0.17763.0'">
106-
<PackageReference Include="System.Drawing.Common" Version="8.0.1" />
106+
<PackageReference Include="System.Drawing.Common" Version="8.0.2" />
107107
</ItemGroup>
108108

109109
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">

AdvancedSharpAdbClient/Extensions/AdbClientExtensions.Async.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public static Task InstallMultipleAsync(this IAdbClient client, DeviceData devic
465465
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
466466
public static Task InstallWriteAsync(this IAdbClient client, DeviceData device, Stream apk, string apkName, string session, IProgress<double>? progress = null, CancellationToken cancellationToken = default) =>
467467
client.InstallWriteAsync(device, apk, apkName, session, progress.AsAction(), cancellationToken);
468-
468+
469469
/// <summary>
470470
/// Asynchronously pair with a device for secure TCP/IP communication.
471471
/// </summary>

AdvancedSharpAdbClient/Extensions/Extensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ public static void Dispose(this WaitHandle waitHandle)
147147
progress == null ? null : progress.Report;
148148
#endif
149149

150+
#if NET
151+
[SupportedOSPlatformGuard("Windows")]
152+
#endif
150153
public static bool IsWindowsPlatform() =>
151154
#if NETCORE && !UAP10_0_15138_0
152155
true;
@@ -161,6 +164,11 @@ or PlatformID.WinCE
161164
or PlatformID.Xbox;
162165
#endif
163166

167+
#if NET
168+
[SupportedOSPlatformGuard("Linux")]
169+
[SupportedOSPlatformGuard("OSX")]
170+
[SupportedOSPlatformGuard("FreeBSD")]
171+
#endif
164172
public static bool IsUnixPlatform() =>
165173
#if NETCORE && !UAP10_0_15138_0
166174
false;

AdvancedSharpAdbClient/Models/DeviceData.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Diagnostics;
77
using System.Diagnostics.CodeAnalysis;
88
using System.Net;
9-
using System.Net.Sockets;
109
using System.Runtime.CompilerServices;
1110
using System.Text;
1211
using System.Text.RegularExpressions;

AdvancedSharpAdbClient/Models/Framebuffer.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace AdvancedSharpAdbClient.Models
1919
/// <param name="endPoint">The <see cref="EndPoint"/> at which the adb server is listening.</param>
2020
/// <param name="adbSocketFactory">The <see cref="Func{EndPoint, IAdbSocket}"/> to create <see cref="IAdbSocket"/>.</param>
2121
[DebuggerDisplay($"{nameof(Framebuffer)} \\{{ {nameof(Header)} = {{{nameof(Header)}}}, {nameof(Data)} = {{{nameof(Data)}}}, {nameof(Device)} = {{{nameof(Device)}}}, {nameof(EndPoint)} = {{{nameof(EndPoint)}}} }}")]
22-
public sealed class Framebuffer(DeviceData device, EndPoint endPoint, Func<EndPoint, IAdbSocket> adbSocketFactory) : IDisposable
22+
public sealed class Framebuffer(DeviceData device, EndPoint endPoint, Func<EndPoint, IAdbSocket> adbSocketFactory) : IDisposable, ICloneable<Framebuffer>, ICloneable
2323
{
2424
/// <summary>
2525
/// The <see cref="Array"/> of <see cref="byte"/>s which contains the framebuffer header.
@@ -303,6 +303,19 @@ public void Dispose()
303303
GC.SuppressFinalize(this);
304304
}
305305

306+
/// <summary>
307+
/// Creates a new <see cref="Framebuffer"/> object that is a copy of the current instance with new <see cref="Device"/>.
308+
/// </summary>
309+
/// <param name="device">The new <see cref="Device"/> to use.</param>
310+
/// <returns>A new <see cref="Framebuffer"/> object that is a copy of this instance with new <see cref="Device"/>.</returns>
311+
public Framebuffer Clone(DeviceData device) => new(device, EndPoint, AdbSocketFactory);
312+
313+
/// <inheritdoc/>
314+
public Framebuffer Clone() => new(Device, EndPoint, AdbSocketFactory);
315+
316+
/// <inheritdoc/>
317+
object ICloneable.Clone() => Clone();
318+
306319
/// <summary>
307320
/// Throws an exception if this <see cref="Framebuffer"/> has been disposed.
308321
/// </summary>

AdvancedSharpAdbClient/Polyfills/Extensions/StringExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Collections.Generic;
77
using System.ComponentModel;
8-
using System.Linq;
98
using System.Text;
109

1110
namespace AdvancedSharpAdbClient.Polyfills

0 commit comments

Comments
 (0)