Middle · Trace · AOT metadata needs an explicit reachability plan

Trace the direct-registry companion and identify which deployment behavior it does not execute.

Think through your answer before opening the explanation.

Runtime & concurrency

using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Reflection;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;

var registry = new Dictionary<string, Func<IMessage>>(StringComparer.Ordinal) { ["rune"] = () => new RuneMessage() };
Console.WriteLine($"message:{registry["rune"]().Text}");
Console.WriteLine($"missing:{registry.TryGetValue("other", out _)}");
public interface IMessage { string Text { get; } }
public sealed class RuneMessage : IMessage { public RuneMessage() { } public string Text => "rune"; }
Reveal answer and reasoning

The registry contains rune mapped to a factory that constructs RuneMessage, whose Text is rune. The first line is message:rune. There is no association for other, so TryGetValue returns false and the second line is missing:False. This portable snippet uses direct known construction and an ordinal application key; it does not invoke Activator or discover arbitrary types by name.

The external project separately executes an annotated reflection path and checks agreement, but that code is not hidden inside this companion. A common wrong trace invents an AOT publication or annotation output because the lesson discusses deployment. These lines establish a bounded registry contract only. They do not prove a native artifact exists, that every member was preserved, or that unknown plugin types can be loaded.

Keeping this distinction explicit prevents similar domain results from being mislabeled as identical runtime capabilities.

What a strong answer covers

  • The direct message is rune.
  • The unknown key is absent.
  • This snippet neither reflects nor publishes a native app.

Common pitfall

Attributing an external reflection or NativeAOT operation to the portable registry snippet.

Follow-up questions

  1. What would a second registered message add?
  2. How should an unknown external key be reported?

Self-review

Choose what to revisit. These marks are your own assessment and are separate from lesson completion.

Primary references

Open lesson and code ↗

← All interview questions