Skip to content

Commit 9696917

Browse files
Copilotdanroth27
andcommitted
Remove RenderFragment contravariance from release notes (bug fix)
Co-authored-by: danroth27 <1874516+danroth27@users.noreply.github.com>
1 parent 61d9969 commit 9696917

1 file changed

Lines changed: 0 additions & 37 deletions

File tree

release-notes/11.0/preview/preview1/aspnetcore.md

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Here's a summary of what's new in ASP.NET Core in this preview release:
66
- [Label component for forms](#label-component-for-forms)
77
- [DisplayName component](#displayname-component)
88
- [QuickGrid `OnRowClick` event](#quickgrid-onrowclick-event)
9-
- [RenderFragment contravariance](#renderfragment-contravariance)
109
- [Relative navigation with `RelativeToCurrentUri`](#relative-navigation-with-relativetocurrenturi)
1110
- [`GetUriWithHash()` extension method](#geturiwithhash-extension-method)
1211
- [BasePath component](#basepath-component)
@@ -161,42 +160,6 @@ The `QuickGrid` component now supports row click events through the new `OnRowCl
161160

162161
The feature includes built-in CSS styling that applies a pointer cursor to clickable rows through the `row-clickable` CSS class, providing clear visual feedback to users.
163162

164-
## RenderFragment contravariance
165-
166-
The `TValue` type parameter in `RenderFragment<TValue>` is now marked as contravariant with the `in` modifier. This enables passing render fragments that accept base types where derived types are expected, eliminating the need for complex reflection-based adapters in generic component composition.
167-
168-
```csharp
169-
// Before: Invariant delegate blocked this
170-
public delegate RenderFragment RenderFragment<TValue>(TValue value);
171-
172-
// After: Contravariance enabled
173-
public delegate RenderFragment RenderFragment<in TValue>(TValue value);
174-
```
175-
176-
This change enables more flexible component composition:
177-
178-
```csharp
179-
// Non-generic fragment handling base type
180-
RenderFragment<IList> baseTemplate = (IList items) => builder =>
181-
{
182-
foreach (var item in items)
183-
{
184-
// Render item
185-
}
186-
};
187-
188-
// Can now be assigned where specific type is expected
189-
RenderFragment<List<Product>> specificTemplate = baseTemplate; // ✅ Works with contravariance
190-
191-
// DynamicComponent scenario now works directly
192-
var parameters = new Dictionary<string, object>
193-
{
194-
["ItemsTemplate"] = baseTemplate, // ✅ No adapter needed
195-
};
196-
```
197-
198-
Note that C# variance only works with reference types due to CLR limitations. Value types (structs, enums, primitives) do not support variance.
199-
200163
## Relative navigation with `RelativeToCurrentUri`
201164

202165
Blazor's `NavigationManager.NavigateTo()` and `NavLink` component now support relative URI navigation through the new `RelativeToCurrentUri` parameter. This enables navigation to URIs relative to the current page path rather than the application's base URI.

0 commit comments

Comments
 (0)