Skip to content

feat: AOT compliance with multi-targeting (netstandard2.1 + net8.0 + net10.0)#41

Merged
BenjaminMichaelis merged 10 commits into
mainfrom
feature/aot-compliance
May 17, 2026
Merged

feat: AOT compliance with multi-targeting (netstandard2.1 + net8.0 + net10.0)#41
BenjaminMichaelis merged 10 commits into
mainfrom
feature/aot-compliance

Conversation

@BenjaminMichaelis
Copy link
Copy Markdown
Owner

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: XmlSerializerXDocument.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.

- 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
Copilot AI review requested due to automatic review settings May 16, 2026 22:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 XmlSerializer with XDocument traversal in TrxParser, populated previously-unset fields (RunUser, ResultSummary/Counters, TestLists, TestEntries, UnitTest.Storage/Execution, several UnitTestResult attributes), and fixed FQTN to append parameter suffixes for theory tests.
  • Added new model classes (Execution, Counters, ResultSummary, TestList/TestLists, TestEntry/TestEntries); removed [Xml*] attributes and System.Xml.Serialization usings from existing models.
  • Added TrxLib.AotSample net10.0 console app with PublishAot=true and 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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

Comment thread TrxLib/TrxParser.cs
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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.

Comment thread TrxLib/TrxParser.cs Outdated
Re-add StringComparison.Ordinal to all StartsWith checks in the
FQTN reconstruction block so identifier matching is culture-invariant.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated no new comments.

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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated no new comments.

@BenjaminMichaelis BenjaminMichaelis merged commit 4d0a78f into main May 17, 2026
10 checks passed
@BenjaminMichaelis BenjaminMichaelis deleted the feature/aot-compliance branch May 17, 2026 05:07
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants