-
Notifications
You must be signed in to change notification settings - Fork 10.3k
typeparam bind error #9632
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
Comments
Type of error at build time
|
This is definitely an issue, but I'm not sure that I'm totally convinced this ever worked unless We used to have a generic overload of the binding functionality that didn't use the enum type constraint. It would throw for non-enum types. https://github.com/aspnet/AspNetCore/blob/v3.0.0-preview4-19216-03/src/Components/Components/src/BindMethods.cs#L273 The new methods have a similar method but with the enum constraint. https://github.com/aspnet/AspNetCore/blob/master/src/Components/Components/src/EventCallbackFactoryBinderExtensions.cs#L595 I think we need to address this in general though since we have enums in our programming model. This means we'll need to add a general-purpose bind/converter. |
Example of the generated code: #pragma checksum "C:\Users\rynowak\source\repos\Blazor1\Blazor1.razor" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "49595bbe8c7c44c17ab89283a7e51479d3e64ea6"
// <auto-generated/>
#pragma warning disable 1591
namespace Blazor1
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Layouts;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.JSInterop;
using Blazor1.Shared;
public class Blazor1<T> : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
{
builder.AddMarkupContent(0, "<h3>Blazor1</h3>\r\n\r\n");
builder.OpenElement(1, "input");
builder.AddAttribute(2, "type", "text");
builder.AddAttribute(3, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue(value));
// There is no generic version of CreateBinder
builder.AddAttribute(4, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => value = __value, value));
builder.CloseElement();
}
#pragma warning restore 1998
#line 7 "C:\Users\rynowak\source\repos\Blazor1\Blazor1.razor"
T value;
#line default
#line hidden
}
}
#pragma warning restore 1591 |
Fixes: #8493 Fixes: #9632 Fixes: #9339 Fixes: #8385 Fixes: 10077 This fix adds support for type converters as well as a few other minor things we were missing from binding. The key thing about supporting conversions is that we new can support arbitrary types with `@bind`. This means you can use it with generics, which is something many users have tried. Along with type converters we get Guid and TimeSpan from the BCL. The BCL also includes converters for types we're less interested in like `short`.
Fixes: #8493 Fixes: #9632 Fixes: #9339 Fixes: #8385 Fixes: 10077 This fix adds support for type converters as well as a few other minor things we were missing from binding. The key thing about supporting conversions is that we new can support arbitrary types with `@bind`. This means you can use it with generics, which is something many users have tried. Along with type converters we get Guid and TimeSpan from the BCL. The BCL also includes converters for types we're less interested in like `short`.
* Add support for TypeConverter Fixes: #8493 Fixes: #9632 Fixes: #9339 Fixes: #8385 Fixes: 10077 This fix adds support for type converters as well as a few other minor things we were missing from binding. The key thing about supporting conversions is that we new can support arbitrary types with `@bind`. This means you can use it with generics, which is something many users have tried. Along with type converters we get Guid and TimeSpan from the BCL. The BCL also includes converters for types we're less interested in like `short`. * Use correct NumberStyles * Fix culture * Core check
This has been added in preview 7 - #10730 |
Hi, in Blazor 0.10 such code stopped working
This is a build error of version 0.10 or is the ability to typeparam bind removed ?, is there an alternative solution to the problem?
The text was updated successfully, but these errors were encountered: