-
Notifications
You must be signed in to change notification settings - Fork 183
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
Compile issue in razor files for model expressions "!@" #10371
Comments
Is the <label asp-for="Name" taghelper-hidden="!Model.HasName"></label> |
It does. Our TagHelper expects a bool value. Previously, not sure how many versions ago, it was mandatory to add the [HtmlTargetElement(Attributes = HiddenAttributeName)]
public class HiddenTagHelper : TagHelper
{
private const string HiddenAttributeName = "taghelper-hidden";
[HtmlAttributeName(HiddenAttributeName)]
public bool Hidden { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (Hidden)
{
output.SuppressOutput();
}
else
{
base.Process(context, output);
}
}
} |
It goes wrong not only with the !@ expression, but also with the <select asp-for="CountryId" asp-items="await @Model.CountriesAsync()"></select> <a href="/" taghelper-hidden="@Model.Month == @Model.CurrentMonth">Current</a> In the sample above with the equals comparison the compiler comlains about the second <label asp-for="Name" taghelper-hidden="@Model.HasName"></label> The above example works fine. In our code, this leads to hundreds of compile issues after installing version 8.0.300. Is there going to be a fix for this? |
With the latest preview 9.0.0-preview.5.24256.2, everything works fine. No compile issues. |
I don't know if we are planning to update 8.0.300 with my bugfix, but we can certainly see if it meets the servicing bar. @jaredpar? |
I would like to please ask that this gets fixed on 8.0.30X. This is currently breaking our builds after we upgraded to cover the CVEs that the lastest release fixes. |
I also started getting a similar issue passing data to partial views if the partial was contained inside a razor if or foreach. This spontaneously started two days ago too, and i had to change 700 files to get compilation to work.
These built fine a few days ago then 2 days ago suddenly every page that had this was throwing the exact same error message as OP. I had to remove all the |
Not sure if it helps, but I noticed a similar issues with builds today. Previously had code like the following (notice the space after the " and before the @): I cleaned up all the '@' tags in the project to remove any unnecessary spaces in the quotes and all builds seem to be working fine now. Like @mfalconi-perle above, these builds were working fine for us last week without issue with the spaces in the quotes. Apologies if the above does not provide any help, just figured I'd throw in what I experienced today. |
After installing SDK version 8.0.300, we have compile issues in razor (cshtml) files. This was not the case in previous SDK versions. If we fix the SDK version to an earlier version, there are no compile issues either.
Errors:
It involves the following code:
The following code change fixes it:
Probably related to #10186 and fixed by PRs of @333fred?
The text was updated successfully, but these errors were encountered: