Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,8 @@ jobs:
- name: Build
run: dotnet build -c Release

- name: Build (AOT Analyze)
run: dotnet build src/Ramstack.HtmxToolkit/Ramstack.HtmxToolkit.csproj -c Release -f net8.0 --no-incremental --no-restore --warnaserror -p:EnableAotAnalysis=true

# NOTE: net8.0 is CI-only (AOT analysis above); the package ships net6.0 assets only.
# Do not "fix" this to pack all TargetFrameworks without also updating the csproj comment.
- name: Restore NuGet Package
run: dotnet restore src/Ramstack.HtmxToolkit/Ramstack.HtmxToolkit.csproj -p:TargetFrameworks=net6.0

- name: Create NuGet Packages
run: dotnet pack src/Ramstack.HtmxToolkit/Ramstack.HtmxToolkit.csproj -c Release -o ./nuget --no-build --no-restore -p:TargetFrameworks=net6.0
run: dotnet pack src/Ramstack.HtmxToolkit/Ramstack.HtmxToolkit.csproj -c Release -o ./nuget --no-build --no-restore

- name: NuGet login (OIDC)
id: login
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ jobs:
- name: Build (Release)
run: dotnet build -c Release

- name: Build (AOT Analyze)
run: dotnet build src/Ramstack.HtmxToolkit/Ramstack.HtmxToolkit.csproj -c Release -f net8.0 --no-incremental --no-restore --warnaserror -p:EnableAotAnalysis=true
- name: Pack (AOT validation)
run: dotnet pack src/Ramstack.HtmxToolkit/Ramstack.HtmxToolkit.csproj -c Release -o "${RUNNER_TEMP}/aot-packages" --no-build --no-restore -p:MinVerVersionOverride=0.0.0-aot

- name: Restore (AOT validation)
run: dotnet restore tests/Ramstack.HtmxToolkit.AotValidation/Ramstack.HtmxToolkit.AotValidation.csproj -r linux-x64 --source "${RUNNER_TEMP}/aot-packages" --source https://api.nuget.org/v3/index.json

- name: Publish (AOT validation)
run: dotnet publish tests/Ramstack.HtmxToolkit.AotValidation/Ramstack.HtmxToolkit.AotValidation.csproj -c Release -r linux-x64 --no-restore --warnaserror

- name: Run (AOT validation)
run: tests/Ramstack.HtmxToolkit.AotValidation/bin/Release/net8.0/linux-x64/publish/Ramstack.HtmxToolkit.AotValidation

- name: Test (Debug)
run: dotnet test -c Debug --no-build
Expand Down
3 changes: 1 addition & 2 deletions src/Ramstack.HtmxToolkit/Ramstack.HtmxToolkit.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<IsAotCompatible Condition="'$(TargetFramework)' == 'net8.0' and '$(EnableAotAnalysis)' == 'true'">true</IsAotCompatible>
<TargetFramework>net6.0</TargetFramework>
<Description>Enables seamless integration of HTMX with ASP.NET Core (https://htmx.org).</Description>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
1 change: 1 addition & 0 deletions src/Ramstack.HtmxToolkit/TagHelpers/HtmxUrlTagHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Ramstack.HtmxToolkit.TagHelpers;
[HtmlTargetElement(Attributes = HostAttributeName)]
[HtmlTargetElement(Attributes = ProtocolAttributeName)]
[HtmlTargetElement(Attributes = FragmentAttributeName)]
[RequiresUnreferencedCode("Razor Page URL generation is not compatible with trimming.")]
public sealed class HtmxUrlTagHelper(IUrlHelperFactory factory) : TagHelper
{
private const string ActionAttributeName = "hx-action";
Expand Down
3 changes: 3 additions & 0 deletions tests/Ramstack.HtmxToolkit.AotValidation/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Ramstack.HtmxToolkit;

Console.WriteLine(HtmxAssets.Hash);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<ILLinkTreatWarningsAsErrors>true</ILLinkTreatWarningsAsErrors>
<!-- CI restores this synthetic version from its runner-local package source. -->
<AotPackageVersion Condition="'$(AotPackageVersion)' == ''">0.0.0-aot</AotPackageVersion>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Ramstack.HtmxToolkit" Version="$(AotPackageVersion)" />
<!-- Analyze every library method, including APIs not called by Program.cs. -->
<TrimmerRootDescriptor Include="TrimmerRoots.xml" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions tests/Ramstack.HtmxToolkit.AotValidation/TrimmerRoots.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<linker>
<!--
Roots the full API surface of Ramstack.HtmxToolkit so trimming and Native AOT analyze
every reachable member, even APIs that Program.cs never calls.

HtmxUrlTagHelper is intentionally excluded: it is marked [RequiresUnreferencedCode]
(Razor Page URL generation is trim-incompatible), and rooting it leaks IL2026 from the
unannotated framework UrlHelperExtensions. Everything else must stay AOT-clean.

When a new tag helper is added, list it here unless it is genuinely trim-incompatible.
-->
<assembly fullname="Ramstack.HtmxToolkit">
<namespace fullname="Ramstack.HtmxToolkit" />
<namespace fullname="Ramstack.HtmxToolkit.Collections" />
<namespace fullname="Ramstack.HtmxToolkit.Configuration" />
<namespace fullname="Ramstack.HtmxToolkit.Hosting" />
<namespace fullname="Ramstack.HtmxToolkit.Internal" />
<namespace fullname="Ramstack.HtmxToolkit.Serialization" />
<type fullname="Ramstack.HtmxToolkit.TagHelpers.HtmxConfigTagHelper" />
<type fullname="Ramstack.HtmxToolkit.TagHelpers.HtmxHeaderTagHelper" />
<type fullname="Ramstack.HtmxToolkit.TagHelpers.HtmxRequestTagHelper" />
<type fullname="Ramstack.HtmxToolkit.TagHelpers.HtmxValsTagHelper" />
</assembly>
</linker>