-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Blazor insignificant whitespace trimming is done by the 5.0 SDK even when not targeting 5.0 #28085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It is not the 5.0 SDK alone. I installed 5.0 SDK 2 days ago, worked yesterday all day without any visibile changes and at the end of yesterday I upgraded VS from 16.7 to 16.8 - and now this morning "everything" looked different (some parts of my app got really ugly due to missing spaces). |
and |
@mkArtakMSFT Yes, it does look like this is a bug. In Razor < 5.0, there was a more limited form of whitespace removal (just removing the leading/trailing whitespace at the top level of the component). In 5.0, we extended this to remove leading/trailing whitespace on all elements within the component too. We added an option to control whitespace preservation, with the options being "use new 5.0 behavior" or "don't strip any whitespace at all". However, when making this change, we didn't create any mechanism to continue using the 3.x limited-whitespace-stripping behavior - the code that implemented that is just gone. To fix this, I think we'll reintroduce a forked copy of the |
If you create a That's just a short-term workaround. For 5.0.2 we should be able to include a proper fix for this so that 3.1-targeting apps get the 3.1 behavior even when using the 5.x SDK. |
@SteveSandersonMS Yup, pinning the SDK works fine as a workaround (that’s how I verified this behavior in the first place). The fix for 5.0.2 looks really promising! I expected this to be a lot more complicated to get both versions working. Thanks! |
global.json, yeah? referencing any of 3.1.x (.400, .402, .403) results in
dotnet --info
|
@springy76 There's something wrong with your installation of the .NET Core SDK. You may need to reinstall whatever specific SDK version you want to use. This isn't a Blazor-specific issue but rather is about the SDK itself, so if you have further trouble with that I'd recommend filing an issue at https://github.com/dotnet/sdk/issues. For reference, please see dotnet/sdk#6180. |
Uh oh!
There was an error while loading. Please reload this page.
With Blazor in 5.0, insignificant whitespace trimming was introduced for Razor components as per #23568. However, it appears that this is a tooling feature that applies regardless of what target framework the project has.
In my case, upgrading to the .NET 5 SDK caused an existing ASP.NET Core 3.1 application (targeting netcoreapp3.1) from experiencing a broken UI due to missing whitespace between elements which is now determined to be insignificant.
The diff in my case looks something like this which causes two button elements being right next to each other instead of being separated by (collapsed) whitespace:
I know the ship has probably already sailed but maybe there’s a way to tell the SDK to keep the old tooling when targeting 3.1. Otherwise, aspnet/Announcements#426 should probably updated that this will already affect existing applications even when upgrading just the SDK.
The text was updated successfully, but these errors were encountered: