The automatic field generation for @ref
does work inside visual studio intellisense but not when building the project.
Steps to reproduce the behavior:
3.0.100-preview8-013656
and VS 16.3.0 Preview 2.0
@ref="ele"
to an element inside of the Counter
component@code
. E.g. ele.ToString();
Pages\Counter.razor(14,9,14,12): error CS0103: Der Name "ele" ist im aktuellen Kontext nicht vorhanden.
Code should compile.
Workaround is to @ref:suppressField="ele"
and add the field manually.
.NET Core SDK (gem盲脽 "global.json"):
Version: 3.0.100-preview8-013656
Commit: 8bf06ffc8d
Laufzeitumgebung:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\
Host (useful for support):
Version: 3.0.0-preview8-28405-07
Commit: d01b2fb7bc
.NET Core SDKs installed:
2.1.701 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
@NTaylorMullen can you please look into this? Please try to repro this, if you can and we'll see what's going on then.
Yes I can confirm the issue. A workaround is needed as this will break a lot of projects.
Same here. Serious bug.
As a workaround you can add the @ref:suppressField
to revert to the old behaviour
Yup. The feature doesn't work.
the workaround not work for (but i'm not really how to use it)
I precise i have a separate cs file for the ViewModel of my razor components
<input type="password" class="form-control" @bind-value="this.Model.Password" @bind-value:event="oninput" @onkeydown="@OnKeyDownPassword" @ref:suppressField="@inputPassword" />
protected ElementReference inputPassword { get; set; }
It build, but when i launch it i have this error in the chrome console
Uncaught (in promise) DOMException: Failed to execute 'setAttribute' on 'Element': '@ref:suppressfield' is not a valid attribute name.
anybody success tu use the workaround ?
thanks !
@julienGrd
Use it like this
<Show @ref="_showRef" @ref:suppressField Number="Number" />
@julienGrd
Use it like this<Show @ref="_showRef" @ref:suppressField Number="Number" />
thanks it works ! i was pretty sure i was not using the good syntax :-)
Ya I can reproduce this, working on a fix. @shirhatti @danroth27 we should update the blog post (and anywhere else relevant) to mention that this feature does not work as intended.
Does anyone have a repro that causes a compiler crash?
Any chance for a patch/hotfix/new build ?
Sorry folks to do this, but here's the latest: https://github.com/aspnet/Announcements/issues/381
Lol, so no one tested this new feature before releasing it?
Most helpful comment
Lol, so no one tested this new feature before releasing it?