Blazorise icon indicating copy to clipboard operation
Blazorise copied to clipboard

Blazor Pages that use Layout Throw "Identifier Expected" Error in VS2022

Open paulsterling opened this issue 2 years ago • 3 comments

NOTE: I tried to submit this via the support site (https://support.blazorise.com/issues/new) but was unable to successfully submit. We are a commercial license subscriber.

Starting a few days ago all Blazor pages that use the <Layout> Blazorise component have started displaying the compilation error

CS1001: Identifier Expected

Along with CS1003: Syntax error, ',' expected . There are no project or tool updates - though I did update to Blazorise 1.0.6 and VS2022 17.3.2 just to make sure. The same issue persists. The issue does not appear on components that do not use <Layout>. FWIW I've also tried using <Blazorise.Layout> but the issue persists.

This solution has been in active development for more than a year and this is the first we've run into this odd issue. The issue blocks compilation so we are unable to compile/release updates currently.

I certainly suspect this may be due to a setting in VS2022 but have failed at finding any related issues with solutions. Please let me know if you have a solution or ideas as to what the underlying cause may be.

Thank you!

The complete page from the above image is

@page "/sample/detail-copy/{jobCd}"

<Layout Loading="false">
    <LayoutContent>
        <Row Gutter="(16, 8)">
            <Column ColumnSize="ColumnSize.Is12">
                <Card>
                    <Text>This is some text</Text>
                </Card>
            </Column>
        </Row>
    </LayoutContent>
</Blazorise.Layout>

@code {
    [Parameter]
    public string jobCd { get; set; } = string.Empty;
    }

paulsterling avatar Aug 29 '22 23:08 paulsterling

It's a Visual Studio and Razor problem from what I know. The same thing happened to me a few days ago after I installed the latest version of .NET 7 preview to be able to add support to the next Blazorise v1.1.

It seems that value tuples are broken now. I have reported the problem at https://github.com/dotnet/razor-compiler/issues/332

Hopefully it will be fixed in the next VS release.

stsrki avatar Aug 30 '22 08:08 stsrki

Thanks for the response @stsrki . Just a note that I am not targeting .NET 7 and still see this with .NET 6 (6.0.400) so perhaps there was an update made in both versions that affects this? <TargetFramework>net6.0</TargetFramework>

dotnet --list-sdks
3.1.422 [C:\Program Files\dotnet\sdk]
6.0.202 [C:\Program Files\dotnet\sdk]
6.0.203 [C:\Program Files\dotnet\sdk]
6.0.303 [C:\Program Files\dotnet\sdk]
6.0.400 [C:\Program Files\dotnet\sdk]

paulsterling avatar Aug 30 '22 15:08 paulsterling

I have contacted some people from MS, and the problem is already forwarded to the right razor team to look at. We'll see how it goes 🤞

stsrki avatar Aug 30 '22 18:08 stsrki

Is there something new about this issue?

PatHelb avatar Oct 07 '22 09:10 PatHelb

The issue will be fixed with the next release of Visual Studio, or .NET SDK. See https://github.com/dotnet/razor-compiler/issues/332

stsrki avatar Oct 07 '22 09:10 stsrki

Do you know if this also affects .net 6? and when the release will be?

PatHelb avatar Oct 07 '22 09:10 PatHelb

The error is only present in the latest Visual Studio. It doesn't matter if it's .NET 6 or 7. The same issue is for all framework versions.

stsrki avatar Oct 07 '22 09:10 stsrki

Ok, thank you for the information.

PatHelb avatar Oct 07 '22 09:10 PatHelb

It looks like this fix has been merged into the main branch of the dotnet/razor repo but it does not seem to have made it's way to VS2022 17.4.2 yet and also does not seem to be in the 7.0.100 SDK.

https://github.com/dotnet/razor/blob/main/src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Components/TypeNameHelper.cs#L52

But it is in VS2022 17.5.0 Preview 1.0. So, if this is blocking for anyone else, like it is for me, using the latest preview of VS2022 is the current solution.

paulsterling avatar Dec 06 '22 21:12 paulsterling

@paulsterling should we close the ticket?

stsrki avatar Dec 07 '22 06:12 stsrki

@stsrki

Yes, think so. The fix (or mitigation as it's described in the PR) is coming in VS2022 17.5.0.

Thanks!

paulsterling avatar Dec 07 '22 16:12 paulsterling