Visual studio "inconsistent line endings" - c#

I'm new to VS, never really used it much. Prefer other IDE's but when it's a toss up between VS and MonoDevelop, I was told VS was the better choice.
I set it as my default editor in Unity and it's giving me this message every so often
The line endings in this file are not consistent. Do you want to normalize the endings?
Then it gives me a list such as
Windows (CR LF)
Macintosh (CR)
Unix (LF)
How can I stop this from coming up?

You can turn off that check in Tools/Options/Environment/Documents
Uncheck "Check for consistent line endings on load"

If you don't want to cover up by changing the document setting, you can try and remediate by replacing the faulty line endings. See post 'how to fix inconsistent line endings for whole vs solution.

Related

is there rules for comments in editorconfig file

I did a custom .editorconfig file which I apllied the nameing conventions like(interfaces should begins with I and then Uppercase) and works just fine (except the fact that it doesnt fix the names automatically after i run code cleanup). and i was wondering if there were a set of rules to control the comments, for example, the line should starts with space then the comments, and it should start new line after 100 character.
I dont want to use third party softwares, I would like to use vanilla visual studio

SpecFlow has parsing problems

I have a problem with parsing steps in .feature file with implementation which is defined in steps.cs file. Beside that, the same step was parsed successfully just a few lines upper in same scenario in .feature file. All steps bind successfully, with exception of last 2 steps, which fail to bind, although these steps appear for 2nd time.
I tried to delete .cache files in %TEMP%, but it is not that. Besides that, step definition is like:
From steps.cs file, when I do Ctrl+Alt+Shift+S, I get 2 steps recognized, which is ok.
We use VS 2015, specflow for VS2015, and SpecFlowSingleFileGenerator as generator. Same happens with VS 2019, with specflow for VS2019 and SpecFlowSingleFileGenerator as generator.
I must say that we have a plenty of scenarios and features which behave nice (with very very basic regex).
Anybody got any clue for this?
Also, when I enable tracing (Tools->Options->SpecFlow) in Output window of VS, I get the messaages:
[08:51:21.6011171] EditorParser: Start full parsing
[08:51:21.6041087] EditorParser: Finished full parsing in 2 ms, 6 errors
Edit: when I open .feature file for first time on opening solution, it parses everything well at first glance. But after 30 seconds, some of steps transit to unrecognized state, as mentioned above.
Edit 1: seems like this part of regex makes problems - \s*(for remote point ""(.*)"")?.
When I put space before open brace (, I get good parsing. But my steps then aren't functioning anymore.
Edit 2: images removed.
Edit 3: I've got mail from Andreas about this topic:
When the regex of a binding is getting to complex the Visual Studio Extension has problems to match them correctly. I fear your regex is already to complex for it.
The runtime should handle it just fine.
From my experience having these kind of checks in the regex make it hard to see then the error at runtime.
I think you only get an exception that the step can't be matched.
If I have such a restricted range of possible values as in your binding, I always have a runtime check that throws an exception if it doesn't pass.

Strange name and value appearing in Watch window

Does anyone have any idea what this means in the Watch window, how it was caused and how I could fix it?
I can't seem to find a specific line of code which is breaking it, it appears before the constructor of a class. I don't know what is causing it. I am programming in C# using Visual Studio 2015.
Has anyone else had an issue of this before?
A non-image version of the output is:
此᫈暔熚攺ᙋᲰ耀㼴͹픑㨊攼ᙉᵬ耀 error CS0726: '᫈暔熚攺ᙋᲰ耀㼴͹픑㨊攼ᙉᵬ耀' is not a valid format specifier
I'm not great at languages, but it appears to be a mixture of Chinese, Korean and various unicode characters. All of my code is written in English.
EDIT After further investigation, changing the text value or deleting it will make it not reaper when stepping through the code (Until it hits an exception in my code), or relaunching the debugger.
This is the Watch window - it contains a list of variables you specifically want to watch while debugging. It is not related in any way to a line of code. When you hit a break point, you can enter any value at all in the Name column - if it matches a variable that is currently in scope the value column will show its current value otherwise an error saying it is not in scope.
The names are saved somewhere so they persist when VS is restarted, so it is possible it is due to corruption of that file or if you cut & paste from somewhere using an unexpected character set.
The Name column must be a valid variable name (no spaces) or an expression (spaces allowed but it must be a valid expression) - anything after the valid portion of input may be considered as a format specifier (for example to limit number of array elements) - this error is related to that.
You can simply delete this entry & it will be gone permanently. There is no problem with your code.
Compiler Error CS0726
Visual Studio 2008 Other Versions
'format specifier' is not a valid format specifier
This error occurs in the debugger. When you type a variable name into one of the debugger windows, you can follow it with a comma, and then a format specifier. Examples are: myInt, h or myString,nq. This error arises when the compiler does not recognize the Format Specifiers in C#.
Check your VS language :
On the Tools menu, click Options.
In the Options dialog box, expand Environment and then click International Settings.
In the Language list, choose the language in which the UI text should appear in the development environment.

How to remove extra empty lines from file with mac line endings in VS 2008?

So that's the question...perhaps there's a regular expression for this? Just to be clear, I don't want to remove ALL newlines and bunch all of the code together, only the extras. I'm not familiar with how to construct regexes, so any help is greatly appreciated!
And here's the explanation as to why:
I was obviously ignorant of the troubles the following situation could cause, so you know I'm now fully aware of that! I've submitted c# code on a mac to perforce, which originally came from windows. Now I've updated those source files on my PC, and their line endings are now messed up, with VS 2008 giving me a compiler error, telling me to fix my mac line endings. I found the Stripem VS add-in, which fixes the compile error, but the code looks terrible, with tons of extra lines.
For the regex approach, see if you can match one or both of \r or \n
.
I don't know what ending of line mac's are using... but if it is \n and \r this could help:
remove all \r or replace it with \n, then replace multiple \n with one \n.
You could use Notepad++, it has nice conversion between EOL Windows/UNIX/Mac.
FYI: I use VS2012 and there is build-in mechanism for this kind of things:
File -> Advanced Save Option...
And then you choose encoding and line endings.

Automatically Format Document in Visual Studio?

Anyway of invoking the Edit > Advanced > Format Document" VS command automatically when switching away from a document / routinely with a timer / on entering a document?
Its really irritating Ctrl+E+D'ing everytime you want to prettify your code.
ReSharper does this every time you close a brace, press semicolon or paste some code in. It's not quite what you're asking for, but I don't think you'll notice the difference. Oh, and it rocks in so many other ways as well.
You can try this extension for Visual Studio 2013 I wrote recently. This is almost the same as the feature in Productivity power tools but also works for *.cshtml, *.xml and all formats which support the command "Format Document"
Format Document on Save

Categories