Building in VS from aspnetcore repo, .razor files failing with CS0649 (Field is never assigned to) and RZ9991 (Attribute names could not be inferred)
See original GitHub issueThis seems to be a new issue since yesterday, as far as I can tell. Note that it works fine when building from the command line.
Repro: Open ComponentsNoDeps.slnf
in Visual Studio and try to build BasicTestApp
2>------ Build started: Project: BasicTestApp, Configuration: Debug Any CPU ------
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\FormsTest\InputFileComponent.razor(8,170,8,182): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\FormsTest\InputFileComponent.razor(13,283,13,299): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\VirtualizationComponent.razor(3,87,3,95): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\GlobalizationBindCases.razor(15,640,15,660): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\GlobalizationBindCases.razor(27,1126,27,1153): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\GlobalizationBindCases.razor(39,1612,39,1634): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\GlobalizationBindCases.razor(52,2217,52,2244): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(22,1131,22,1161): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(24,1366,24,1396): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(37,1894,37,1917): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(67,3213,67,3230): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(91,4297,91,4316): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(136,6411,136,6439): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(166,8113,166,8139): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(178,8819,178,8852): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(283,14378,283,14419): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(297,15089,297,15122): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(311,15740,311,15772): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\BindCasesComponent.razor(325,16455,325,16491): error RZ9991: The attribute names could not be inferred from bind attribute 'bind-value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\SignalRClientComponent.razor(31,31,31,44): error CS0649: Field 'SignalRClientComponent.transportType' is never assigned to, and will always have its default value
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\MultipleChildContent.razor(24,10,24,20): error CS0649: Field 'MultipleChildContent.ShowFooter' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\EventCustomArgsComponent.razor(80,10,80,38): error CS0649: Field 'EventCustomArgsComponent.customKeyDownStopPropagation' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\EventBubblingComponent.razor(81,10,81,31): error CS0649: Field 'EventBubblingComponent.targetStopPropagation' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\EventBubblingComponent.razor(83,10,83,26): error CS0649: Field 'EventBubblingComponent.preventOnKeyDown' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\HttpClientTest\CookieCounterComponent.razor(19,12,19,29): error CS0649: Field 'CookieCounterComponent.testServerBaseUrl' is never assigned to, and will always have its default value null
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\EventBubblingComponent.razor(80,10,80,37): error CS0649: Field 'EventBubblingComponent.intermediateStopPropagation' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\EventBubblingComponent.razor(82,10,82,32): error CS0649: Field 'EventBubblingComponent.ancestorPreventDefault' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\CascadingValueTest\CascadingValueSupplier.razor(26,10,26,27): error CS0649: Field 'CascadingValueSupplier.currentFlagValue2' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\RouterTest\PreventDefaultCases.razor(36,10,36,30): error CS0649: Field 'PreventDefaultCases.targetPreventDefault' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\CascadingValueTest\CascadingValueSupplier.razor(25,10,25,27): error CS0649: Field 'CascadingValueSupplier.currentFlagValue1' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\RouterTest\PreventDefaultCases.razor(37,10,37,34): error CS0649: Field 'PreventDefaultCases.descendantPreventDefault' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\DynamicComponentRendering.razor(31,20,31,35): error CS0649: Field 'DynamicComponentRendering.currentCaseName' is never assigned to, and will always have its default value null
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\SignalRClientComponent.razor(30,20,30,26): error CS0649: Field 'SignalRClientComponent.hubUrl' is never assigned to, and will always have its default value null
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\EventCustomArgsComponent.razor(79,10,79,37): error CS0649: Field 'EventCustomArgsComponent.customKeyDownPreventDefault' is never assigned to, and will always have its default value false
2>C:\dir\aspnetcore\src\Components\test\testassets\BasicTestApp\RouterTest\PreventDefaultCases.razor(35,10,35,32): error CS0649: Field 'PreventDefaultCases.ancestorPreventDefault' is never assigned to, and will always have its default value false
2>Done building project "BasicTestApp.csproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 6 up-to-date, 0 skipped ==========
This happens in other sample projects too if I add a [Parameter]
property.
I’m unsure why this would only affect building inside VS and not the command line. Might it be something to do with source generator changes? I tried the following VS versions:
- 16.10.0 Preview 1.0
- 16.10.0 Preview 2.0 [31117.304.main]
… with the same results on both.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:15 (15 by maintainers)
Top Results From Across the Web
c# - "The attribute names could not be inferred from bind ...
It turns out there are at least two causes of this: 1. The component name is now case-sensitive. The answer turns out to...
Read more >Error RZ9991: The attribute names could not be inferred ...
The error occurs during the build step of the Azure Pipeline execution. The error message specifically references the 'bind-Value' attribute.
Read more >Field is never assigned to, and will always have its default ...
This warning is notifying you of a variable which you never assigned a value to and it's not possible to assign a value...
Read more >Untitled
Building in VS from aspnetcore repo, .razor files failing with CS0649 (Field is never assigned to) and RZ9991 (Attribute names could not be...
Read more >Can't disable warning CS0649
After building my solution I get hundreds of CS0649 warnings - "Field X is never assigned to, and will always have its default...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Update: I’ve added a way to support override the
_UseRazorSourceGenerator
flag and falling back to the old model. When we pick up the next version of the SDK, I’ll disable the RSG for this project until we replat on the new source generators API.Thanks to @HaoK and @javiercn for the help rubber ducking this.
The issue seems to be related to the caching implementation that we use to cache tag helper descriptors in the Razor source generator. This implementation is temporary and will be usurped by the work that we do in https://github.com/dotnet/aspnetcore/issues/31244 to migrate to the new incremental source generator API.
Another hunch we had is that the issue might not repro on CI because of the
--ci
flag although I invalidated this locally. It appears that this issue doesn’t repro when you run the top-level build script which is why we don’t see it in CI.Sooooooo, for now, I say we wait to see how things shake out when we migrate to the incremental source generator API.