-
Notifications
You must be signed in to change notification settings - Fork 228
Closed
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I'm trying dotnet/aspnetcore#31800
This will always get a build error when using @typeparam T where T:IProductModel
CS0246 The type or namespace name 'IProductModel' could not be found (are you missing a using directive or an assembly reference?)
There are no intellisense errors
I tried:
- using the full namespace
- adding the namespace with
@using - adding the namespace to _Imports.razor
Expected Behavior
No build error
Steps To Reproduce
I have this interface (in the same project as my Blazor Server)
public interface IProductModel
{
int Code { get; }
string Description { get; }
}I have this component (stripped version)
@typeparam T where T:IProductModel
<select class="form-select">
@foreach (var item in Items)
{
<option value="@item.Code" selected="@(item.Code == Selected.Code)">@item.Description</option>
}
</select>
@code {
[Parameter]
public T Selected { get; set; } = default!;
[Parameter]
public IEnumerable<T> Items { get; set; } = default!;
}Build the code.
See #7148
Exceptions (if any)
Only build errors
.NET Version
6.0.302
Anything else?
- Visual Studio 2022 v17.2.6
- Blazor Server .NET 6