Skip to content

feat(AOT): Annotate Create with RequiresDynamicCode / RequiresUnreferencedCode#314

Open
dimension-zero wants to merge 1 commit into
fsprojects:masterfrom
dimension-zero:pr/26-trim-aot-readiness
Open

feat(AOT): Annotate Create with RequiresDynamicCode / RequiresUnreferencedCode#314
dimension-zero wants to merge 1 commit into
fsprojects:masterfrom
dimension-zero:pr/26-trim-aot-readiness

Conversation

@dimension-zero
Copy link
Copy Markdown
Contributor

feat(AOT): Annotate Create with RequiresDynamicCode / RequiresUnreferencedCode

  • New file TrimAnnotations.fs: internal polyfills in
    System.Diagnostics.CodeAnalysis for RequiresDynamicCodeAttribute and
    RequiresUnreferencedCodeAttribute. The trimmer and AOT compiler
    resolve attributes by full type name, so internal copies in this
    assembly are picked up. Guarded with #if !NET7_0_OR_GREATER so a
    future multi-target picks up the real BCL attributes.
  • ArgumentParser.fs:
    • Add module TrimMessages with constant explanatory strings.
    • Annotate ArgumentParser.Create<'Template> with both attributes so
      AOT-publish consumers see IL3050 and trim-publish consumers see
      IL2026, each with a clear message pointing at the underlying
      reflection use (MakeGenericType / Activator / FSharpType).
  • Argu.fsproj: set IsTrimmable=true and IsAotCompatible=false guarded
    with MSBuild IsTargetFrameworkCompatible('net8.0') so netstandard2.0
    builds still succeed without NETSDK1212 noise. A future multi-target
    pass to net8.0 will activate these flags automatically.

Pure metadata addition. No runtime impact. All 112 tests pass.


…encedCode

* New file TrimAnnotations.fs: internal polyfills in
  System.Diagnostics.CodeAnalysis for RequiresDynamicCodeAttribute and
  RequiresUnreferencedCodeAttribute. The trimmer and AOT compiler
  resolve attributes by full type name, so internal copies in this
  assembly are picked up. Guarded with #if !NET7_0_OR_GREATER so a
  future multi-target picks up the real BCL attributes.
* ArgumentParser.fs:
  - Add module TrimMessages with constant explanatory strings.
  - Annotate ArgumentParser.Create<'Template> with both attributes so
    AOT-publish consumers see IL3050 and trim-publish consumers see
    IL2026, each with a clear message pointing at the underlying
    reflection use (MakeGenericType / Activator / FSharpType).
* Argu.fsproj: set IsTrimmable=true and IsAotCompatible=false guarded
  with MSBuild IsTargetFrameworkCompatible('net8.0') so netstandard2.0
  builds still succeed without NETSDK1212 noise. A future multi-target
  pass to net8.0 will activate these flags automatically.

Pure metadata addition. No runtime impact. All 112 tests pass.
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