返回提交历史
Modified
.github/workflows/publish-packages.yml
+6
-2
Modified
README.md
+3
-1
Modified
README.zh-CN.md
+3
-1
Modified
XFEExtension.NetCore.AutoConfig.Analyzer/Generator/ProfilePropertyAutoGenerator.cs
+2
-0
Modified
XFEExtension.NetCore.AutoConfig.Analyzer/XFEExtension.NetCore.AutoConfig.Analyzer.csproj
+2
-2
Modified
XFEExtension.NetCore.AutoConfig.CodeFix/XFEExtension.NetCore.AutoConfig.CodeFix.csproj
+2
-2
Modified
XFEExtension.NetCore.AutoConfig.Tests/GeneratorAndCodeFixTests.cs
+2
-1
Modified
XFEExtension.NetCore.AutoConfig.Tests/PersistenceTests.cs
+11
-0
Modified
XFEExtension.NetCore.AutoConfig/ProfileStore.cs
+7
-7
Modified
XFEExtension.NetCore.AutoConfig/XFEExtension.NetCore.AutoConfig.csproj
+3
-3
XFEstudio/XFEExtension.NetCore.AutoConfig
优化发布流程,修正 XML 元素名为属性名
- publish-packages.yml 仅在 tag push 时发布,提升安全性,发布到 GitHub Packages 改用 GH_PACKAGES_TOKEN - 创建 GitHub Release 放宽为所有 push 事件 - README 明确 XML 元素名为属性名(如 <Value>),非带 Instance 前缀 - ProfilePropertyAutoGenerator 生成属性加 [XmlElement],确保序列化用属性名 - GeneratorAndCodeFixTests 增加 [XmlElement("Value")] 断言并更新哈希 - PersistenceTests 新增测试,验证节点名为 <Value> - ProfileStore<TProfile> Update/Read 方法缩进优化 - 升级 Microsoft.CodeAnalysis 至 5.6.0,XFEExtension.NetCore 至 5.2.0 - XFEExtension.NetCore.AutoConfig 升级至 4.0.1
87d7caf
代码差异
10 个文件
+41
-19
@@ -2,6 +2,8 @@ name: Publish Packages
2
2
3
3
on:
4
4
push:
5
branches-ignore:
6
- "**"
5
7
tags:
6
8
- "v*"
7
9
workflow_dispatch:
@@ -86,6 +88,8 @@ jobs:
86
88
87
89
- name: Publish to GitHub Packages
88
90
shell: pwsh
91
env:
92
GH_PACKAGES_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }}
89
93
run: |
90
94
$packages = Get-ChildItem -Path "${{ env.PACKAGE_OUTPUT_DIR }}" -Filter *.nupkg -File
91
95
if (-not $packages) {
@@ -93,7 +97,7 @@ jobs:
93
97
}
94
98
95
99
foreach ($package in $packages) {
96
dotnet nuget push $package.FullName --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key "${{ secrets.GITHUB_TOKEN }}" --skip-duplicate
100
dotnet nuget push $package.FullName --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key "$env:GH_PACKAGES_TOKEN" --skip-duplicate
97
101
}
98
102
99
103
- name: Publish to NuGet.org
@@ -110,7 +114,7 @@ jobs:
110
114
}
111
115
112
116
- name: Create GitHub Release
113
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
117
if: ${{ github.event_name == 'push' }}
114
118
uses: softprops/action-gh-release@v2
115
119
with:
116
120
tag_name: ${{ github.ref_name }}
@@ -96,7 +96,9 @@ partial class SystemProfile : XFEProfile
96
96
97
97
### Schema Versions, Migrations, and Validation
98
98
99
Override `ProfileSchemaVersion` and register every `N -> N + 1` step in `ConfigureMigrations`. Files without metadata are version `0`. Built-in XFE dictionary, JSON, and XML modes persist version metadata automatically; `RenameProperty` handles generated `InstanceXxx` JSON/XML members as well as XFE dictionary keys.
99
Override `ProfileSchemaVersion` and register every `N -> N + 1` step in `ConfigureMigrations`. Files without metadata are version `0`. Built-in XFE dictionary, JSON, and XML modes persist version metadata automatically; `RenameProperty` handles XFE dictionary keys, generated `InstanceXxx` JSON members, and XML element names.
100
101
XML element names use the profile property name (for example, `<Value>`) even though the generated C# instance property remains `InstanceValue`.
100
102
101
103
```csharp
102
104
[AutoLoadProfile]
@@ -96,7 +96,9 @@ partial class SystemProfile : XFEProfile
96
96
97
97
### 配置版本、迁移与验证
98
98
99
重写 `ProfileSchemaVersion`,并在 `ConfigureMigrations` 中注册每个 `N -> N + 1` 步骤。没有版本元数据的旧文件视为版本 `0`。XFE 字典、JSON、XML 三种内置格式会自动保存版本;`RenameProperty` 同时处理 XFE 字典键和 JSON/XML 中生成的 `InstanceXxx` 成员。
99
重写 `ProfileSchemaVersion`,并在 `ConfigureMigrations` 中注册每个 `N -> N + 1` 步骤。没有版本元数据的旧文件视为版本 `0`。XFE 字典、JSON、XML 三种内置格式会自动保存版本;`RenameProperty` 同时处理 XFE 字典键、JSON 中生成的 `InstanceXxx` 成员以及 XML 节点名称。
100
101
XML 节点会使用配置属性名称(例如 `<Value>`),生成的 C# 实例属性仍保持为 `InstanceValue`。
100
102
101
103
```csharp
102
104
[AutoLoadProfile]
@@ -388,6 +388,7 @@ public sealed class ProfilePropertyAutoGenerator : IIncrementalGenerator
388
388
var getMethodName = "Get" + propertyName + "Property";
389
389
var setMethodName = "Set" + propertyName + "Property";
390
390
var typeDisplay = field.Field.Type.ToDisplayString(DeclarationTypeDisplayFormat);
391
var xmlElementNameLiteral = SyntaxFactory.Literal(field.PropertyName).ToFullString();
391
392
392
393
builder.Append(" static partial void ").Append(getMethodName).AppendLine("();");
393
394
builder.Append(" static partial void ").Append(setMethodName).Append("(ref ").Append(typeDisplay).AppendLine(" value);");
@@ -425,6 +426,7 @@ public sealed class ProfilePropertyAutoGenerator : IIncrementalGenerator
425
426
builder.AppendLine(" }");
426
427
builder.AppendLine();
427
428
builder.AppendLine(" [global::XFEExtension.NetCore.AutoConfig.ProfileFieldAutoGenerateAttribute]");
429
builder.Append(" [global::System.Xml.Serialization.XmlElementAttribute(").Append(xmlElementNameLiteral).AppendLine(")]");
428
430
builder.Append(" public ").Append(typeDisplay).Append(' ').Append(instancePropertyName).AppendLine();
429
431
builder.AppendLine(" {");
430
432
builder.Append(" get { lock (ProfileSyncRoot) return this.").Append(fieldName).AppendLine("; }");
@@ -14,8 +14,8 @@
14
14
</PropertyGroup>
15
15
16
16
<ItemGroup>
17
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
18
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" PrivateAssets="all" />
17
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.6.0" PrivateAssets="all" />
18
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.6.0" PrivateAssets="all" />
19
19
</ItemGroup>
20
20
21
21
</Project>
@@ -10,8 +10,8 @@
10
10
</PropertyGroup>
11
11
12
12
<ItemGroup>
13
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
14
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0" PrivateAssets="all" />
13
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.6.0" PrivateAssets="all" />
14
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.6.0" PrivateAssets="all" />
15
15
</ItemGroup>
16
16
17
17
<ItemGroup>
@@ -65,7 +65,8 @@ public sealed class GeneratorAndCodeFixTests
65
65
var generatedSource = result.Results.Single().GeneratedSources.Single().SourceText.ToString().Replace("\r\n", "\n");
66
66
var hash = Convert.ToHexString(System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(generatedSource)));
67
67
68
Assert.Equal("CB48140E88B75EA0AC24DFEE1F7332D29AAF7FDD277BC5F46F098FE80BCBE1C4", hash);
68
Assert.Contains("[global::System.Xml.Serialization.XmlElementAttribute(\"Value\")]", generatedSource);
69
Assert.Equal("BFCE10C01C4BBD8D156D2AFB85A55DC4B545B292AFF2841197BE70599FD3FBA5", hash);
69
70
}
70
71
71
72
[Theory]
@@ -38,6 +38,17 @@ public sealed class PersistenceTests
38
38
}
39
39
}
40
40
41
[Fact]
42
public void XmlUsesProfilePropertyNamesWithoutInstancePrefix()
43
{
44
XmlRoundTripProfile.Current.InstanceValue = "canonical";
45
46
var xml = XmlRoundTripProfile.ExportProfile();
47
48
Assert.Contains("<Value>canonical</Value>", xml);
49
Assert.DoesNotContain("<InstanceValue>", xml);
50
}
51
41
52
[Fact]
42
53
public void ProfilePathAttributeAndDefaultPathUseExpectedPaths()
43
54
{
@@ -101,11 +101,11 @@ public sealed class ProfileStore<TProfile> where TProfile : XFEProfile, new()
101
101
{
102
102
ArgumentNullException.ThrowIfNull(update);
103
103
lock (syncRoot)
104
lock (current.ProfileSyncRoot)
105
{
106
update(current);
107
current.InstanceRequestSaveProfile();
108
}
104
lock (current.ProfileSyncRoot)
105
{
106
update(current);
107
current.InstanceRequestSaveProfile();
108
}
109
109
}
110
110
111
111
/// <summary>在实例锁内读取配置。</summary>
@@ -113,8 +113,8 @@ public sealed class ProfileStore<TProfile> where TProfile : XFEProfile, new()
113
113
{
114
114
ArgumentNullException.ThrowIfNull(read);
115
115
lock (syncRoot)
116
lock (current.ProfileSyncRoot)
117
return read(current);
116
lock (current.ProfileSyncRoot)
117
return read(current);
118
118
}
119
119
120
120
private TProfile CreateProfile()
@@ -28,9 +28,9 @@
28
28
## 调整
29
29
30
30
- 明确 Native AOT/Trim 支持边界并标注反射序列化入口
31
</PackageReleaseNotes>
31
</PackageReleaseNotes>
32
32
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
33
<Version>4.0.0</Version>
33
<Version>4.0.1</Version>
34
34
<GenerateDocumentationFile>True</GenerateDocumentationFile>
35
35
</PropertyGroup>
36
36
@@ -56,7 +56,7 @@
56
56
</ItemGroup>
57
57
58
58
<ItemGroup>
59
<PackageReference Include="XFEExtension.NetCore" Version="4.2.3" />
59
<PackageReference Include="XFEExtension.NetCore" Version="5.2.0" />
60
60
</ItemGroup>
61
61
62
62
<ItemGroup>