Skip to content

Commit

Permalink
Add clone for Framebuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed Feb 16, 2024
1 parent 6b3509f commit ae4842e
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ jobs:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64

- name: Setup NuGet.exe
uses: NuGet/setup-nuget@v1
uses: NuGet/setup-nuget@v2

- name: Install Dependencies
run: msbuild $env:Solution_Name /t:Restore /p:FullTargets=true /p:GITHUB_ACTIONS=false
Expand Down
1 change: 0 additions & 1 deletion AdvancedSharpAdbClient.Tests/AdbSocketTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.IO;
using System.Text;
using System.Threading;
using Xunit;

namespace AdvancedSharpAdbClient.Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void TryAsVersionTest(int versionCode, string versionName, bool expected)
Assert.Equal(expected, result);
if (expected)
{
Assert.Equal(versionCode, version.Major * 1000 + version.Minor * 100 + version.Build * 10 + version.Revision);
Assert.Equal(versionCode, (version.Major * 1000) + (version.Minor * 100) + (version.Build * 10) + version.Revision);
}
else
{
Expand All @@ -49,7 +49,7 @@ public void TryAsPackageVersionTest(int versionCode, string versionName, bool ex
Assert.Equal(expected, result);
if (expected)
{
Assert.Equal(versionCode, version.Major * 1000 + version.Minor * 100 + version.Build * 10 + version.Revision);
Assert.Equal(versionCode, (version.Major * 1000) + (version.Minor * 100) + (version.Build * 10) + version.Revision);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace AdvancedSharpAdbClient.Models.Tests
Expand Down
4 changes: 2 additions & 2 deletions AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<FullTargets>False</FullTargets>
<FullTargets>True</FullTargets>
<ImportAsync>True</ImportAsync>
<Nullable>Enable</Nullable>
</PropertyGroup>
Expand Down Expand Up @@ -103,7 +103,7 @@

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

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public static Task InstallMultipleAsync(this IAdbClient client, DeviceData devic
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
public static Task InstallWriteAsync(this IAdbClient client, DeviceData device, Stream apk, string apkName, string session, IProgress<double>? progress = null, CancellationToken cancellationToken = default) =>
client.InstallWriteAsync(device, apk, apkName, session, progress.AsAction(), cancellationToken);

/// <summary>
/// Asynchronously pair with a device for secure TCP/IP communication.
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions AdvancedSharpAdbClient/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public static void Dispose(this WaitHandle waitHandle)
progress == null ? null : progress.Report;
#endif

#if NET
[SupportedOSPlatformGuard("Windows")]
#endif
public static bool IsWindowsPlatform() =>
#if NETCORE && !UAP10_0_15138_0
true;
Expand All @@ -161,6 +164,11 @@ or PlatformID.WinCE
or PlatformID.Xbox;
#endif

#if NET
[SupportedOSPlatformGuard("Linux")]
[SupportedOSPlatformGuard("OSX")]
[SupportedOSPlatformGuard("FreeBSD")]
#endif
public static bool IsUnixPlatform() =>
#if NETCORE && !UAP10_0_15138_0
false;
Expand Down
1 change: 0 additions & 1 deletion AdvancedSharpAdbClient/Models/DeviceData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
Expand Down
15 changes: 14 additions & 1 deletion AdvancedSharpAdbClient/Models/Framebuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace AdvancedSharpAdbClient.Models
/// <param name="endPoint">The <see cref="EndPoint"/> at which the adb server is listening.</param>
/// <param name="adbSocketFactory">The <see cref="Func{EndPoint, IAdbSocket}"/> to create <see cref="IAdbSocket"/>.</param>
[DebuggerDisplay($"{nameof(Framebuffer)} \\{{ {nameof(Header)} = {{{nameof(Header)}}}, {nameof(Data)} = {{{nameof(Data)}}}, {nameof(Device)} = {{{nameof(Device)}}}, {nameof(EndPoint)} = {{{nameof(EndPoint)}}} }}")]
public sealed class Framebuffer(DeviceData device, EndPoint endPoint, Func<EndPoint, IAdbSocket> adbSocketFactory) : IDisposable
public sealed class Framebuffer(DeviceData device, EndPoint endPoint, Func<EndPoint, IAdbSocket> adbSocketFactory) : IDisposable, ICloneable<Framebuffer>, ICloneable
{
/// <summary>
/// The <see cref="Array"/> of <see cref="byte"/>s which contains the framebuffer header.
Expand Down Expand Up @@ -303,6 +303,19 @@ public void Dispose()
GC.SuppressFinalize(this);
}

/// <summary>
/// Creates a new <see cref="Framebuffer"/> object that is a copy of the current instance with new <see cref="Device"/>.
/// </summary>
/// <param name="device">The new <see cref="Device"/> to use.</param>
/// <returns>A new <see cref="Framebuffer"/> object that is a copy of this instance with new <see cref="Device"/>.</returns>
public Framebuffer Clone(DeviceData device) => new(device, EndPoint, AdbSocketFactory);

/// <inheritdoc/>
public Framebuffer Clone() => new(Device, EndPoint, AdbSocketFactory);

/// <inheritdoc/>
object ICloneable.Clone() => Clone();

/// <summary>
/// Throws an exception if this <see cref="Framebuffer"/> has been disposed.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace AdvancedSharpAdbClient.Polyfills
Expand Down

0 comments on commit ae4842e

Please sign in to comment.