-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
First comment line in C# is counted as Code #72
Comments
This is an unusual one. When run via command line it does indeed fail. With the following test however,
It actually passes. I had a look at the encoding of the file, and the issue is that it is encoded as UTF-8-BOM. If you change it to UTF-8 it works as expected, re-encode as UTF-8-BOM and back to the failure. Just a guess (ill confirm later) but I suspect #73 is the same issue. Seeing as UTF-8-BOM adds some bytes to the start of the file this explains why the first line is counted as code.
I am not sure about the best way to approach resolving this. BOM is not recommended for use with UTF-8 http://www.unicode.org/versions/Unicode5.0.0/ch02.pdf
From wikipedia,
It is possible to check for the special characters and then strip them https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding but I would need to see if this is a common pattern for dealing with this. @dbaggerman thoughts? @ptupitsyn is there any special reason you are using BOM for some files? |
Looking into it, seems removing the BOM is a pretty common pattern. I will add a check which checks for the presence of the first byte, and if so check for the full BOM and if found skip those bytes before processing the rest of the file. |
Above replicates the bug. |
There is a fix for this specific issue in PR #74 however I want it to be expanded to be more generic before it is merged in. @ptupitsyn If you need a fix now you can build from that branch. Once we have the final fix merged in ill close this down. |
I understand that BOM is not recommended, and modern IDEs and editors don't insert it. Skipping BOM bytes seems to be a good approach. Thanks a lot for the quick response! |
Merged in. Build from master to get this. Will be made into the next release, when #76 is finished off. |
Describe the bug
When first line in C# file contains single-line comment (starts with
//
), it is counted as code.To Reproduce
FooClass.zip
Expected behavior
Actual behavior
Desktop
The text was updated successfully, but these errors were encountered: