Skip to content

Commit fb486f7

Browse files
committed
修复没有mainHeader保存的bug,增加单元测试
1 parent a5af1ba commit fb486f7

9 files changed

Lines changed: 1575 additions & 38 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ build.ps1
7272
build.sh
7373
publish-nuget.ps1
7474
global.json
75-
push-nuget.ps1
75+
push-nuget.ps1

AutoSettingUI.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoSettingUI.Generator", "src\AutoSettingUI.Generator\AutoSettingUI.Generator.csproj", "{B7DC0B72-9060-49DB-89E0-63FBDD9269DA}"
44
EndProject
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoSettingUI.Generator.Tests", "src\AutoSettingUI.Generator.Tests\AutoSettingUI.Generator.Tests.csproj", "{FC3394A1-8FEF-4E9A-82A6-F5DBE1EB4D00}"
6+
EndProject
57
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoSettingUI.Core", "src\AutoSettingUI.Core\AutoSettingUI.Core.csproj", "{8B64B632-C05C-4710-AA8C-819CF86319E8}"
68
EndProject
79
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoSettingUI.Avalonia", "src\Extensions\AutoSettingUI.Avalonia\AutoSettingUI.Avalonia.csproj", "{3E7B0764-8E81-48C1-9FCC-5A68F26EA5A7}"
@@ -44,6 +46,10 @@ Global
4446
{B7DC0B72-9060-49DB-89E0-63FBDD9269DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
4547
{B7DC0B72-9060-49DB-89E0-63FBDD9269DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
4648
{B7DC0B72-9060-49DB-89E0-63FBDD9269DA}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{FC3394A1-8FEF-4E9A-82A6-F5DBE1EB4D00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{FC3394A1-8FEF-4E9A-82A6-F5DBE1EB4D00}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{FC3394A1-8FEF-4E9A-82A6-F5DBE1EB4D00}.Release|Any CPU.ActiveCfg = Release|Any CPU
52+
{FC3394A1-8FEF-4E9A-82A6-F5DBE1EB4D00}.Release|Any CPU.Build.0 = Release|Any CPU
4753
{8B64B632-C05C-4710-AA8C-819CF86319E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4854
{8B64B632-C05C-4710-AA8C-819CF86319E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
4955
{8B64B632-C05C-4710-AA8C-819CF86319E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -98,6 +104,7 @@ Global
98104
EndGlobalSection
99105
GlobalSection(NestedProjects) = preSolution
100106
{B7DC0B72-9060-49DB-89E0-63FBDD9269DA} = {E9EAEB75-13C9-4AC0-9734-F2374DC8A194}
107+
{FC3394A1-8FEF-4E9A-82A6-F5DBE1EB4D00} = {E9EAEB75-13C9-4AC0-9734-F2374DC8A194}
101108
{8B64B632-C05C-4710-AA8C-819CF86319E8} = {E9EAEB75-13C9-4AC0-9734-F2374DC8A194}
102109
{3E7B0764-8E81-48C1-9FCC-5A68F26EA5A7} = {FEC5DFBE-67B3-44C8-81C9-90C4213BF940}
103110
{6B03215F-DF2B-43BA-84B7-F25DAA32F01C} = {FEC5DFBE-67B3-44C8-81C9-90C4213BF940}

README.md

Lines changed: 124 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,77 @@
1313

1414
## Installation
1515

16-
Install the package for your preferred UI framework:
16+
Install the package for your preferred UI framework. Each package automatically includes the necessary dependencies (`Core`, `Extension.Shared`).
17+
18+
### Avalonia
19+
20+
```bash
21+
dotnet add package AutoSettingUI.Avalonia
22+
```
1723

1824
```xml
19-
<!-- Avalonia -->
2025
<PackageReference Include="AutoSettingUI.Avalonia" Version="1.0.0" />
26+
```
27+
28+
### Ursa (Avalonia with Ursa theme)
2129

22-
<!-- Ursa (Avalonia with Ursa theme) -->
30+
```bash
31+
dotnet add package AutoSettingUI.Ursa
32+
```
33+
34+
```xml
2335
<PackageReference Include="AutoSettingUI.Ursa" Version="1.0.0" />
36+
```
37+
38+
### WPF
39+
40+
```bash
41+
dotnet add package AutoSettingUI.WPF
42+
```
2443

25-
<!-- WPF -->
44+
```xml
2645
<PackageReference Include="AutoSettingUI.WPF" Version="1.0.0" />
2746
```
2847

29-
> **Note:** `AutoSettingUI.Core` is automatically included as a dependency. `AutoSettingUI.Generator` is only needed for AOT and should be referenced by the app project.
48+
### AOT Support (Optional)
49+
50+
For Native AOT or trimming support, also install the source generator:
51+
52+
```bash
53+
dotnet add package AutoSettingUI.Generator
54+
```
55+
56+
```xml
57+
<PackageReference Include="AutoSettingUI.Generator" Version="1.0.0" />
58+
```
3059

31-
**Target frameworks:** `AutoSettingUI.Core`, `AutoSettingUI.Avalonia`, and `AutoSettingUI.Ursa` target `net8.0;net9.0;net10.0`. `AutoSettingUI.WPF` targets `net8.0-windows;net9.0-windows;net10.0-windows`.
60+
**Target frameworks:** `AutoSettingUI.Core`, `AutoSettingUI.Avalonia`, `AutoSettingUI.Ursa`, and `AutoSettingUI.Generator` target `net8.0;net9.0;net10.0`. `AutoSettingUI.WPF` targets `net8.0-windows;net9.0-windows;net10.0-windows`.
3261

3362
**Avalonia version range:** `AutoSettingUI.Avalonia` references `[11.0.0,12.0.0)`. `AutoSettingUI.Ursa` references `[11.1.1,12.0.0)` (Ursa 1.13.0 requires Avalonia >= 11.1.1).
3463

3564
## Quick Start
3665

3766
This section shows a minimal end-to-end setup using the current demos as reference. It covers Avalonia, Ursa, and WPF, plus AOT support.
3867

39-
### 1. Add Packages / References
68+
### 1. Add Packages
4069

41-
```xml
42-
<!-- Avalonia -->
43-
<PackageReference Include="AutoSettingUI.Avalonia" Version="1.0.0" />
70+
Install the package for your UI framework:
4471

45-
<!-- Ursa (Avalonia with Ursa theme) -->
46-
<PackageReference Include="AutoSettingUI.Ursa" Version="1.0.0" />
72+
```bash
73+
# Avalonia
74+
dotnet add package AutoSettingUI.Avalonia
4775

48-
<!-- WPF -->
49-
<PackageReference Include="AutoSettingUI.WPF" Version="1.0.0" />
76+
# Ursa
77+
dotnet add package AutoSettingUI.Ursa
78+
79+
# WPF
80+
dotnet add package AutoSettingUI.WPF
5081
```
5182

52-
If you want AOT support, also reference the generator in your **app** project:
83+
For AOT support, also add the generator:
5384

54-
```xml
55-
<ProjectReference Include="..\..\src\AutoSettingUI.Generator\AutoSettingUI.Generator.csproj"
56-
OutputItemType="Analyzer"
57-
ReferenceOutputAssembly="false" />
85+
```bash
86+
dotnet add package AutoSettingUI.Generator
5887
```
5988

6089
### 2. Define a Settings Model
@@ -251,14 +280,23 @@ public sealed class NumericUpDownAttribute : ControlBindingAttribute
251280

252281
## Packages
253282

254-
| Package | Description |
255-
| ---------------------------- | ----------------------------------------------- |
256-
| `AutoSettingUI.Core` | Attributes, interfaces, and models. |
257-
| `AutoSettingUI.Generator` | Roslyn Incremental Source Generator (Analyzer). |
258-
| `AutoSettingUI.Extension.Shared` | Shared validation and control helpers. |
259-
| `AutoSettingUI.Avalonia` | Avalonia UI panel extension. |
260-
| `AutoSettingUI.Ursa` | Ursa-themed Avalonia panel extension. |
261-
| `AutoSettingUI.WPF` | WPF panel extension. |
283+
### User-Facing Packages (Install These)
284+
285+
| Package | Description | When to Use |
286+
| ------------------------- | --------------------------------------------------- | ------------------------------------ |
287+
| `AutoSettingUI.Avalonia` | Avalonia UI panel extension. Includes Core + Shared | Avalonia applications |
288+
| `AutoSettingUI.Ursa` | Ursa-themed Avalonia panel extension. Includes all | Ursa (Avalonia theme) applications |
289+
| `AutoSettingUI.WPF` | WPF panel extension. Includes Core + Shared | WPF applications |
290+
| `AutoSettingUI.Generator` | Roslyn Source Generator for AOT support (Optional) | When using Native AOT or trimming |
291+
292+
### Internal Dependencies (Auto-Included)
293+
294+
| Package | Description |
295+
| ------------------------------ | -------------------------------------------- |
296+
| `AutoSettingUI.Core` | Attributes, interfaces, and models. |
297+
| `AutoSettingUI.Extension.Shared` | Shared validation and control helpers. |
298+
299+
> **Note:** You don't need to install `Core` or `Extension.Shared` manually — they are automatically included when you install any UI framework package.
262300
263301
## Documentation
264302

@@ -268,6 +306,65 @@ public sealed class NumericUpDownAttribute : ControlBindingAttribute
268306
- [AOT Source Generator](manual/aot-source-generator.md) — AOT support details
269307

270308

309+
## Building and Publishing
310+
311+
For maintainers and contributors:
312+
313+
### Build the Solution
314+
315+
```powershell
316+
# Debug build
317+
.\build-all.ps1
318+
319+
# Release build with NuGet packages
320+
.\build-all.ps1 -Configuration Release -Pack
321+
```
322+
323+
### Publish NuGet Packages
324+
325+
Use the interactive script to select and publish packages:
326+
327+
```powershell
328+
.\publish-nuget.ps1
329+
```
330+
331+
This will show an interactive menu:
332+
333+
```
334+
========================================
335+
AutoSettingUI NuGet Pack & Publish
336+
========================================
337+
338+
Select packages to pack/publish:
339+
340+
1. AutoSettingUI.Core - Core library with attributes and descriptors
341+
2. AutoSettingUI.Generator - Roslyn source generator for AOT support
342+
3. AutoSettingUI.Avalonia - Avalonia UI controls
343+
4. AutoSettingUI.Ursa - Ursa UI controls (Avalonia theme)
344+
5. AutoSettingUI.WPF - WPF UI controls
345+
346+
A. Pack ALL packages
347+
Q. Quit
348+
```
349+
350+
Enter numbers (e.g., `1 3 4`) to select specific packages, or `A` for all.
351+
352+
### Publish Demo Applications
353+
354+
```powershell
355+
# Avalonia demo (Normal mode)
356+
.\publish-demo.ps1 -Framework Avalonia -Mode Normal
357+
358+
# Avalonia demo (AOT mode)
359+
.\publish-demo.ps1 -Framework Avalonia -Mode AOT
360+
361+
# Ursa demo
362+
.\publish-demo.ps1 -Framework Ursa -Mode Normal
363+
364+
# WPF demo
365+
.\publish-demo.ps1 -Framework WPF -Mode Normal
366+
```
367+
271368
## License
272369

273370
MIT

build-all.ps1

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,81 @@
11
<#
22
.SYNOPSIS
3-
Builds the entire AutoSettingUI solution.
3+
Builds the entire AutoSettingUI solution and optionally packs NuGet packages.
4+
5+
.DESCRIPTION
6+
This script builds the solution in Debug or Release configuration.
7+
It can also pack NuGet packages for distribution.
8+
9+
.PARAMETER Configuration
10+
The build configuration. Options: 'Debug', 'Release'. Default is 'Debug'.
11+
12+
.PARAMETER Pack
13+
If specified, packs NuGet packages after building.
14+
15+
.PARAMETER OutputDirectory
16+
The output directory for NuGet packages. Default is 'artifacts'.
17+
18+
.EXAMPLE
19+
.\build-all.ps1 -Configuration Release -Pack
420
#>
521

6-
$ErrorActionPreference = "Continue"
22+
param (
23+
[ValidateSet("Debug", "Release")]
24+
[string]$Configuration = "Debug",
725

8-
Write-Host "--- Building AutoSettingUI Solution ---" -ForegroundColor Cyan
26+
[switch]$Pack,
927

10-
dotnet build AutoSettingUI.sln -c Debug
28+
[string]$OutputDirectory = "artifacts"
29+
)
1130

12-
if ($LASTEXITCODE -eq 0) {
13-
Write-Host "`nSolution Build Successful!" -ForegroundColor Green
14-
}
15-
else {
31+
$ErrorActionPreference = "Stop"
32+
33+
Write-Host "========================================" -ForegroundColor Cyan
34+
Write-Host " Building AutoSettingUI Solution" -ForegroundColor Cyan
35+
Write-Host " Configuration: $Configuration" -ForegroundColor Cyan
36+
Write-Host "========================================" -ForegroundColor Cyan
37+
38+
# Build solution
39+
dotnet build AutoSettingUI.sln -c $Configuration
40+
41+
if ($LASTEXITCODE -ne 0) {
1642
Write-Host "`nSolution Build Failed!" -ForegroundColor Red
1743
exit 1
1844
}
45+
46+
Write-Host "`nSolution Build Successful!" -ForegroundColor Green
47+
48+
# Pack NuGet packages if requested
49+
if ($Pack) {
50+
Write-Host "`n========================================" -ForegroundColor Cyan
51+
Write-Host " Packing NuGet Packages" -ForegroundColor Cyan
52+
Write-Host "========================================" -ForegroundColor Cyan
53+
54+
$Packages = @(
55+
"src\AutoSettingUI.Core\AutoSettingUI.Core.csproj",
56+
"src\AutoSettingUI.Generator\AutoSettingUI.Generator.csproj",
57+
"src\Extensions\AutoSettingUI.Extension.Shared\AutoSettingUI.Extension.Shared.csproj",
58+
"src\Extensions\AutoSettingUI.Avalonia\AutoSettingUI.Avalonia.csproj",
59+
"src\Extensions\AutoSettingUI.Ursa\AutoSettingUI.Ursa.csproj",
60+
"src\Extensions\AutoSettingUI.WPF\AutoSettingUI.WPF.csproj"
61+
)
62+
63+
if (-not (Test-Path $OutputDirectory)) {
64+
New-Item -ItemType Directory -Path $OutputDirectory | Out-Null
65+
}
66+
67+
foreach ($Package in $Packages) {
68+
Write-Host "`nPacking: $Package" -ForegroundColor Yellow
69+
dotnet pack $Package -c $Configuration -o $OutputDirectory --no-build
70+
71+
if ($LASTEXITCODE -ne 0) {
72+
Write-Host "Failed to pack: $Package" -ForegroundColor Red
73+
exit 1
74+
}
75+
}
76+
77+
Write-Host "`n========================================" -ForegroundColor Green
78+
Write-Host " All Packages Packed Successfully!" -ForegroundColor Green
79+
Write-Host " Location: $(Resolve-Path $OutputDirectory)" -ForegroundColor Green
80+
Write-Host "========================================" -ForegroundColor Green
81+
}

publish-demo.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ param (
3232
$ErrorActionPreference = "Stop"
3333

3434
$ProjectMap = @{
35-
"Avalonia" = "Demo\AutoSettingUI.Avalonia.Demo\AutoSettingUI.Avalonia.Demo.csproj"
35+
"Avalonia" = "Demo\AutoSettingUI.Avalonia.CrossPlatform.Demo\AutoSettingUI.Avalonia.CrossPlatform.Demo\AutoSettingUI.Avalonia.CrossPlatform.Demo.csproj"
3636
"Ursa" = "Demo\AutoSettingUI.Ursa.Demo\AutoSettingUI.Ursa.Demo.csproj"
3737
"WPF" = "Demo\AutoSettingUI.Wpf.Demo\AutoSettingUI.Wpf.Demo.csproj"
3838
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<IsPackable>false</IsPackable>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
11+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
13+
<PackageReference Include="xunit" Version="2.6.6" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" PrivateAssets="all" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\AutoSettingUI.Core\AutoSettingUI.Core.csproj" />
19+
<ProjectReference Include="..\AutoSettingUI.Generator\AutoSettingUI.Generator.csproj"
20+
OutputItemType="Analyzer"
21+
ReferenceOutputAssembly="true" />
22+
</ItemGroup>
23+
24+
</Project>

0 commit comments

Comments
 (0)