Repository navigation
Name the component, not its element, in RenderError — and report mount, host-root and ErrorBoundary-caught render errors #1323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Alexandre Zollinger Chohfi (azchohfi)
merged 19 commits into
main
from
azchohfi-render-error-component-name
Oct 7, 2026
Merged
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a6b40e9
Name the component, not its element, in RenderError
azchohfi 3404692
Report render errors an ErrorBoundary catches
azchohfi 6728ac4
Cover RenderError on func/memo mount, nested boundary throws, and bot…
azchohfi 96b4ab9
Cache generic component names and skip ComponentUnmount naming when t…
azchohfi d348e74
CHANGELOG: RenderError names the component and reports every render e…
azchohfi fe20e8f
Record the render-error catches in the spec-044 swallowed-error ledger
azchohfi 5f95751
Don't read Exception.Message when emitting RenderError
azchohfi b1c100e
Report every exception an ErrorBoundary recovers from; fix stale attr…
azchohfi d8496be
Report OOM/SO render failures outside a boundary too
azchohfi 4075055
Merge origin/main into azchohfi-render-error-component-name
azchohfi 9ee41ea
Report root effect failures; name rollback unmounts like other unmounts
azchohfi 0469209
Attribute root failures to the root that threw; format generic array …
azchohfi 10f0fdb
Merge origin/main into azchohfi-render-error-component-name
azchohfi ef58dd2
Name derived function/memo elements by their own type on mount
azchohfi 288575b
Merge remote-tracking branch 'origin/main' into azchohfi-render-error…
azchohfi b585258
Format generic derived element names like any other generic component
azchohfi 918ab90
Merge remote-tracking branch 'origin/main' into azchohfi-render-error…
azchohfi 3cc6999
Use System.Threading.Lock for the host registry gate (IDE0330)
azchohfi 671fed2
Merge remote-tracking branch 'origin/main' into azchohfi-render-error…
azchohfi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| namespace Microsoft.UI.Reactor.Core.Diagnostics; | ||
|
|
||
| /// <summary> | ||
| /// The component name Reactor's diagnostics report (<c>ReactorEventSource</c> | ||
| /// <c>RenderError</c>, <c>ComponentRenderStart</c>/<c>Stop</c>, | ||
| /// <c>EffectsFlushStart</c>/<c>Stop</c>, <c>ComponentUnmount</c>, and the | ||
| /// reconciler's <c>ILogger</c> messages). | ||
| /// | ||
| /// <para><b>Why not <c>element.GetType().Name</c>.</b> A class component is carried by a | ||
| /// <see cref="ComponentElement"/> — and by <c>ComponentElement<TProps></c> for | ||
| /// <c>Component<T, TProps>(…)</c> — so naming the <em>element</em> reports | ||
| /// <c>ComponentElement</c> / <c>ComponentElement`1</c> for every class component in | ||
| /// the app. The component is <see cref="ComponentElement.ComponentType"/> (or the live | ||
| /// instance's type, which wins after a hot-reload type swap).</para> | ||
| /// | ||
| /// <para><b>Shape.</b> The type's own simple name, as before, for a non-generic | ||
| /// component (<c>Counter</c>), so existing traces and greps are unchanged. A generic | ||
| /// component renders its arity in C# form (<c>Counter<Int32></c>) instead of the | ||
| /// metadata name (<c>Counter`1</c>). Function and memo components have no type of their | ||
| /// own and keep reporting <c>FuncElement</c> / <c>MemoElement</c>.</para> | ||
| /// | ||
| /// <para><b>PII.</b> Output is built only from developer-authored type names — never | ||
| /// props, state, keys or paths — so it is safe on the ETW payload | ||
| /// (spec 044 §6.2.1).</para> | ||
| /// | ||
| /// <para>Reflection-light (<c>Type.Name</c> and <c>Type.GetGenericArguments()</c>), | ||
| /// so it is trim- and AOT-safe.</para> | ||
| /// </summary> | ||
| internal static class ComponentNames | ||
| { | ||
| /// <summary> | ||
| /// Name for a component node: the live <paramref name="instance"/>'s type when there | ||
| /// is one, else the component type an element declares, else the element's own type | ||
| /// (<c>FuncElement</c>, <c>MemoElement</c>). | ||
| /// </summary> | ||
| internal static string For(Component? instance, Element? element) | ||
| { | ||
| if (instance is not null) return For(instance.GetType()); | ||
| if (element is ComponentElement componentElement) return For(componentElement.ComponentType); | ||
| return element?.GetType().Name ?? "unknown"; | ||
|
azchohfi marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /// <summary>Display name of a component type; see the class remarks for the shape.</summary> | ||
| internal static string For(Type type) | ||
| { | ||
| if (!type.IsGenericType) return type.Name; | ||
|
|
||
| // Generic names are built, so cache them: the name is asked for on every traced | ||
| // render and unmount. A weak table, so it never roots a collectible or hot-reloaded type. | ||
| return s_genericNames.GetValue(type, static t => | ||
| { | ||
| var sb = new global::System.Text.StringBuilder(); | ||
| Append(sb, t); | ||
| return sb.ToString(); | ||
| }); | ||
| } | ||
|
azchohfi marked this conversation as resolved.
|
||
|
|
||
| private static readonly global::System.Runtime.CompilerServices.ConditionalWeakTable<Type, string> s_genericNames = new(); | ||
|
|
||
| private static void Append(global::System.Text.StringBuilder sb, Type type) | ||
| { | ||
| var name = type.Name; | ||
| var tick = name.IndexOf('`'); | ||
| sb.Append(tick >= 0 ? name.Substring(0, tick) : name); | ||
|
|
||
| if (!type.IsGenericType) return; | ||
|
|
||
| // For a nested generic the flat argument list also carries the declaring type's | ||
| // arguments; this name only reports the ones it introduces itself. | ||
| var args = type.GetGenericArguments(); | ||
| int own = tick >= 0 && int.TryParse(name.AsSpan(tick + 1), out var arity) ? arity : 0; | ||
| if (own == 0) return; | ||
|
|
||
| sb.Append('<'); | ||
| for (int i = args.Length - own; i < args.Length; i++) | ||
| { | ||
| if (i > args.Length - own) sb.Append(", "); | ||
| Append(sb, args[i]); | ||
| } | ||
| sb.Append('>'); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.