Visual Studio 2015 not automatically adding asterisk for multiline comments - c#

When typing multi-line comments Visual studio used to add an automatic asterisk to each new line of the comment as I press enter(apparently 2015 does not do this anymore). I really liked this. As of right now though, if I type "/*" and enter, Visual studio does not try to autocomplete it at all. In fact, it even lets me end the comment with "*/", too, instead of doing it for me. So my question is: is anyone else experiencing this? How do I get the original functionality back, so each new line is automatically prefixed with an asterisk, and closed for me by "*/"?
I already checked and yes, my environment settings are set to C# and yes the option "Generate XML documentation comments for ///" is indeed checked in my settings.

This is a well-known problem, the feature fell by the way-side in the Roslyn refactoring of the C# Editor Features. Nothing to do with config or a change of preferences, it simply was not implemented.
It is currently being tracked by this Github issue. Status is "Up for grabs" right now with nobody having shown an interest in grabbing it yet as of today. Afaict, best to not hold your breath for it, I think they have several bigger fires to put out. It will surely be delivered in an update sooner or later.

Just wanted to update and say that this problem was apparently fixed(sort of) in one of the newer updates of Visual Studio. The editor still does not complete the comment for you, but it does at least keep the formatting consistent, and adds an asterisk to the next line for you.

Related

Is there a way to have IntelliSense auto-complete, but not change what I've written?

The title.
I would like Visual Studio to auto-complete on any key press (and not only Tab), but only add to what I've written, never change it.
Is there a way to achieve that?
(VS2022 v. 17.4)
Visual Studio has limited ability to modify how Intellisense works.
https://social.msdn.microsoft.com/Forums/en-US/4ecfb382-d769-40af-908d-0bac9bd562d6/is-it-possible-to-change-intellisense-behavior-to-look-for-explicit-approval-of-suggestions?forum=visualstudiogeneral
You can also find the full documentation for it here: https://learn.microsoft.com/en-us/visualstudio/ide/using-intellisense?view=vs-2022

Observing a question mark sign (?) on every file of a c# project after i reload the project [duplicate]

I often get blue question marks on files in my VS2012 Solution Explorer when opening a solution bound to Perforce through P4VS.
Looks like something is having trouble to "synchronize" with the depot/workspace/whatnot. Hitting "Refresh View" always solves the issue but I'm growing tired on doing this everyday:
This is my VS version:
Microsoft Visual Studio Professional 2012
Version 11.0.61030.00 Update 4
And P4VS:
2014.1.85.4506
This is persistent across P4VS versions for a few months now, and seems to be affecting sometimes individual files, sometimes entire projects, with no apparent pattern.
How can I diagnose what's going wrong, be it a server issue, a VS issue, a workspace issue?... The Perforce Source Control output shows nothing special.
Actually it's not entire folders, it's entire projects. It appears that even if refreshing a project "fixes" the issue for one run, re-opening the solution brings it back. Whereas I think that for individual files, refreshing them solves the issue once and for all. I'll play with it a bit more to confirm that.
To help diagnose what is going wrong you should probably turn on logging, and check the preferences that will show everything in the output window. For the P4VS log, go to:
Tools- > Options -> Source Control -> Perforce - Logging
(This is not the same thing as the Visual Studio Activity log.)
There could be a possibility that you are getting disconnected and refresh reconnects you. I am not sure if you have your connection set to use solution-specific settings, since you did not mention the connection dialog coming up.
This "solved" the issue for me, at least for the entire projects that went blue-question-marked:
1) Tools > Options
2) Source Control
3) Perforce - General
4) Tick the option "Treat Solution/Project as directory when
selected"
Not sure why but that's one less annoyance for me every day. Thanks to Perforce support for suggesting that.
The file is probably not marked for version control. I noticed this icon in one file and opened Perforce to check. For whatever reason, this file was not marked for add in Perforce. After marking the file for add and submitting, the blue question mark went away.

How to set code formatting to allow end-of-line comments?

The C# code formatting in Xamarin Studio (i.e. when hitting Ctrl-I to format the document) puts end of line comments onto a new line. I can't find any way to change this in the C# code formatting policy settings. How to change this to preserve end of line comments on the same line?
For example, take this code:
public class Foo
{
int bar; // comment
}
If I hit Ctrl-I (or alternately click Edit > Format > Format Document from the menu, or select the code and click Edit > Format > Format Selection from the menu), the code is reformatted as:
public class Foo
{
int bar;
// comment
}
I'm using v4.2.2 build 2 v4.3 build 52 on OS X.
Note: it seems this is a bug. So my question really is -- has anyone who has also encountered this come up with a fix or workaround and if so what is it?
I don't think there is a real answer to this question, as you have said its a bug in the version you are using.
UPDATE: We have discovered that this is not a bug in the software. As it affects all versions the OP updates to, most likely there is some setting or extension affecting the outcome.
A work around although you may not be to happy with it would be to place you comments above the line in question. This is a perfectly acceptable way of code-commenting.
public class Foo
{
// comment
int bar;
}
Using version 4.3
Pre Ctrl + I
Post Ctrl + I
As a final note you may want to view your code formatting preferences found here:
UPDATE 1
You could try resetting all your preferences by deleting everything in the following folders, see here.
I will add that I haven't tried this so could break your installation.
Just tested and this doesn't break Xamarin Studio and does reset all preferences.
~/Library/Preferences/XamarinStudio-4.0/
~/Library/XamarinStudio-4.0/
UPDATE 2
The only last thing you can try as we have found out this isn't a bug in the software but something on your computer. Is to do a full removal of Xamarin Studio. I recommend using AppCleaner as it will search for any related files and remove them.
Onces it has fully uninstalled, then reinstall Xamarin Studio.
UPDATE 3
Last solution, try creating a new user account. Run Xamarin Studio under that account to see if the problem persist. If it does the only thing left to do is a fresh install of OS X and reinstall Xamarin Studio first. The problem should be gone now... reinstall all other applications checking that nothing has broken Xamarin Studio after each install.
This has been acknowledged as a bug by Xamarin. See this bug report. In that report, Xamarin says it's replacing its entire formatting engine as of mid-2014, with the hope of having it in place by "next year." Xamarin further suggests avoiding the problem by turning off auto-formatting on save, suggesting there is no official fix or workaround at this time other than avoiding the issue.

Visual Studio 2010 renaming project and main forms

I guess a lot of people start working on something. And then later they find-out the names don't really cover the end product. Or well at least, I do choose often poor names for stuff, I start programming faster then thinking about things like that (in the end I often rename my buttons too so my code becomes more clear too).
What is the best way of a current work in progress (not finished) to rename it? Without breaking the code, or do a lot after editing.
The reason I ask it here is I've seen it gone wrong a few times, leaving me code that didn't work any more so I better as how to do this and where in which pane, it's best to rename.
So what's wrong? Well in the upper right pane of Visual Studio 2010 C# (solution explorer):
The solution itself has a wrong name
The next line of it has the wrong name
And the main form could be improved too
If you were to rename the main form it would ask you if you want to change all references to it, you say yes and that problem is solved.
Renaming the solution is equally simple, just right click in the Solution Explorer and rename. It won't break your local build or anything.
I don't know what "The next line of it has the wrong name" is referring to (the project maybe?) but the same probably goes for it.
Well usually you should change the file name of your class in the solution explorer and it should ask if you want to change all references, though sometimes it can go wrong so to double check you can replace all command to find all references of old name and replace with the new one..
http://msdn.microsoft.com/en-us/library/139eef4h.aspx
Also if you change in code, the name of a class or variable or anything and then you should see small line under the changed name, stand with the mouse pointer on the variable and press ctrl+. (ctrl dot) And that shoul pop up small options and the first one should let you change all references of that variable new name also:
http://www.dofactory.com/ShortCutKeys/ShortCutKeys.aspx

Navigate files with VisualStudio 2008

I am currently developing with VisualStudio 2008. I find it increasingly difficult to find files when the number of files and projects increase. The situation become so bad that I literally have to spend 10-20 seconds to find code I want to work on when switch between files. Sounds like not a lot of time, but this can be very annoying because it breaks the "coding flow".
I believe this is a general problem with all IDEs. But I still find it easier to work with Eclipse. One particular example is that in Eclipse, I could apply some key shortcut to find implementations defined in an Interface.(I have forgotten which key shortcut though, after not working with it for about 1 year.) Another example is that in VS 2008, rightclick->Find all references will find all occurrences containing the selected text(Update: This accusation is incorrect. Thanks for pointing it out); while similar operation in Eclipse will find all occurrences where the selected class/variable are referenced. Personally, I find the Eclipse way is better for file navigation.
This could be due to my inexperience with VS IDE. So, I am looking for suggestions to improve the file navigation experience so that I can get some more time for actual coding.
I have used the navigate buttons but they are only useful for small number of files.
Thanks.
I agree wholeheartedly about ReSharper. If you don't want a "paid" solution though, a useful Visual Studio shortcut is
CTRL + ,
it gives a list of recently edited files.
CodeRush is a free alternative to ReSharper which you might find useful too.
Kindness,
Dan
Have a look at Jetbrains Resharper. Ctrl N or Ctrl Shift N. To jump quickly to files by type name or by file name. Also you can control Click Classes to navigate to them instantly.
I can't even work in visual studio without it anymore. It virtually eliminates the need for the solution explorer
SamTools for Visual Studio 2005/2008 (and I have a build for 2010 if someone needs it). The particular feature that's handy here is the Solution File List.
You can right click the tab of any open document and Find In Solution Explorer or Show In Windows Explorer
You can right click in the Solution File List for the same
Unlike other solutions to this problem, this is a properly docking tool pane so it fits in great. Ctrl+Alt+F places you in the Filter box with the current text selected, so it's very easy to work with.
Oh and it's free/GPL. :)
Solution File List http://wiki.pixelminegames.com/images/8/88/SamTools_SlnFileList.png
Dpack is also a free alternative with some nice file navigation shortcuts, but Resharper is the bomb.
BTW, they should have some more of this stuff in vs2010, which is in beta right now (I think)

Categories

Resources