Git Product home page Git Product logo

Comments (7)

kodybrown avatar kodybrown commented on June 5, 2024

I can add a .gitattributes file that will take care of that and any other potential issues?

from essentialcsharp.

MarkMichaelis avatar MarkMichaelis commented on June 5, 2024

I was trying to avoid that because the files should just be text. I was hoping it was caused by some errant encoding and we just had to re-write the file. Perhaps both? Your input is welcome.

from essentialcsharp.

Keboo avatar Keboo commented on June 5, 2024

I think both probably needs to be done.

Listing file that are "binary" (source) shows pretty much all of the csproj files.

Looking at the contents most (not all) csproj files have an xml declaration with an encoding of utf-16 specified. Digging a bit further, most (all?) of the csproj files appear to have a utf-16 LE BOM (0xFF 0xFE).
This is likely the cause of your git diff troubles (2 byte encoding while git expects 1).

Though you can configure your local diff to convert the files I think it would be better to simply fix these files.

VS2017 for the new core csproj format (is there a fancy name for it?) generate the csproj without the XML declaration and with a UTF-8 BOM. Framework based csproj still generate the xml declaration with an encoding of utf-8 and a UTF-8 BOM.

It is probably best to:

  1. Fix all of the csproj files to be UTF-8. This will likely solve your diff issues.
  2. Also setup the .gitattributes to mark all .cs and .csproj files as text. Though not current necessary it is possible that at some point you will need to include fancy characters in a file. In these cases git might falsely detect file as binary rather than text. Most (all?) git tools respect the fact that the .gitattributes files has final say over whether a file is considered text or binary.

from essentialcsharp.

nlundby avatar nlundby commented on June 5, 2024

I submitted a pull request with all of the csproj files changed to UTF-8. This did indeed solve the diff issues.

I didn't touch the .gitattributes file. If it becomes necessary I figure it would be a quick fix.

from essentialcsharp.

MarkMichaelis avatar MarkMichaelis commented on June 5, 2024

Request pulled... thanks, Neal!!!

(Curious, how did you change all the files?)

from essentialcsharp.

MarkMichaelis avatar MarkMichaelis commented on June 5, 2024

By the way Neal, what specifically did you do change a file to UTF-8? Just curious.

from essentialcsharp.

nlundby avatar nlundby commented on June 5, 2024

There used to be an advanced option in VS that allowed you to change the encoding, but this was removed in VS17 due to uncommon use. The only method available now is to SAVE AS and select UTF-8 encoding and then overwrite the project. The UTF-8 BOM then will cause VS to maintain UTF-8 for future changes.

Removal of the UTF-16 declarations and overwriting the old projects was relatively smooth, but in 2 cases VS was not recognizing the new UTF-8 XML file, but a simple copy & paste operation nudged the IDE to recognize it.

from essentialcsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.