Skip to content

Commit 2394ef0

Browse files
committed
Upgrade C#/WinRT
1 parent d81a8ab commit 2394ef0

36 files changed

+232
-80
lines changed

AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ await RunTestAsync(
937937
() => TestClient.InstallCommitAsync(Device, "936013062"));
938938
}
939939

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

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

966-
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
966+
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
967967
using (IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync())
968968
{
969969
string[] requests =
@@ -1012,7 +1012,7 @@ public async Task InstallMultipleWinRTAsyncTest()
10121012
}
10131013
}
10141014

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

10181018
string[] requests =
@@ -1086,9 +1086,9 @@ public async Task InstallMultipleWinRTWithBaseAsyncTest()
10861086
}
10871087
}
10881088

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

10941094
string[] requests =
@@ -1153,7 +1153,7 @@ public async Task InstallWriteWinRTAsyncTest()
11531153
}
11541154
}
11551155

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

AdvancedSharpAdbClient.Tests/AdbClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ public void GetFeatureSetTest()
11411141
public void CloneTest()
11421142
{
11431143
Assert.True(TestClient is ICloneable<IAdbClient>);
1144-
#if WINDOWS10_0_17763_0_OR_GREATER
1144+
#if WINDOWS10_0_18362_0_OR_GREATER
11451145
Assert.True(TestClient is ICloneable<IAdbClient.IWinRT>);
11461146
#endif
11471147
AdbClient client = TestClient.Clone();

AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
<Choose>
99
<When Condition="'$(IsWindows)' == 'True' and '$(IsStandard)' != 'True'">
1010
<PropertyGroup>
11-
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
11+
<TargetFramework>net8.0-windows10.0.18362.0</TargetFramework>
12+
<WindowsSdkPackageVersion>10.0.18362.42</WindowsSdkPackageVersion>
1213
</PropertyGroup>
1314
</When>
1415
<Otherwise>
@@ -22,7 +23,7 @@
2223
<PackageReference Include="coverlet.msbuild" Version="6.0.2" PrivateAssets="all">
2324
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2425
</PackageReference>
25-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
26+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
2627
<PackageReference Include="NSubstitute" Version="5.1.0" />
2728
<PackageReference Include="xunit" Version="2.9.0" />
2829
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all">

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/Properties/GlobalUsings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
global using AdvancedSharpAdbClient.Logs.Tests;
1414
#endregion
1515

16-
#if WINDOWS10_0_17763_0_OR_GREATER
16+
#if WINDOWS10_0_18362_0_OR_GREATER
1717
global using Windows.ApplicationModel;
1818
global using System.Runtime.InteropServices.WindowsRuntime;
1919
global using Windows.Storage;

AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ await RunTestAsync(
252252
Assert.True(service.IsProcessing);
253253
_ = await Assert.ThrowsAsync<InvalidOperationException>(() => service.PushAsync((Stream)null, null, default, default));
254254
_ = await Assert.ThrowsAsync<InvalidOperationException>(() => service.PullAsync(null, (Stream)null));
255-
#if WINDOWS10_0_17763_0_OR_GREATER
255+
#if WINDOWS10_0_18362_0_OR_GREATER
256256
_ = await Assert.ThrowsAsync<InvalidOperationException>(() => service.PushAsync((IInputStream)null, null, default, default));
257257
_ = await Assert.ThrowsAsync<InvalidOperationException>(() => service.PullAsync(null, (IOutputStream)null));
258258
#endif
@@ -264,7 +264,7 @@ await RunTestAsync(
264264
});
265265
}
266266

267-
#if WINDOWS10_0_17763_0_OR_GREATER
267+
#if WINDOWS10_0_18362_0_OR_GREATER
268268
/// <summary>
269269
/// Tests the <see cref="SyncService.PullAsync(string, IOutputStream, Action{SyncProgressChangedEventArgs}?, CancellationToken)"/> method.
270270
/// </summary>
@@ -313,7 +313,7 @@ public async Task PushWinRTAsyncTest()
313313
{
314314
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
315315

316-
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\Fstab.bin"));
316+
StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/Fstab.bin"));
317317
using IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync();
318318
byte[] content = await File.ReadAllBytesAsync("Assets/Fstab.bin");
319319
byte[] contentMessage =

AdvancedSharpAdbClient.Tests/SyncServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public void CloneTest()
233233
socket.Responses.Enqueue(AdbResponse.OK);
234234
using SyncService syncService = new(socket, Device);
235235
Assert.True(syncService is ICloneable<ISyncService>);
236-
#if WINDOWS10_0_17763_0_OR_GREATER
236+
#if WINDOWS10_0_18362_0_OR_GREATER
237237
Assert.True(syncService is ICloneable<ISyncService.IWinRT>);
238238
#endif
239239
using SyncService service = syncService.Clone();

AdvancedSharpAdbClient/AdbClient.Async.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,9 @@ public async Task InstallCommitAsync(DeviceData device, string session, Cancella
934934

935935
#if HAS_WINRT
936936
/// <inheritdoc/>
937-
[ContractVersion(typeof(UniversalApiContract), 65536u)]
937+
#if NET
938+
[SupportedOSPlatform("Windows10.0.10240.0")]
939+
#endif
938940
public virtual async Task InstallAsync(DeviceData device, IRandomAccessStream apk, Action<InstallProgressEventArgs>? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
939941
{
940942
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -1003,6 +1005,9 @@ public virtual async Task InstallAsync(DeviceData device, IRandomAccessStream ap
10031005
}
10041006

10051007
/// <inheritdoc/>
1008+
#if HAS_WINRT && NET
1009+
[SupportedOSPlatform("Windows10.0.10240.0")]
1010+
#endif
10061011
public async Task InstallMultipleAsync(DeviceData device, IRandomAccessStream baseAPK, IEnumerable<IRandomAccessStream> splitAPKs, Action<InstallProgressEventArgs>? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
10071012
{
10081013
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -1057,6 +1062,9 @@ void OnSplitSyncProgressChanged(string? sender, double args)
10571062
}
10581063

10591064
/// <inheritdoc/>
1065+
#if HAS_WINRT && NET
1066+
[SupportedOSPlatform("Windows10.0.10240.0")]
1067+
#endif
10601068
public async Task InstallMultipleAsync(DeviceData device, IEnumerable<IRandomAccessStream> splitAPKs, string packageName, Action<InstallProgressEventArgs>? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
10611069
{
10621070
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -1101,6 +1109,9 @@ void OnSyncProgressChanged(string? sender, double args)
11011109
}
11021110

11031111
/// <inheritdoc/>
1112+
#if NET
1113+
[SupportedOSPlatform("Windows10.0.10240.0")]
1114+
#endif
11041115
public virtual async Task InstallWriteAsync(DeviceData device, IRandomAccessStream apk, string apkName, string session, Action<double>? callback = null, CancellationToken cancellationToken = default)
11051116
{
11061117
callback?.Invoke(0);
@@ -1173,6 +1184,9 @@ public virtual async Task InstallWriteAsync(DeviceData device, IRandomAccessStre
11731184
/// The progress is reported as a value between 0 and 100, representing the percentage of the apk which has been transferred.</param>
11741185
/// <param name="cancellationToken">A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.</param>
11751186
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
1187+
#if NET
1188+
[SupportedOSPlatform("Windows10.0.10240.0")]
1189+
#endif
11761190
protected virtual async Task InstallWriteAsync(DeviceData device, IRandomAccessStream apk, string apkName, string session, Action<string?, double>? callback, CancellationToken cancellationToken = default)
11771191
{
11781192
callback?.Invoke(apkName, 0);

0 commit comments

Comments
 (0)