返回提交历史
Modified
XFEExtension.NetCore.XApp.Test/Program.cs
+42
-24
Modified
XFEExtension.NetCore.XApp.Test/XFEExtension.NetCore.XApp.Test.csproj
+0
-1
Modified
XFEExtension.NetCore.XApp/XAppLoader.cs
+17
-0
Modified
XFEExtension.NetCore.XApp/XFEExtension.NetCore.XApp.csproj
+3
-3
XFEstudio/XFEExtension.NetCore.XApp
优化程序解包结构
23184b4
代码差异
4 个文件
+62
-28
@@ -1,5 +1,4 @@
1
using XFEExtension.NetCore.StringExtension;
2
using XFEExtension.NetCore.XApp.Core;
1
using XFEExtension.NetCore.XApp.Core;
3
2
using XFEExtension.NetCore.XApp.Extensions;
4
3
5
4
internal class Program
@@ -7,10 +6,18 @@ internal class Program
7
6
[SMTest]
8
7
private static async Task MainTest()
9
8
{
10
var app = CreateXApp();
11
var page = await app.GetMainPage();
9
try
10
{
11
var app = CreateXApp();
12
var page = await app.GetMainPage();
13
}
14
catch (Exception ex)
15
{
16
Console.WriteLine(ex);
17
}
12
18
}
13
static XApp CreateXApp()
19
20
private static XApp CreateXApp()
14
21
{
15
22
var appInfo = new XAppInformation(string.Empty, "be98276c-48d6-451d-8a0a-a311d782d9d6", "第一个小程序", new Version(1, 0, 0), "这是第一个小程序", "XFE工作室室长", "4174240069", string.Empty, string.Empty, string.Empty, string.Empty);
16
23
var xApp = new XApp
@@ -18,9 +25,7 @@ internal class Program
18
25
AppInformation = appInfo
19
26
};
20
27
xApp.AppFiles.Add(XAppCode.FromCode(XAppFileType.XFCS, "XApp.xfcs", """
21
using XFEExtension.NetCore.XApp;
22
23
namespace XFEstudio;
28
namespace MyFirstXApp;
24
29
25
30
public class XAppProgram
26
31
{
@@ -32,7 +37,7 @@ internal class Program
32
37
}
33
38
}
34
39
"""));
35
xApp.AppFiles.Add(XAppCode.FromCode(XAppFileType.XFCS, "GlobalUsing.g.xfcs", """
40
xApp.AppFiles.Add(XAppCode.FromCode(XAppFileType.CS, "GlobalUsing.g.cs", """
36
41
global using global::Microsoft.Maui;
37
42
global using global::Microsoft.Maui.Controls;
38
43
global using global::Microsoft.Maui.Controls.Hosting;
@@ -43,32 +48,45 @@ internal class Program
43
48
global using global::System.Collections.Generic;
44
49
global using global::System.IO;
45
50
global using global::System.Linq;
51
global using global::XFEExtension.NetCore.XApp;
46
52
global using global::System.Threading;
47
53
global using global::System.Threading.Tasks;
48
54
"""));
49
xApp.AppFiles.Add(XAppCode.FromCode(XAppFileType.XFCS, "MainPage.cs", """"
50
namespace XFEstudio;
55
xApp.AppFiles.Add(XAppCode.FromCode(XAppFileType.XFCS, "MainPage.xfcs", """"
56
namespace MyFirstXApp;
51
57
52
58
public partial class MainPage : ContentPage
53
59
{
54
60
public MainPage()
55
61
{
56
this.LoadFromXaml("""
57
<?xml version="1.0" encoding="utf-8" ?>
58
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
59
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
60
x:Class="XFEstudio.MainPage"
61
Title="我的第一个小程序">
62
<StackLayout>
63
<Label Text="这是一个小程序" FontSize="18"/>
64
<Label Text="这是一个小程序" FontSize="12"/>
65
<Label Text="这是一个小程序" FontSize="6"/>
66
</StackLayout>
67
</ContentPage>
68
""");
62
InitXAppPage();
69
63
}
70
64
}
71
65
""""));
66
xApp.AppFiles.Add(XAppCode.FromCode(XAppFileType.CS, "MainPage.g.cs", """
67
namespace MyFirstXApp;
68
69
public partial class MainPage
70
{
71
internal void InitXAppPage()
72
{
73
this.LoadFromXaml(@"[XFMLTOLOAD]");
74
}
75
}
76
"""));
77
xApp.AppFiles.Add(XAppCode.FromCode(XAppFileType.XFML, "MainPage.xfml", """
78
<?xml version="1.0" encoding="utf-8" ?>
79
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
80
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
81
x:Class="MyFirstXApp.MainPage"
82
Title="第一个小程序">
83
<StackLayout>
84
<Label Text="这是一个小程序" FontSize="22" HorizontalOptions="Center" TextColor="#000"/>
85
<Label Text="这是一个小程序" FontSize="18" HorizontalOptions="Center"/>
86
<Label Text="这是一个小程序" FontSize="12" HorizontalOptions="Center"/>
87
</StackLayout>
88
</ContentPage>
89
"""));
72
90
return xApp;
73
91
}
74
92
}
@@ -9,7 +9,6 @@
9
9
10
10
<ItemGroup>
11
11
<PackageReference Include="Microsoft.Maui.Controls.Xaml" Version="8.0.20" />
12
<PackageReference Include="XFEExtension.NetCore.XApp.Core" Version="1.0.6" />
13
12
<PackageReference Include="XFEExtension.NetCore.XUnit" Version="2.0.3" />
14
13
</ItemGroup>
15
14
@@ -31,6 +31,23 @@ public static class XAppLoader
31
31
var syntaxTrees = new List<SyntaxTree>();
32
32
foreach (var xAppCode in xAppCodes)
33
33
{
34
if (xAppCode.FileType == XAppFileType.XFML)
35
continue;
36
var fileName = Path.GetFileNameWithoutExtension(xAppCode.FileName);
37
var split = fileName.Split('.');
38
if (split.Length > 1)
39
{
40
fileName = split[0];
41
}
42
if (xAppCode.FileType == XAppFileType.CS && xAppCode.FileName.Contains(".g.cs"))
43
{
44
var autoGenCodeFile = xAppCodes.Where(code => code.FileType == XAppFileType.XFML && code.FileName.Contains($"{fileName}")).ToArray();
45
if (autoGenCodeFile is not null && autoGenCodeFile.Length > 0)
46
{
47
var codeFile = autoGenCodeFile[0];
48
xAppCode.Code = xAppCode.Code?.Replace("[XFMLTOLOAD]", codeFile.Code);
49
}
50
}
34
51
syntaxTrees.Add(SyntaxFactory.ParseSyntaxTree(xAppCode.Code!));
35
52
}
36
53
var compilationOptions = new CSharpCompilationOptions(OutputKind.WindowsApplication);
@@ -15,9 +15,9 @@
15
15
<PackageIcon>logoIcon.png</PackageIcon>
16
16
<RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.XApp</RepositoryUrl>
17
17
<PackageTags>XApp;XFE</PackageTags>
18
<PackageReleaseNotes>fix-修复编译引用程序集的bug</PackageReleaseNotes>
18
<PackageReleaseNotes>优化程序解包结构</PackageReleaseNotes>
19
19
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
20
<Version>1.0.1</Version>
20
<Version>1.0.2</Version>
21
21
</PropertyGroup>
22
22
23
23
<ItemGroup>
@@ -38,7 +38,7 @@
38
38
<ItemGroup>
39
39
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
40
40
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.20" />
41
<PackageReference Include="XFEExtension.NetCore.XApp.Core" Version="1.0.0" />
41
<PackageReference Include="XFEExtension.NetCore.XApp.Core" Version="1.0.7" />
42
42
</ItemGroup>
43
43
44
44
</Project>