Add explicit Native AOT/trim compatibility and CI smoke publish for Semantic - #22
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/Franchef/Semantic.NET/sessions/f1cef637-b641-4f1b-8a0f-24116fbdefe6 Co-authored-by: Franchef <55815835+Franchef@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Franchef/Semantic.NET/sessions/f1cef637-b641-4f1b-8a0f-24116fbdefe6 Co-authored-by: Franchef <55815835+Franchef@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update project configuration for Native AOT and trimming compatibility
Add explicit Native AOT/trim compatibility and CI smoke publish for Semantic
May 9, 2026
Franchef
approved these changes
May 9, 2026
Franchef
marked this pull request as ready for review
May 9, 2026 19:38
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22 +/- ##
=======================================
Coverage 95.95% 95.95%
=======================================
Files 7 7
Lines 99 99
Branches 20 20
=======================================
Hits 95 95
Misses 2 2
Partials 2 2 ☔ View full report in Codecov by Sentry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes Native AOT/trimming support explicit and continuously validated for
Semanticwhile preserving the existing public API and target framework. It also adds a minimal executable smoke app that exercises the core semantic builders under AOT publish.Library AOT/trim contract
Semantic/Semantic.csprojto declare compatibility and enable analysis:IsAotCompatibleIsTrimmableEnableTrimAnalyzerNative AOT smoke app
NativeAotSmokeconsole project referencingSemantic.PatternMatchesBuilderSlidingWindowBuilderMovingAverageBuilderCI enforcement
.github/workflows/ci.ymlwith a Native AOT publish step for the smoke app (linux-x64, trimmed + AOT).Related low-risk cleanup
using System.Buffers;fromSemantic/Sequences/PatternMatches.cs.Original prompt
Implement Native AOT / trimming-friendly improvements in
Franchef/Semantic.NETon branchchore/native-aot-trim-friendlyand open a pull request back tomain.Context:
Semantic) with semantic utilities underSemantic/SequencesandSemantic/Statistic.Requested changes:
Update the library project configuration in
Semantic/Semantic.csprojto explicitly enable Native AOT / trimming compatibility analysis.<IsAotCompatible>true</IsAotCompatible><IsTrimmable>true</IsTrimmable><EnableTrimAnalyzer>true</EnableTrimAnalyzer>Add a minimal Native AOT smoke test sample/app in the repository that references the
Semanticlibrary and exercises the main semantic extensions:PatternMatchesBuilderSlidingWindowBuilderMovingAverageBuilderThe sample should be suitable for publish-time validation with AOT/trimming (for example via
PublishAot=trueandPublishTrimmed=true).Add CI validation for the Native AOT scenario.
Clean up any low-risk code issues found during review that support the goal.
using System.Buffers;inSemantic/Sequences/PatternMatches.csif still present).Implementation guidance:
Deliverable:
chore/native-aot-trim-friendlytomainwith a concise title and summary of the AOT/trim-friendly improvements.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: in this repo, for Native AOT Compatibility: Ensure all semantic extensions are "Trim-friendly" so the library can be used in high-performance, cloud-native environments.
Assistant: This repo already looks largely Native AOT / trimming-safe, and I don’t see obvious reflection-heavy or linker-hostile patterns in the current semantic extensions.
What I found:
System.ReflectionActivator.CreateInstanceType.GetTypeKey files reviewed:
Semantic/Sequences/PatternMatches.csSemantic/Sequences/PatternMatchesBuilder.csSemantic/Sequences/SlidingWindow.csSemantic/Sequences/SlidingWindowBuilder.csSemantic/Statistic/MovingAverage.csSemantic/Statistic/MovingAverageBuilder.csSemantic/Statistic/MovingAverageCustomStep.csSemantic/Semantic.csprojAssessment
Current status: likely already trim-friendly by implementation.
The code uses:
EqualityComparer<T>.DefaultThose are generally fine for Native AOT.
Main improvement I recommend
The repo is missing explicit trimming/AOT validation in the project configuration and CI.
So the best next step is to make compatibility intentional and enforceable, not just incidental.
Suggested changes
Semantic/Semantic.csprojAdd properties like:
IsAotCompatibleIsTrimmableEnableTrimAnalyzerExample:
Create a sample app that:
SemanticPatternMatchesBuilder, `SlidingW...This pull request was created from Copilot chat.