Skip to content

Commit 62c318d

Browse files
CopilotJusterZhu
andcommitted
refactor: remove OSS projects and rework CI/DI setup
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com> Agent-Logs-Url: https://github.com/GeneralLibrary/GeneralUpdate.Maui/sessions/21607648-666e-43bc-a9bb-cb68459f20f1
1 parent 4bc7862 commit 62c318d

47 files changed

Lines changed: 85 additions & 1561 deletions

Some content is hidden

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

.github/workflows/dotnet-ci.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ jobs:
1111
- name: Setup .NET SDK
1212
uses: actions/setup-dotnet@v2
1313
with:
14-
dotnet-version: '8.0.x'
14+
dotnet-version: '10.0.x'
1515
- name: Install .NET MAUI
1616
run: dotnet workload install maui
1717
- name: Restore dependencies
1818
run: dotnet restore ./src/GeneralUpdate.Maui.sln
1919
- name: build
20-
run: dotnet build ./src/GeneralUpdate.Maui.sln -c Release
20+
run: dotnet build ./src/GeneralUpdate.Maui.sln -c Release
21+
- name: test
22+
run: dotnet test ./src/GeneralUpdate.Maui.Android.Tests/GeneralUpdate.Maui.Android.Tests.csproj -c Release -p:TargetFramework=net10.0

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ This project is a subproject of GeneralUpdate, designed to be compatible with .N
44

55
| Platform | Support | Framework version |
66
| -------- | ------- | ----------------- |
7-
| Android | Yes | .NET8 |
7+
| Android | Yes | .NET10 |
88
| Windows | - | - |
99
| iOS | - | - |
1010
| Mac | - | - |
1111

1212
## Projects
1313

14-
- `GeneralUpdate.Maui.OSS`: Existing OSS-based MAUI update package.
1514
- `GeneralUpdate.Maui.Android`: UI-less Android auto-update core for .NET MAUI, including:
1615
- Update discovery from external metadata
1716
- Resumable APK download via `HttpClient` and HTTP range requests

src/GeneralUpdate.Maui.Android.Tests/GeneralUpdate.Maui.Android.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
12+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
1213
<PackageReference Include="xunit" Version="2.9.2" />
1314
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
1415
<PackageReference Include="coverlet.collector" Version="6.0.2" />
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using GeneralUpdate.Maui.Android.Abstractions;
2+
using GeneralUpdate.Maui.Android.Services;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Xunit;
5+
6+
namespace GeneralUpdate.Maui.Android.Tests;
7+
8+
public sealed class GeneralUpdateBootstrapDiTests
9+
{
10+
[Fact]
11+
public void AddGeneralUpdateMauiAndroid_RegistersBootstrapAndCoreServices()
12+
{
13+
var services = new ServiceCollection();
14+
15+
services.AddGeneralUpdateMauiAndroid();
16+
17+
using var provider = services.BuildServiceProvider();
18+
var bootstrap = provider.GetRequiredService<IAndroidBootstrap>();
19+
20+
Assert.NotNull(bootstrap);
21+
Assert.IsType<AndroidBootstrap>(bootstrap);
22+
}
23+
}

src/GeneralUpdate.Maui.Android/GeneralUpdate.Maui.Android.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@
99
<Description>GeneralUpdate.Maui.Android is a UI-less Android auto-update core component for .NET MAUI.</Description>
1010
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
1111
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0" />
16+
</ItemGroup>
1217
</Project>

src/GeneralUpdate.Maui.Android/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ UI-less Android auto-update core for .NET MAUI, focused on reusable update orche
1717

1818
Reference the project/package in your MAUI app and configure Android `FileProvider` authority.
1919

20+
### Dependency Injection (DI)
21+
22+
```csharp
23+
using GeneralUpdate.Maui.Android.Services;
24+
using Microsoft.Extensions.DependencyInjection;
25+
26+
var services = new ServiceCollection();
27+
services.AddGeneralUpdateMauiAndroid();
28+
29+
using var provider = services.BuildServiceProvider();
30+
var bootstrap = provider.GetRequiredService<IAndroidBootstrap>();
31+
```
32+
2033
## Quick Start
2134

2235
```csharp

src/GeneralUpdate.Maui.Android/README.zh-CN.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717

1818
在 MAUI 应用中引用该项目/包,并配置 Android `FileProvider` authority。
1919

20+
### 依赖注入(DI)
21+
22+
```csharp
23+
using GeneralUpdate.Maui.Android.Services;
24+
using Microsoft.Extensions.DependencyInjection;
25+
26+
var services = new ServiceCollection();
27+
services.AddGeneralUpdateMauiAndroid();
28+
29+
using var provider = services.BuildServiceProvider();
30+
var bootstrap = provider.GetRequiredService<IAndroidBootstrap>();
31+
```
32+
2033
## 快速开始
2134

2235
```csharp

src/GeneralUpdate.Maui.Android/Services/GeneralUpdateBootstrap.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using GeneralUpdate.Maui.Android.Abstractions;
22
using GeneralUpdate.Maui.Android.Platform.Android;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Microsoft.Extensions.DependencyInjection.Extensions;
35

46
namespace GeneralUpdate.Maui.Android.Services;
57

@@ -8,6 +10,29 @@ namespace GeneralUpdate.Maui.Android.Services;
810
/// </summary>
911
public static class GeneralUpdateBootstrap
1012
{
13+
public static IServiceCollection AddGeneralUpdateMauiAndroid(
14+
this IServiceCollection services,
15+
HttpClient? httpClient = null)
16+
{
17+
ArgumentNullException.ThrowIfNull(services);
18+
19+
if (httpClient is not null)
20+
{
21+
services.TryAddSingleton<IUpdateDownloader>(new HttpRangeDownloader(httpClient));
22+
}
23+
else
24+
{
25+
services.AddHttpClient<IUpdateDownloader, HttpRangeDownloader>();
26+
}
27+
services.AddSingleton<IHashValidator, Sha256Validator>();
28+
services.AddSingleton<IApkInstaller, AndroidApkInstaller>();
29+
services.AddSingleton<IUpdateStorageProvider, UpdateFileStore>();
30+
services.AddSingleton<IUpdateLogger>(NullUpdateLogger.Instance);
31+
services.AddSingleton<IAndroidBootstrap, AndroidBootstrap>();
32+
33+
return services;
34+
}
35+
1136
public static IAndroidBootstrap CreateDefault(HttpClient? httpClient = null, IUpdateLogger? logger = null)
1237
{
1338
var client = httpClient ?? new HttpClient();

src/GeneralUpdate.Maui.OSS/GeneralUpdate.Maui.OSS.csproj

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/GeneralUpdate.Maui.OSS/GeneralUpdateOSS.cs

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)