dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
494 stars 191 forks source link

Error RZ1003 issue #9974

Open CePur opened 7 months ago

CePur commented 7 months ago

Getting error via razor logger output while trying to format .cshtml file in VS.

Error RZ1003: A space or line break was encountered after the "@" character

The error occurs at after ".actiontype-"

@section styles
{
    <style>

        .actiontype-@((int)myActions.xxx)-bg { background: #deffe178; }

    </style>
}

VS info:

Microsoft Visual Studio Community 2022
Version 17.9.0
VisualStudio.17.Release/17.9.0+34607.119
Microsoft .NET Framework
Version 4.8.09037

Installed Version: Community

Visual C++ 2022   00482-90000-00000-AA219
Microsoft Visual C++ 2022

ASP.NET and Web Tools   17.9.195.45391
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.9.195.45391
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   17.9.195.45391
Azure Functions and Web Jobs Tools

C# Tools   4.9.0-3.24081.11+989117396f26e5453ff157df610d22ce45b6b0a9
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Clear Solution IntelliSense Cache   1.0
Clears the solution IntelliSense cache to fix issues with broken IntelliSense at design time, such as false or missing compile errors, etc.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Conveyor by Keyoti   1.0
Allows you to access your web applications from other machines, even if hosted on the development web server.

Extensibility Message Bus   1.4.39 (main@e8108eb)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

GitHub Copilot   1.156.0.0 (v1.156.0.0@82fafb995)
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.

GitHub Copilot Agent   1.156.0

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio   17.9.0 (b3bca6f)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.9.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core)   17.9.2.2408002+5aec2f1744a2273d3e7157cc4cc1986f87f524d4
Provides languages services for ASP.NET Core Razor.

SonarLint for Visual Studio   7.6.0.83110
SonarLint is an extension to your favorite IDE that provides on-the-fly feedback to developers on new bugs and quality issues injected into their code.

SQL Server Data Tools   17.9.51.1
Microsoft SQL Server Data Tools

TypeScript Tools   17.0.30103.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.9.0-3.24081.11+989117396f26e5453ff157df610d22ce45b6b0a9
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   17.9.0-beta.23614.3+a521e1cd420beb56c15faf6836184fadd2b7937a
Microsoft Visual F# Tools

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSPackage Extension   1.0
VSPackage Visual Studio Extension Detailed Info

Xamarin   17.9.0.138 (d17-9@60c2b9b)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.9.3.0 (remotes/origin/d17-9@f174974f91)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK   13.2.2.0 (d17-5/45b0e14)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: d9a6e87
    Java.Interop: xamarin/java.interop/d17-5@149d70fe
    SQLite: xamarin/sqlite/3.40.1@68c69d8
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d
phil-allen-msft commented 7 months ago

@CePur , we're sorry you are running into this. In order to preserve the correctness of your markup, when Razor tries to format the document, it compares the number of diagnostics (think squiggles) 'before' and 'after', and if they are different it chooses to not format. When you are running into the RZ1003 error as above, does the formatting complete successfully?

CePur commented 7 months ago

@phil-allen-msft nope, it doesn't format. It formats only if i comment out the shared code piece.