-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components
Description
aspnetcore/src/Components/Endpoints/src/Rendering/SSRRenderModeBoundary.cs
Lines 209 to 222 in 223fe49
private ComponentMarkerKey GenerateMarkerKey(int sequence, object? componentKey) | |
{ | |
var componentTypeNameHash = _componentTypeNameHashCache.GetOrAdd(_componentType, TypeNameHash.Compute); | |
var sequenceString = sequence.ToString(CultureInfo.InvariantCulture); | |
var locationHash = $"{componentTypeNameHash}:{sequenceString}"; | |
var formattedComponentKey = (componentKey as IFormattable)?.ToString(null, CultureInfo.InvariantCulture) ?? string.Empty; | |
return new() | |
{ | |
LocationHash = locationHash, | |
FormattedComponentKey = formattedComponentKey, | |
}; | |
} |
The attached code fails when you provide a string as a key, since strings are not IFormattable. We should explicitly check if the key is already a string and use it directly.
We should also have a reasonable set of tests that validate that all common primitive types that we expect to work (ints, guids, and so on) successfully generate a key string.
Copilot
Metadata
Metadata
Assignees
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components