Skip to content

Commit 95a37ab

Browse files
committed
⚡ Add AOT support #135
1 parent 5c3baa3 commit 95a37ab

File tree

9 files changed

+35
-34
lines changed

9 files changed

+35
-34
lines changed

src/Xecrets.Cli.sln

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1414
..\.editorconfig = ..\.editorconfig
1515
..\.gitignore = ..\.gitignore
1616
..\global.json = ..\global.json
17-
..\linux-arm64-zip.ps1 = ..\linux-arm64-zip.ps1
18-
..\linux-x64-zip.ps1 = ..\linux-x64-zip.ps1
19-
..\macos-arm64-zip.ps1 = ..\macos-arm64-zip.ps1
20-
..\macos-x64-zip.ps1 = ..\macos-x64-zip.ps1
2117
..\README.md = ..\README.md
2218
..\SECURITY.md = ..\SECURITY.md
23-
..\win-x64-zip.ps1 = ..\win-x64-zip.ps1
2419
..\xecrets-cli-wer.reg = ..\xecrets-cli-wer.reg
20+
..\nix-zip.ps1 = ..\nix-zip.ps1
21+
..\win-zip.ps1 = ..\win-zip.ps1
22+
..\xecrets-cli.code-workspace = ..\xecrets-cli.code-workspace
2523
EndProjectSection
2624
EndProject
2725
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xecrets.Net.Common", "..\..\xecrets-net\AxCrypt.Common\Xecrets.Net.Common.csproj", "{4C18EBBA-EF5F-4CAE-9101-368129372E17}"

src/Xecrets.Cli/Operation/OptionsCodeExportOperation.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Xecrets Cli - Copyright © 2022-2025 Svante Seleborg, All Rights Reserved.
55
*
66
* This code file is part of Xecrets Cli, parts of which in turn are derived from AxCrypt as licensed under GPL v3 or later.
7-
*
7+
*
88
* However, this code is not derived from AxCrypt and is separately copyrighted and only licensed as follows unless
99
* explicitly licensed otherwise. If you use any part of this code in your software, please see https://www.gnu.org/licenses/
1010
* for details of what this means for you.
@@ -19,7 +19,7 @@
1919
*
2020
* The source repository can be found at https://github.com/ please go there for more information, suggestions and
2121
* contributions. You may also visit https://www.axantum.com for more information about the author.
22-
*/
22+
*/
2323

2424
#endregion Copyright and GPL License
2525

@@ -44,43 +44,48 @@ public Task<Status> RealAsync(Parameters parameters)
4444

4545
sb.AppendLine($"public enum {nameof(XfOpCode)}");
4646
sb.AppendLine("{");
47-
foreach (XfOpCode opCode in Enum.GetValues(typeof(XfOpCode)))
47+
foreach (XfOpCode opCode in Enum.GetValues<XfOpCode>())
4848
{
4949
sb.Append(" ").Append(Enum.GetName(opCode)).Append(" = ").Append((int)opCode).AppendLine(",");
5050
}
51+
5152
sb.AppendLine("}");
5253
sb.AppendLine();
5354

5455
sb.AppendLine($"public enum {nameof(XfOptionKeys)}");
5556
sb.AppendLine("{");
56-
foreach (XfOptionKeys optionKey in Enum.GetValues(typeof(XfOptionKeys)))
57+
foreach (XfOptionKeys optionKey in Enum.GetValues<XfOptionKeys>())
5758
{
5859
sb.Append(" ").Append(Enum.GetName(optionKey)).Append(" = ").Append((int)optionKey).AppendLine(",");
5960
}
61+
6062
sb.AppendLine("}");
6163
sb.AppendLine();
6264

6365
sb.AppendLine($"public enum {nameof(XfStatusCode)}");
6466
sb.AppendLine("{");
65-
foreach (XfStatusCode statusCode in Enum.GetValues(typeof(XfStatusCode)))
67+
foreach (XfStatusCode statusCode in Enum.GetValues<XfStatusCode>())
6668
{
6769
sb.Append(" ").Append(Enum.GetName(statusCode)).Append(" = ").Append((int)statusCode).AppendLine(",");
6870
}
71+
6972
sb.AppendLine("}");
7073
sb.AppendLine();
7174

7275
sb.AppendLine($"public enum {nameof(XfSubStatusCode)}");
7376
sb.AppendLine("{");
74-
foreach (XfSubStatusCode subStatus in Enum.GetValues(typeof(XfSubStatusCode)))
77+
foreach (XfSubStatusCode subStatus in Enum.GetValues<XfSubStatusCode>())
7578
{
7679
sb.Append(" ").Append(Enum.GetName(subStatus)).Append(" = ").Append((int)subStatus).AppendLine(",");
7780
}
81+
7882
sb.AppendLine("}");
7983
sb.AppendLine();
8084

8185
sb.AppendLine("public class XfCliApi");
8286
sb.AppendLine("{");
83-
string version = $"{parameters.Parser.ExportableCliVersion.Major},{parameters.Parser.ExportableCliVersion.Minor}";
87+
string version =
88+
$"{parameters.Parser.ExportableCliVersion.Major},{parameters.Parser.ExportableCliVersion.Minor}";
8489
sb.Append(" public Version XfCliVersion { get; } = new Version(").Append(version).AppendLine(");");
8590
sb.AppendLine();
8691
sb.AppendLine(" public List<(int, string, string)> XfCliOptions { get; } =");
@@ -89,6 +94,7 @@ public Task<Status> RealAsync(Parameters parameters)
8994
{
9095
sb.AppendLine($" ({def.OpCode}, \"{def.Prototype}\", \"{def.Description}\"),");
9196
}
97+
9298
sb.AppendLine(" ];");
9399
sb.AppendLine("}");
94100

src/Xecrets.Cli/Properties/PublishProfiles/linux-arm64.pubxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<TargetFramework>net8.0</TargetFramework>
1111
<RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
1212
<SelfContained>true</SelfContained>
13-
<PublishSingleFile>true</PublishSingleFile>
13+
<!-- PublishTrimmmed must be in publish profile, not in .csproj where it has no effect -->
1414
<PublishTrimmed>true</PublishTrimmed>
1515
</PropertyGroup>
1616
</Project>
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
3-
https://go.microsoft.com/fwlink/?LinkID=208121.
4-
-->
2+
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
53
<Project>
64
<PropertyGroup>
75
<Configuration>Release</Configuration>
@@ -12,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
1210
<TargetFramework>net8.0</TargetFramework>
1311
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
1412
<SelfContained>true</SelfContained>
15-
<PublishSingleFile>true</PublishSingleFile>
13+
<!-- PublishTrimmmed must be in publish profile, not in .csproj where it has no effect -->
1614
<PublishTrimmed>true</PublishTrimmed>
1715
</PropertyGroup>
1816
</Project>

src/Xecrets.Cli/Properties/PublishProfiles/osx-arm64.pubxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<TargetFramework>net8.0</TargetFramework>
1111
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
1212
<SelfContained>true</SelfContained>
13-
<PublishSingleFile>true</PublishSingleFile>
13+
<!-- PublishTrimmmed must be in publish profile, not in .csproj where it has no effect -->
1414
<PublishTrimmed>true</PublishTrimmed>
1515
</PropertyGroup>
1616
</Project>
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
3-
https://go.microsoft.com/fwlink/?LinkID=208121.
4-
-->
2+
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
53
<Project>
64
<PropertyGroup>
75
<Configuration>Release</Configuration>
@@ -12,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
1210
<TargetFramework>net8.0</TargetFramework>
1311
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
1412
<SelfContained>true</SelfContained>
15-
<PublishSingleFile>true</PublishSingleFile>
13+
<!-- PublishTrimmmed must be in publish profile, not in .csproj where it has no effect -->
1614
<PublishTrimmed>true</PublishTrimmed>
1715
</PropertyGroup>
1816
</Project>
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
3-
https://go.microsoft.com/fwlink/?LinkID=208121.
4-
-->
2+
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
53
<Project>
64
<PropertyGroup>
75
<Configuration>Release</Configuration>
@@ -12,8 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
1210
<TargetFramework>net8.0</TargetFramework>
1311
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
1412
<SelfContained>true</SelfContained>
15-
<PublishSingleFile>true</PublishSingleFile>
16-
<PublishReadyToRun>false</PublishReadyToRun>
13+
<!-- PublishTrimmmed must be in publish profile, not in .csproj where it has no effect -->
1714
<PublishTrimmed>true</PublishTrimmed>
1815
</PropertyGroup>
1916
</Project>
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
3-
https://go.microsoft.com/fwlink/?LinkID=208121.
4-
-->
2+
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
53
<Project>
64
<PropertyGroup>
75
<Configuration>Release</Configuration>
@@ -12,8 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
1210
<TargetFramework>net8.0</TargetFramework>
1311
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
1412
<SelfContained>true</SelfContained>
15-
<PublishSingleFile>true</PublishSingleFile>
16-
<PublishReadyToRun>false</PublishReadyToRun>
13+
<!-- PublishTrimmmed must be in publish profile, not in .csproj where it has no effect -->
1714
<PublishTrimmed>true</PublishTrimmed>
1815
</PropertyGroup>
1916
</Project>

src/Xecrets.Cli/Xecrets.Cli.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
<TransformOutOfDateOnly>false</TransformOutOfDateOnly>
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
99
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
10+
<PublishAot Condition="'$(RuntimeIdentifier)' == 'win-x64' Or '$(RuntimeIdentifier)' == 'win-arm64'">true</PublishAot>
11+
<PublishSingleFile Condition="'$(RuntimeIdentifier)' != 'win-x64' And '$(RuntimeIdentifier)' != 'win-arm64'">true</PublishSingleFile>
12+
<IsTrimmable>true</IsTrimmable>
13+
<IsAotCompatible>true</IsAotCompatible>
14+
<!-- Disable ReadyToRun since it incrases the size of the output significantly, with limited performance gain. -->
15+
<PublishReadyToRun>false</PublishReadyToRun>
16+
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
1017
</PropertyGroup>
1118
<PropertyGroup>
1219
<OutputType>Exe</OutputType>
@@ -24,15 +31,15 @@
2431
</PropertyGroup>
2532
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
2633
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
27-
<NoWarn></NoWarn>
2834
<WarningsNotAsErrors>
2935
</WarningsNotAsErrors>
3036
</PropertyGroup>
3137
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
3238
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
33-
<NoWarn></NoWarn>
3439
<ILLinkTreatWarningsAsErrors>false</ILLinkTreatWarningsAsErrors>
3540
<DebuggerSupport>false</DebuggerSupport>
41+
<OptimizationPreference>Speed</OptimizationPreference>
42+
<TrimmerSingleWarn>false</TrimmerSingleWarn>
3643
</PropertyGroup>
3744
<ItemGroup>
3845
<Content Include="XecretsCli.ico" />

0 commit comments

Comments
 (0)