In Visual Studio 2015, if you have code like this:
var foo = that.Bar(); // Get the value
//foo++;
selecting Edit -> Advanced -> Format Document results in formatting like this:
var foo = that.Bar(); // Get the value
//foo++;
where Visual Studio has assumed two unrelated comments were related and grouped them together. The assumption of relation is because there are consecutive lines, one ending with a comment and the next starting with one. This can, of course, be worked around by adding blank lines but that is not always the best choice depending on the specific code. Note that Visual Studio 2013 did not have this feature.
I was unable to find any mention of this feature via internet searches. This is C#, and Visual Studio is configured to preserve tabs.
Is there any way to disable this one portion of the auto-formatting?
I don't think this is possible. I've found this post on GitHub where one comment mentioned your problem. CyrusNajmabadi wrote:
Interestingly enough, we added some support to align comments over multiple lines. So, for example, in the example being mentioned, post format you end up with:
Alignment is an interesting problem, and currently we have no support for alignment to happen with tabs when formatting between tokens. However, it gets more and more complex considering you might have these comments attached to items which themselves get moved around by formatting and thus may have their locations move to places that are not on tabstop boundaries.
Related
i dont like the new interface of my search all, it suddenly change when i reinstall my visual studio
here is my search all result interface
the result suppose like this
Do you guys know how to change the result interface ?
It sounds like you are using 2 different types of search.
The first capture you provide is from Find and replace feature, that cand be raised with shortcut Ctlr + F, and when you select option "Find all". It returns a lsit fo files that match the text you are searching for. You may check Microsoft documentacion for Find and replace
The second capture represent the usage of Find references in your code, that provides a way to find where particular code elements are referenced throughout your codebase. You can find more information in Microsoft documentacion for Find references.
If you want to make use of Find references feature, you should use shortcut Shift + F12 or simply you can make right click over any object/class/element in your code, and select option Find all references.
Capture: Find all references using right click and contextual menu
Remember that this would not work with a simple piece of text, you must find references of an existant element, like a model, a class, a variable, etc.
Hope this info could be useful.
[EDIT]
Maybe I could misunderstand your question. If you refer to the theme (backgroud anf font color mainly) of the interface, you could set Light theme option, through main menu, selecting Tools menu, and then Options. once there, enter section General, under Environment option, and select Light option in dropdownlist associated with Color theme option.
Check this link (made for VS CE 2017, but work as well) to see captures of the process:
https://ourcodeworld.com/articles/read/869/how-to-change-to-a-dark-theme-in-visual-studio-community-2017
[EDIT FOR COMMENT]
I've checked it with VS 2019. As you said, default view for Find all feature looks like references result view. If you want to keep the "classic" list view, you can simply click on ListView button, at the right top, on the bar that appears over your result section, as you can see in following capture.
Whenever I write my own XML comments and use some of the helpful tags like <c></c> or <see cref=""/>, the intellisense popup window shows the literal XML instead of applying any formatting. I typically write XML comments just for the sake of intellisense rather than to build documentation with sandcastle. Is there a way to get intellisense to format my XML tags, or should I abandon them altogether?
I see the same behavior in both Visual Studio and Visual Studio Code.
edit
I deserved that downvote. After researching further, I see there's a lot more that I missed in the original question. The problem only occurs when I am writing a "shortcut" comment, where I leave off the actual XML tag for <summary>, for example:
/// Adds 2 to <c>x</c>
int Add2(int x) => x + 2;
Those comments still show up in the XML document, and I thought it was just shorthand for a comment that only includes a summary.
Furthermore, I also discovered that the behavior for those "shortcut" comments is different for different languages. F# displays the problem as I described in my original post:
Meanwhile, C# just doesn't render any sort of comment in the intellisense popup at all:
I suspect now that my answer is just that Visual Studio and Visual Studio Code don't really like comments where you leave off the <summary> tag.
When I try to paste some C# code in .cshtml view, visual studio 2013 lower cases content within statements like this:
List<MyModel>
So as a result I see this
List<mymodel>
Which is not correct. Do you have any ideas why? Btw, I have Resharper installed.
My best guess: You have "Normalize tag names" enabled in ReSharper. To check, go to Visual Studio's Tools menu > Options > Resharper > Options button > Code Editing section > HTML > Code Style > Normalize tag names. Having that enabled will force lower-case on HTML tags (which your List type is maybe detected as, being between angle brackets).
If that's not it, I'd poke around for similar settings in ReSharper.
Shown: Options dialog for ReSharper Ultimate in VS 2015. YMMV.
Bah. I broke my own rule and posted an answer as a comment. So, here it is as an answer.
This happens when the code is jacked and Intellisense can't properly parse it. The <MyModel> bit is being interpreted as an HTML tag, rather than as C# code, and by style conventions, VS lowercases all HTML tags.
Long and short, to prevent it, make sure that both the code you're copying and pasting and the code your pasting it into are valid Razor code. You can also do CTRL+Z immediately after the paste. When VS does automatic formatting on a block of code, the first undo in the stack is its formatting.
I have been wondering how to setup intellisense comments for Visual Studio (minimum version 2013) and have been having trouble. Using XML comments are only useful for generating the separate file for documentation.
What I want is to be able to put descriptions on functions/methods that show up when I hover over them in a project I am working that includes the DLL that should have these descriptions already set. This is something trivial to be honest but it would be really nice to have this functionality. But every thing I try seems to end with no comments being shown in the project when I hover over these functions/methods.
To restate my question, what needs to be done to allow for my descriptions of functions/methods to appear when I hover over them when they are used in a separate project/solution?
Okay. I got it to work. I just checked the XML documentation file box in Project Properties -> Build Tab. I also needed to include it as Alexei Levenkov helped me out with in the comments. Doing both of those things allow them to show up.
Feature explained below is available in Microsoft Dynamics AX (formerly known as Axapta), an ERP application. However, my question is related to Visual Studio 2010 and MVC 3 application. Please find my questions after this feature explanation.
Screenshot #1 shows a method written in X++ (language used in Microsoft Dynamics AX) using the MorphX editor. If I select a text within double quotes and right-click on them, I will get the options as shown in the screenshot. This is true if the text begins with an # character and is a valid id found in the label file.
If I click on the option Lookup Properties/Methods, a tool tip will appear showing the actual text associated with the selected label id. Here in this case the label id is #SYS67 and its associated label text is Transaction date. Refer screenshot #2.
If I click on the option Lookup Label/Text, the label editor will appear with the label id pre-filtered along with other languages of choice at the bottom section of the editor. I can change the translation text in different languages using the editor. Refer screenshot #3.
In Dynamics AX, the label texts are stored in text files with label id and separated by a tab. Label ids always begin with # symbol. Here in the example shown #SYS is the group prefix and the given number is a sequential index. Refer screenshot #4 that displays text found in an en-us label file.
I understand that this is similar to Resource editor in Visual Studio where the translation text are stored in .resx files for each language. I would like to do something similar for an ASP.NET MVC 3 application using SQL Server database as the data store for the translation text.
Here are my questions:
What would I need to create in Visual Studio 2010 to achieve this functionality so I can invoke the translation editor in the IDE? Would that be a plugin or extension?
Would a similar resource provider be possible to do in an ASP.NET MVC application, where I can just specify the label id within double quotes and have provider model fetch the data from database during runtime? Is the syntax Resources.MyResource.GetLabel("#SYS67"); the only available option in ASP.NET? Sorry, if the resources syntax is wrong.
Are there any similar tool set (plugin/extension) already available for Visual Studio?
I believe that one of the terms to do translation in ASP.NET application is making use of Resource Provider Model. Are there any other terms? I am interested to know the term of what I am trying to achieve so I can search on the web to read more about it.
Any inputs will be really appreciated.
Thanks in advance.
Screenshot #1:
Screenshot #2:
Screenshot #3:
Screenshot #4:
I'm going to jump in here and give you what I know. I apologize if it doesn't completely answer your question but I don't want to stray too far from what I am familiar with and thus give you bad advice.
From the way you describe your issue, it seems that you could use the resource files (RESX) for translations, the issue is more that you want to know how to edit them in a manner that is user friendly. Further, some users may want to edit the translations on the web.
To answer this part of your question, I would recommend that you look at this article:
http://blog.lavablast.com/post/2008/02/07/RESX-file-Web-Editor.aspx
The author seems to have a similar issue as you and the conclusion the author arrived at was similar to what you are thinking about. The source code is provided so you could get a head-start if you wanted to pursue this method.
If you are going to pursue rolling your own editor, I would suggest that you choose one interface and stick with it. Otherwise you will be increasing your development time on something that isn't your actual product. Since you want the web for some users, I would suggest you would stick with the web for everyone. However, if you really want to pursue an plugin for Visual Studio, I would recommend that you put as much code into a central business logic layer as possible so that your presentation layers don't take up much of your time.
As for currently-available options, I don't think any of the following are Visual Studio plugins, but they all do a good job at working with localization:
http://www.redpin.eu/index.html
http://www.lingobit.com/products/index.html
http://www.sdl.com/en/language-technology/products/software-localization/sdl-passolo.asp
If you want to learn more about the terminology and practices of localization, I would recommend the following site:
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/localization.aspx
If you want to store information in a database instead of a .resx file, here is a resource that will show you how to do it:
http://msdn.microsoft.com/en-us/library/aa905797.aspx