microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
221 stars 10 forks source link

[BUG] Blazor Hot Reload Breakdown and Component Glitches AND Code Formating in VS Code #1487

Open JaquesBotha opened 1 day ago

JaquesBotha commented 1 day ago

Describe the Issue

I'm encountering several recurring issues while working with the C# Dev Kit in Visual Studio Code (VS Code) on a Blazor Server project. These issues occur across both the .NET 8 stable SDK and the .NET 9 Preview SDK. Below is a detailed explanation of the problems I'm facing:

Issue 1: Hot Reload Stops Working After 5-10 Minutes or Few Attempts

- Behavior: When running my Blazor project using dotnet watch run, Hot Reload works perfectly for the first few minutes or a few attempts, but eventually stops functioning. I’ve noticed this happens inconsistently, after 5-10 minutes of use or after several Hot Reload actions.

- Workaround: The only way to resolve the issue is to stop the console with Ctrl + C, run a dotnet build, followed by another dotnet watch run. This process becomes repetitive and interrupts the development flow.

- Reproducibility: This happens consistently on both the .NET 8 stable and .NET 9 Preview SDK.

Issue 2: Blazor Components Failing to Register in IDE

- Behavior: Occasionally, when working with Blazor components, the IDE (VS Code) fails to recognize or register some components correctly. This is an IDE issue, as the code itself still functions perfectly when the project is run in the browser. The issue is that components in the code editor sometimes aren't recognized (e.g., no IntelliSense, errors displayed), and this seems to happen randomly. Restarting VS Code sometimes temporarily resolves the problem.

- Reproducibility: This occurs sporadically, and I haven’t been able to consistently reproduce the behavior. It affects productivity, as the IDE fails to provide proper code assistance.

Issue 3: Inconsistent Code Formatting for C#, Razor, and Blazor

- Behavior: The code formatting feature in VS Code for C#, Razor, and Blazor files only works intermittently. Sometimes, the formatting works perfectly after saving a file, while other times it simply doesn't apply the standard formatting. There’s no clear trigger or pattern for when it stops working.

- Reproducibility: This issue happens randomly. I’ve tried different projects and switching between SDKs (.NET 8 stable and .NET 9 Preview), but the formatting behavior remains inconsistent.

Additional Information:

These issues significantly disrupt the development process, especially with the reliance on Hot Reload for iterative development and the need for consistent code formatting to maintain clean codebases.

Let me know if you need any further details or logs to help resolve this.

Steps to Reproduce:

For Issue 1 (Hot Reload Stops):

  1. Create or open any Blazor Server project.
  2. Run the project using dotnet watch run.
  3. Make multiple changes to any .razor file and observe Hot Reload behavior.
  4. After 5-10 minutes or after several changes, Hot Reload stops functioning.
  5. Attempt a manual build using dotnet build, then dotnet watch run to restore functionality.

For Issue 2 (Blazor Components Registration Failure in IDE):

  1. Create or open a Blazor project in VS Code.
  2. Add new components or make changes to existing ones.
  3. Observe that the IDE may not recognize components (e.g., missing IntelliSense, highlighting, and errors) even though the project still runs in the browser without issues.
  4. Restart VS Code to temporarily fix the issue.

For Issue 3 (Inconsistent Code Formatting):

  1. Open a Blazor project in VS Code.
  2. Make changes to C#, Razor, or Blazor files and attempt to format the code using the editor's formatting feature.
  3. Observe that sometimes formatting works and sometimes it does not, with no clear cause or pattern.

Expected Behavior:

  1. Hot Reload should continue to work consistently without requiring manual intervention (Ctrl + C and re-running dotnet build).
  2. Blazor Components in the IDE should always be properly registered and recognized within the code editor for accurate IntelliSense and code support.
  3. Code Formatting should consistently work across C#, Razor, and Blazor files.

Environment Information:

AbhitejJohn commented 1 day ago

Thanks for the detailed report @JaquesBotha . Tagging @phil-allen-msft to help.