Skip to content

WIP: Native AOT migration of Ecng runtime paths and compatibility verification - #35

Draft
mikasoukhov wants to merge 43 commits into
masterfrom
feature/ecng-aot-audit-registries-20261107
Draft

mikasoukhov wants to merge 43 commits into
masterfrom
feature/ecng-aot-audit-registries-20261107

Conversation

@mikasoukhov

@mikasoukhov mikasoukhov commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Actual runtime changes (same PR, no master merge)

Ecng.Common

  • TypeHelper.CreateInstance uses registered, statically compiled constructors before the original reflection fallback.
  • TypeHelper.Make resolves precompiled closed generic types from a concurrent structural registry, avoiding a global lock and repeated candidate metadata arrays.
  • ArrayHelper.CreateArray now uses static factories for common element types out of the box and allows explicit registration for model arrays.
  • Converter.ArrayCovariance routes array creation through the same AOT-safe path.
  • Converter.RegisterTypeName resolves pre-registered model types before assembly scanning.
  • FastActivator<T> supports explicit delegates and avoids Reflection.Emit and constructor inspection on Native AOT.

Ecng.Serialization

  • Existing SettingsStorage sync/async persistable creation now goes through the registered factory path.
  • Existing JsonSerializer list/array materialization uses precompiled generic types, constructors and array factories.
  • JArrayToObjectConverter<T> now supports explicit precompiled field accessors in wire order, avoiding Reflection.Emit and runtime field metadata assumptions. JIT reflection fallback remains unchanged.
  • JsonHelper provides source-generated JSON metadata overloads; non-generic variants are limited to net7+ to preserve net6 support.
  • JSON reflection field scanning is annotated for trimming.

Ecng.Reflection

  • FindImplementations<T> uses RegisterImplementation<TContract,TImplementation> registrations in Native AOT rather than scanning loaded assemblies. JIT scanning stays available.

Verification

  • Dedicated workflow audits Ecng.Common and Serialization for IL2xxx/IL3xxx warnings, includes a net6 compilation check, builds net10 native executable and executes smoke tests.
  • Smoke exercises the actual legacy settings, collection serializer, static implementation discovery, field-based JSON and source-generated JSON paths.
  • Regular cross-platform .NET tests run separately.
  • Historical legacy Newtonsoft and unregistered reflection APIs still carry AOT warnings; this PR does NOT claim all Ecng APIs to be universally AOT-safe.
  • Keep PR draft until the most recent commit passes native and standard CI. No blanket NoWarn and no change to NuGet release workflow.

@mikasoukhov mikasoukhov changed the title WIP: Native AOT analysis, static type/factory registration and source-generated JSON WIP: Native AOT migration of Ecng runtime paths and compatibility verification Nov 8, 2026
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