feat: AOT compliance with multi-targeting (netstandard2.1 + net8.0 + net10.0)#41
Merged
Conversation
- Multi-target netstandard2.1;net8.0;net10.0 - Set IsAotCompatible=true for net8.0+ targets - Replace XmlSerializer with XDocument/XElement parsing (AOT-safe, works across all targets - no #if needed) - Remove now-unused [XmlRoot]/[XmlElement]/[XmlAttribute] attributes and System.Xml.Serialization references from all model classes
- Add TrxLib.AotSample console app with PublishAot=true - Add 'AOT Publish Validation' step to build-and-test CI workflow, running dotnet publish on both ubuntu-latest (linux-x64) and windows-latest (win-x64)
…FQTN for theories, fix AOT smoke test - Add Execution, Counters, ResultSummary, TestList, TestLists, TestEntry, TestEntries model classes - Parse all previously-missing fields: RunUser, ResultSummary/Counters, TestLists, TestEntries, UnitTest.Storage/Execution, UnitTestResult.ExecutionId/TestListId/TestType/RelativeResultsDirectory - Set TestResultSet.TestRunId, DeploymentRoot, TestSettingsName from parsed data - Fix FQTN construction to include theory parameter suffixes (e.g. '(arg1, arg2)') - Narrow catch(Exception) to catch(XmlException) in DeserializeTestRun - Fix AOT smoke test to write a minimal TRX to a temp file and actually parse it, asserting the result - CI: run the published native binary after dotnet publish to catch runtime-only regressions
Contributor
There was a problem hiding this comment.
Pull request overview
Makes TrxLib AOT-compatible by replacing XmlSerializer-based deserialization with manual XDocument/XElement parsing, adds multi-targeting (netstandard2.1;net8.0;net10.0) with IsAotCompatible=true on net8.0+, and introduces an AOT smoke-test app exercised in CI on Linux and Windows.
Changes:
- Replaced
XmlSerializerwithXDocumenttraversal inTrxParser, populated previously-unset fields (RunUser,ResultSummary/Counters,TestLists,TestEntries,UnitTest.Storage/Execution, severalUnitTestResultattributes), and fixed FQTN to append parameter suffixes for theory tests. - Added new model classes (
Execution,Counters,ResultSummary,TestList/TestLists,TestEntry/TestEntries); removed[Xml*]attributes andSystem.Xml.Serializationusings from existing models. - Added
TrxLib.AotSamplenet10.0 console app withPublishAot=trueand a CI step that publishes and executes the native binary on both ubuntu and windows runners.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| TrxLib/TrxLib.csproj | Multi-targets netstandard2.1/net8.0/net10.0; enables IsAotCompatible on net8+ |
| TrxLib/TrxParser.cs | Switches from XmlSerializer to XDocument; populates new fields; adds parameterized FQTN suffix logic |
| TrxLib/TestRun.cs | Adds RunUser, ResultSummary, TestLists, TestEntries; drops Xml attributes |
| TrxLib/UnitTest.cs | Adds Storage and Execution; drops Xml attributes |
| TrxLib/UnitTestResult.cs | Adds ExecutionId, TestListId, TestType, RelativeResultsDirectory; drops Xml attributes |
| TrxLib/TestMethod.cs, Times.cs, TestSettings.cs, TestDefinitions.cs, Results.cs, Output.cs, ErrorInfo.cs, Deployment.cs | Removed inert Xml serialization attributes/usings |
| TrxLib/Execution.cs, Counters.cs, ResultSummary.cs, TestList.cs, TestLists.cs, TestEntry.cs, TestEntries.cs | New model types for previously-unmapped TRX elements |
| TrxLib.sln | Adds TrxLib.AotSample project and x64/x86 solution configs |
| TrxLib.AotSample/TrxLib.AotSample.csproj | New net10.0 AOT-publishable console app referencing TrxLib |
| TrxLib.AotSample/Program.cs | Writes minimal TRX, parses with TrxParser, asserts TestRunName |
| .github/workflows/build-and-test.yml | Adds AOT Publish Validation step that publishes self-contained and runs the native binary |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Resolve modify/delete conflict on TrxLib.sln: main migrated to .slnx, so delete .sln and add TrxLib.AotSample to TrxLib.slnx instead. Action version bumps and package updates from main auto-merged cleanly.
Add theory-tests.trx fixture with two AddNumbers(x, y) theory instances and one plain PlainTest. Add three tests to TrxParserTests covering: - suffix appended for parameterized tests (1, 2) and (0, 0) - no suffix appended for a non-parameterized test - all three results parsed with correct count and outcome Resolves review comment on TrxParser.cs:86 re: missing coverage for the FQTN parameter-suffix branching logic.
Resolve overlapping parser/model conflicts by keeping AOT-safe LINQ-to-XML parser implementation and applying main's updated tests/model assertions. Also align theory-parameter FQTN suffix extraction to support both short and fully-qualified testName prefixes.
Re-add StringComparison.Ordinal to all StartsWith checks in the FQTN reconstruction block so identifier matching is culture-invariant.
Update the native AOT smoke app to parse all bundled TRX sample files from TrxLib.Tests/SampleTrxFiles in a single run. Add linked content items in the sample project so fixtures are copied to output/publish.
Remove SuppressNETCoreSdkPreviewMessage from the AOT sample project. Replace the committed theory-tests.trx fixture with a test helper that creates equivalent TRX content at runtime, copies it to a temp file, and parses that copied file for coverage.
Create the theory fixture from real test execution output instead of hand-authored XML. The fixture was generated by temporary theory tests, written via dotnet test --logger trx, then copied into SampleTrxFiles. Parser tests now consume theory-tests.trx directly.
BenjaminMichaelis
added a commit
that referenced
this pull request
May 17, 2026
…net10.0) (#41) ## Summary Makes TrxLib fully AOT-compatible by replacing `XmlSerializer` with `XDocument`/`XElement` manual parsing, adding multi-targeting, and validating with a native AOT smoke-test project in CI. ## Changes ### Library (`TrxLib`) - **Multi-target**: `netstandard2.1;net8.0;net10.0` — keeps backward compatibility while enabling `IsAotCompatible=true` on net8.0+ - **Parser rewrite**: `XmlSerializer` → `XDocument.Load()` + `XElement` navigation (fully AOT-safe, available on all targets, no `#if` branching) - **New model classes**: `Execution`, `Counters`, `ResultSummary`, `TestList`, `TestLists`, `TestEntry`, `TestEntries` - **Complete parsing**: all previously-unset fields now populated — `RunUser`, `ResultSummary`/`Counters`, `TestLists`, `TestEntries`, `UnitTest.Storage`/`Execution`, `UnitTestResult.ExecutionId`/`TestListId`/`TestType`/`RelativeResultsDirectory` - **`TestResultSet` properties**: `TestRunId`, `DeploymentRoot`, `TestSettingsName` now populated from parsed data - **Theory/parameterized test names**: FQTN now correctly appends parameter suffixes (e.g. `MethodName(arg: "value")`) - **Exception handling**: `catch (Exception)` narrowed to `catch (XmlException)` in the XML loading path - **Cleanup**: removed inert `[XmlRoot]`/`[XmlElement]`/`[XmlAttribute]` attributes and `using System.Xml.Serialization` from all model classes ### AOT Smoke Test (`TrxLib.AotSample`) - New `net10.0` console app with `PublishAot=true` that references TrxLib - Writes a minimal TRX to a temp file, parses it with `TrxParser.Parse`, and asserts the result — exercising the full `XDocument` parse path in the native binary ### CI (`.github/workflows/build-and-test.yml`) - Added `AOT Publish Validation` step to the existing matrix job (ubuntu + windows) - Runs `dotnet publish -r <rid> --self-contained` then **executes the native binary** to catch both link-time and runtime AOT regressions ## Verification - ✅ 38/38 tests pass - ✅ `dotnet build` — 0 AOT analyzer warnings on net8.0/net10.0 - ✅ `dotnet publish -r win-x64` — 0 ILLink/AOT warnings - ✅ Native binary runs and prints `TrxLib AOT validation passed.` fix
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.
Summary
Makes TrxLib fully AOT-compatible by replacing
XmlSerializerwithXDocument/XElementmanual parsing, adding multi-targeting, and validating with a native AOT smoke-test project in CI.Changes
Library (
TrxLib)netstandard2.1;net8.0;net10.0— keeps backward compatibility while enablingIsAotCompatible=trueon net8.0+XmlSerializer→XDocument.Load()+XElementnavigation (fully AOT-safe, available on all targets, no#ifbranching)Execution,Counters,ResultSummary,TestList,TestLists,TestEntry,TestEntriesRunUser,ResultSummary/Counters,TestLists,TestEntries,UnitTest.Storage/Execution,UnitTestResult.ExecutionId/TestListId/TestType/RelativeResultsDirectoryTestResultSetproperties:TestRunId,DeploymentRoot,TestSettingsNamenow populated from parsed dataMethodName(arg: "value"))catch (Exception)narrowed tocatch (XmlException)in the XML loading path[XmlRoot]/[XmlElement]/[XmlAttribute]attributes andusing System.Xml.Serializationfrom all model classesAOT Smoke Test (
TrxLib.AotSample)net10.0console app withPublishAot=truethat references TrxLibTrxParser.Parse, and asserts the result — exercising the fullXDocumentparse path in the native binaryCI (
.github/workflows/build-and-test.yml)AOT Publish Validationstep to the existing matrix job (ubuntu + windows)dotnet publish -r <rid> --self-containedthen executes the native binary to catch both link-time and runtime AOT regressionsVerification
dotnet build— 0 AOT analyzer warnings on net8.0/net10.0dotnet publish -r win-x64— 0 ILLink/AOT warningsTrxLib AOT validation passed.