Skip to content
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

Asp.net core .cs file encoding is not uft-8 encoded #37201

Closed
vsfeedback opened this issue Oct 1, 2021 · 9 comments
Closed

Asp.net core .cs file encoding is not uft-8 encoded #37201

vsfeedback opened this issue Oct 1, 2021 · 9 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. bug This issue describes a behavior which is not expected - a bug. Priority:2 Work that is important, but not critical for the release
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
When creating a new razor file, the cshtml file gets UTF-8 encoded but the .cs file is ANSI encoded.
This happens if you are using a swedish windows operations system with latest VS2019.

It is very easy to reproduce.

  1. Install Windows 10 Swedish version
  2. Install Visual Studio 2019
  3. Create a new Web Project (.net Core)
  4. Add a razor page
  5. Check the encoding for the newly created .cs file by doing "Save as" and select "Save with different encoding" in VS.

It might sound like a small issue but it's not.
When developing code to run on AKS, the file encoding is extreamly important.

Lets say you have a file with a comment containing. UTF-8 charaters. It will compile fine on you local machine, all tests will pass, but when you check in your code and compile it on a Linux machine, it will fail.

For every file you add you need to manually change it's encoding to UTF-8. Please fix this asap.
Please don't ask me for more information. This is 100% reproducable.


Original Comments

Feedback Bot on 5/16/2021, 08:12 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Jiahui Zhang (Beyondsoft Corporation) [MSFT] on 5/25/2021, 00:12 AM:

Thank you for your feedback! We tried to reproduce this issue with following steps:

  1. Create a C# ASP.NET Core Web App project.
  2. Open Pages > _ViewImports.cshtml and edit it.
  3. Go to File > Save _ViewImports.cshtml As…
  4. Click “Save with Encoding…”
    The Encoding shows “Western European (Windows)” instead of “Unicode(UTF-8 with signature)”.
    Actual.png

Is it the behavior of this issue? If yes, we will go through a further investigation. If not, could you help to correct us?
We are looking forward to your reply!

per.bornsjo on 5/25/2021, 00:27 AM:

Yes, that’s the problem!
Both the .cs and the .cshtml should be UTF-8.

Feedback Bot on 6/2/2021, 02:38 AM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.


Original Solutions

(no solutions)

@ghost ghost added the Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. label Oct 1, 2021
@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Oct 1, 2021
@mkArtakMSFT mkArtakMSFT modified the milestones: .NET 7 Planning, 6.0.0 Oct 6, 2021
@pranavkm
Copy link
Contributor

pranavkm commented Oct 6, 2021

I just re-read the issue, and it's specifically talking about .cs files in the project template that we haven't done any work on. While I agree this is a gap, this isn't a regression and I'm going to punt this to 7.0. Fixing it for ASP.NET Core's projects might not be sufficient here since this affects other non-ASP.NET Core templates and scaffolding.

@pranavkm pranavkm removed their assignment Oct 6, 2021
@pranavkm pranavkm modified the milestones: 6.0.0, .NET 7 Planning Oct 6, 2021
@TanayParikh
Copy link
Contributor

Docs & infra candidate? We'll need to update our pipelines / git configs to enforce UTF8 encoding for committed files.

@TanayParikh TanayParikh removed the bug This issue describes a behavior which is not expected - a bug. label Nov 3, 2021
@mkArtakMSFT mkArtakMSFT added the bug This issue describes a behavior which is not expected - a bug. label Nov 17, 2021
@mkArtakMSFT
Copy link
Member

The plan here is to follow up with @DamianEdwards and make sure that all files (including .cs files, which is the main problem here) are saved as UTF-8

@mkArtakMSFT mkArtakMSFT added Priority:2 Work that is important, but not critical for the release triaged labels Nov 17, 2021
@pranavkm pranavkm changed the title Asp.net core .cshtml's file encoding format is not uft-8 encoded Asp.net core .cs file encoding is not uft-8 encoded Nov 17, 2021
@DamianEdwards
Copy link
Member

What's my involvement here?

@mkArtakMSFT
Copy link
Member

We need to validate this to confirm this is still the case and if not, close this. Otherwise, this will indeed be a good infra candidate.

@ghost
Copy link

ghost commented Sep 14, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@ghost
Copy link

ghost commented Oct 26, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mkArtakMSFT
Copy link
Member

Hi. Thanks for contacting us.
We're closing this issue as there was not much community interest in this ask for quite a while now.
You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2022
@andreassandin
Copy link

Hi. I just found this after struggling for days with a docker container that just was impossible to have a Razor page show correct characters!
I use Visual Studio 2022, so the same problem exists there to.
This is a real problem as the original comment from vsfeedback writes, and if i would not have seen this page would have been a impossible to solve without manual re-saving every cshtml.cs file for every project that this bug will happen in.
You at Microsoft should really open this again and make a fix as soon as possible.
Best Regards Andreas

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. bug This issue describes a behavior which is not expected - a bug. Priority:2 Work that is important, but not critical for the release
Projects
None yet
Development

No branches or pull requests

7 participants
@pranavkm @DamianEdwards @TanayParikh @vsfeedback @mkArtakMSFT @andreassandin and others