-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Ensure all template code files(C#, F#, VB) have consistent BOM #41376
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
base: main
Are you sure you want to change the base?
Conversation
81474b4
to
83753e6
Compare
I am strongly in favor of this, but I'm not a code owner in this repository. |
We haven't yet decided that we will even take this approach to BOM usage. There is further discussion to be had. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking request changes to prevent merge
I agree that it would be good to have some discussions and guidance regarding BOM usage. This PR only makes the code file BOM usage consistent. Today all template code files already have BOM(except the two files changed in this PR) |
83753e6
to
c358e09
Compare
Why? I'm not in favor of this. My position: #39187 |
I think that the main reason to include the UTF-8 BOM is to make sure Visual Studio opens the file as a UTF8 file(with BOM). Otherwise it will by default choose another encoding for the template file. This could lead to issues if you develop and save your file using Visual Studio on Windows and then run you program on Linux. If Visual Studio changes it default "guess" to UTF8 instead of current behavior, omitting the BOM would be fine. For more information see: |
The C# compiler behavior is to always try parsing as UTF-8 first, then go to other encodings. I don’t know the VS behavior. I’m generally against BOM. I think it’s generally less portable than plain UTF-8. A lot of Unix tools don’t understand it. |
c358e09
to
a62621e
Compare
Note that this PR only makes the SDK template files for C#, F#, and VB consistent regarding BOM usage. Currently, all C#, F#, and VB template files in the SDK include a BOM, except for two files. This PR fixes these two files and adds an editor config to ensure that future files also include a BOM, until a different decision is made. I believe we should at least maintain consistency regarding BOM usage until we receive guidance or a decision on whether to include a BOM or not? |
Is there a VS issue filed on this? That would help. I guess I'm not worried if we merge this PR or not since it doesn't change much. |
There have been many issues related to this reported over the years, for example: It seems that in Visual Studio 2022, version 17.3 Preview, there will be a new option to set the default encoding: Perhaps this opens up the possibility of changing all templates to UTF-8 without BOM in .NET 10? |
a62621e
to
b5e6efa
Compare
Ensured that all template code files in the repository are marked as UTF-8 BOM. Fixes dotnet#41433
b5e6efa
to
0073bbc
Compare
@baronfel Is there anything else that needs to be done for this PR? Have you had a chance to discuss it yet? Just a note that this PR ensures consistency in BOM usage across SDK template files for C#, F#, and VB. Currently, all template files include a BOM except for two, which this PR fixes. It also adds an editor config to maintain consistency going forward unless a different decision is made. |
Ensure that all template code files in the repository are marked as UTF-8 BOM.
Fixes #41433