Description
Hi,
I'm trying to refactor my existing components to use the newly introduced CascadingTypeParameter
attribute but I'm running into compiler errors.
BlzTableGrid.razor (this is the main grid component)
@attribute [CascadingTypeParameter(nameof(TItem))]
@typeparam TItem
<CascadingValue Value="this" IsFixed="true">
@ColumnsTemplate
</CascadingValue>
...
BlzTableGrid.razor.cs
public partial class BlzTableGrid<TItem> where TItem : class
{
[Parameter]
public RenderFragment ColumnsTemplate { get; set; }
...
BlzGridBaseColumn.cs
public abstract partial class BlzGridBaseColumn<TItem> : ComponentBase where TItem : class
{
[CascadingParameter]
internal BlzTableGrid<TItem> Grid { get; set; }
...
BlzGridColumn.cs
public class BlzGridColumn<TItem> : BlzGridBaseColumn<TItem>, IGridFieldColumn<TItem> where TItem : class
{
[Parameter]
public string FieldName { get; set; }
...
TableGrid.razor (page consuming the grid component)
<BlzTableGrid
TItem="WeatherForecastLookup"
Items="WeatherForecasts"
<ColumnsTemplate>
<BlzGridEditColumn />
<BlzGridDeleteColumn />
<BlzGridViewColumn />
<BlzGridColumn Title="Date" FieldName="@nameof(WeatherForecastLookup.Date)" Format="d" Width="10rem" />
...
I'm getting the following compiler error for what seems to be each column in TableGrid.razor
page:
>C:\Projects\Blazor-Components\DemoApp\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Grid_TableGrid_razor.g.cs(563,29,563,34): error CS0449: The 'class', 'struct', 'unmanaged', 'notnull', and 'default' constraints cannot be combined or duplicated, and must be specified first in the constraints list.
Thank you for your help.