VSFormatOnSave
VSFormatOnSave copied to clipboard
[VS2022] Editor freezes when saving cshtml files (.net framework asp.net)
Saving some .cshtml files causes the program to freeze, sometimes it unfreezes after, sometimes not. Version 3.1
VS info:
Microsoft Visual Studio Enterprise 2022 Version 17.4.2 VisualStudio.17.Release/17.4.2+33122.133 Microsoft .NET Framework Version 4.8.04084
Installed Version: Enterprise
ASP.NET and Web Tools 17.4.326.54890 ASP.NET and Web Tools
Azure App Service Tools v3.0.0 17.4.326.54890 Azure App Service Tools v3.0.0
Azure Functions and Web Jobs Tools 17.4.326.54890 Azure Functions and Web Jobs Tools
Bundler & Minifier 2.9.3 Adds support for bundling and minifying JavaScript, CSS and HTML files in any project.
C# Tools 4.4.0-6.22565.8+53091686b435746d62a5df56abfab0e71203d83a C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Extensibility Message Bus 1.4.1 (main@2ee106a) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
Microsoft Azure Tools for Visual Studio 2.9 Support for Azure Cloud Services projects
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.4.19 (8c0a575) Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 6.4.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Razor (ASP.NET Core) 17.0.0.2246202+61cc048d36a3fc9246d2f04625988b19a18ab8f0 Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.0.62207.28050 Microsoft SQL Server Data Tools
TypeScript Tools 17.0.10921.2001 TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.4.0-6.22565.8+53091686b435746d62a5df56abfab0e71203d83a 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.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b 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.4.0.301 (d17-4@96af3ae) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 17.4.0.138 (remotes/origin/d17-4@d36bba3cc9) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 17.4.2 (c457c97) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 13.1.0.1 (d17-4/13ba222) Xamarin.Android Reference Assemblies and MSBuild support. Mono: a96bde9 Java.Interop: xamarin/java.interop/d17-4@fcc33ce2 SQLite: xamarin/sqlite/3.39.3@23e1ae7 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@0be567a
Xamarin.iOS and Xamarin.Mac SDK 16.0.0.92 (3dd3dc52c) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
I tried some basic typing in a simple .cshtml file, but cannot reproduce the freeze. Maybe my testing environment is too simple. A simplified demo project may help.
I think I've managed to reproduce it on the test project. The freeze happens when you save the file first time. To reproduce it afterwards you need to delete hidden .vs folder in the solution directory.
Test website project: https://drive.google.com/file/d/1VOmbexc2m6kZRyL8-smpb8E66jIe9dEc/
Video: https://youtu.be/iJfK7Mt2tzI
I downloaded your project and tried it several times, yet can't replicate the issue. Utilizing the most recent Visual Studio 2022 Preview, I observed that delays in formatting .cshtml files no longer persist. It appears that Microsoft has at last rectified this complication. Please remove ".razor .cshtml" from Options > Format on save > Extensions cause delayed FormatDocument and see whether the freeze dissipates.
Please remove ".razor .cshtml" from Options > Format on save > Extensions cause delayed FormatDocument and see whether the freeze dissipates.
This has not effect, but if I put .cshtml in several denied sections like on the attached pic freezing stops (and obviously formatting).
Edit: putting it only in format deny is enough.
That's a bug: when you remove ".razor .cshtml" filter, the delayed filter is still active. It will be fixed in next release.
Additionally, I was wrong about the delayed formatting. Microsoft hasn't changed anything. It's just because my CPU is faster. I still need to find out what the problem is.
I've used WH_KEYBOARD to implement capturing input characters, and I'm not sure if this is causing compatibility issues. One possibility is that there might be a conflict with some third-party software.