Skip to content

Hosting samples: class registry keys; document class keys for IRequiredActor under Native AOT - #8674

Merged
Aaronontheweb merged 1 commit into
akkadotnet:devfrom
Aaronontheweb:fix/hosting-samples-class-keys
Sep 30, 2026
Merged

Aaronontheweb merged 1 commit into
akkadotnet:devfrom
Aaronontheweb:fix/hosting-samples-class-keys

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Member

The Hosting samples use public struct Echo{} as the ActorRegistry / IRequiredActor<TKey> key. That works on the JIT but fails under Native AOT. IRequiredActor<> is an open-generic DI registration, and Microsoft.Extensions.DependencyInjection can't close it with MakeGenericType for a value-type argument when dynamic code isn't available.

  • The three samples (SimpleDemo, LoggingDemo, Asp.LoggingDemo) now use public sealed class Echo{}.
  • docs/articles/hosting/dependency-injection.md gets a short note: use a class, not a struct, as the type key.

No API change. We considered constraining IRequiredActor<TActor> to class, but that would break apps at compile time that copied the old samples, even non-AOT ones, so the docs route was chosen.

…quiredActor under Native AOT

The samples' struct Echo{} keys work on the JIT but fail under Native AOT:
MS.DI can't close the open-generic IRequiredActor<> registration for a value type.
@Aaronontheweb Aaronontheweb added the AOT Ahead-of-Time (AOT) Compilation label Sep 30, 2026
@Aaronontheweb
Aaronontheweb enabled auto-merge (squash) September 30, 2026 16:12

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM

@Aaronontheweb
Aaronontheweb merged commit 1f16a3d into akkadotnet:dev Sep 30, 2026
16 checks passed
@Aaronontheweb
Aaronontheweb deleted the fix/hosting-samples-class-keys branch September 30, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AOT Ahead-of-Time (AOT) Compilation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant