dotnet / dotnet/format

.NET 6 SDK RC1: `dotnet format --verify-no-changes` fails when a type from a `*.razor` file is referenced

Open
#1,357 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
1.9k
Forks
173
Avg merge
10d 13h
Merged PRs (30d)
1

Description

# Steps To Reproduce

1. Create a new Razor Class Library using the .NET 6 SDK RC1. My `global.json` contains: `{"sdk": {"version": "6.0.100-rc.1.21458.32"}}` and I ran `dotnet new razorclasslib`.
2. Run the formatter once (just to get a clean output): `dotnet format`.
3. Run `dotnet format --verify-no-changes`.
4. Edit any `*.cs` file and add a reference to a component class that is only declared in `*.razor` files. I added the following line to `ExampleJsInterop.cs`: `private Component1? Dummy { get; } = null;`.
5. Run `dotnet format --verify-no-changes`.

# Expected Output
In both step 3 and step 5: ` Formatting code files in workspace ''.
Format complete in

# Actual Output
In step 5: `Formatting code files in workspace '\ExampleJsInterop.cs(14,13): error CS0246: The type or namespace name 'Component1' could not be found (are you missing a using directive or an assembly reference?) []
Formatted code file '\ExampleJsInterop.cs'.
Format complete in

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.