Skip to content

Make structured logging libraries Native AOT compatible - #963

Draft
baronfel wants to merge 2 commits into
mainfrom
baronfel-aot-trim-logging
Draft

Make structured logging libraries Native AOT compatible#963
baronfel wants to merge 2 commits into
mainfrom
baronfel-aot-trim-logging

Conversation

@baronfel

@baronfel baronfel commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • mark MSBuild.StructuredLogger and MSBuild.StructuredLogger.Utils as AOT-compatible on modern target frameworks
  • replace trim-unsafe reflection and Activator-based object-model construction with statically analyzable code
  • preserve the required MSBuild ItemDictionary<T> reflection path with precise linker rooting
  • add coverage ensuring every concrete object-model node remains constructible
  • add a warning-as-error Native AOT smoke project that exercises both libraries and parses a committed binlog fixture
  • publish and run the native smoke executable in AppVeyor

Validation

  • targeted object-model construction test passes
  • Native AOT publish completes with zero warnings and errors
  • native executable reads the bundled 7-record fixture
  • native executable successfully parsed a real 14,496-record build log from this repository

Enable AOT analysis for the core libraries and replace trim-unsafe reflection and dynamic node construction with statically analyzable code.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c4e0c6d3-54cb-41fb-9c49-c73675669ee2
Publish and run a trimmed Native AOT executable in CI. Exercise node construction, reflection-sensitive accessors, utility XML parsing, and real binlog parsing with a deterministic fixture or an external binlog path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c4e0c6d3-54cb-41fb-9c49-c73675669ee2
@baronfel

baronfel commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

@KirillOsenkov this is mostly vibe-coded nonsense, but I think it could be really interesting to consider making the library trimmable to enable smaller/faster CLI apps!

@baronfel

baronfel commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

(and by that I mean that I think that the core changes are maybe ok but if you were interested in taking it I'd make a proper harness and other niceties)

slang25 added a commit to slang25/MSBuildStructuredLog that referenced this pull request Sep 6, 2026
…otations

Chet Husk's DynamicallyAccessedMembers annotations on the Reflector
accessors (upstream PR KirillOsenkov#963) keep the event-args fields alive under
trimming, so the bridge and the browser-wasm engine no longer need to root
the whole types. Verified: the dylib smoke test reads 113,564 nodes and the
engine test page reads 357,856 in Chrome.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

1 participant