How to insert code snippet for Debug.WriteLine(); in Visual Studio? - visual-studio

I can simply insert code snippet for the Console.WriteLine(); by just using the cw with Tab + Tab. But I'm not able to find the same option for the Debug.WriteLine();.
I want to know how can we customize the code snippet template in Visual Studio for Windows Phone?

In Visual Studio 2010 (and assuming other versions as well), there is not a snippet for Debug.WriteLine(). In that case, you'll need to create a custom snippet. Fortunately, it isn't that hard with the available resources:
MSDN: Creating and Using IntelliSense Code Snippets
The Snippet Editor
Snippet Designer (Visual Studio Extension) and the related CodePlex Site
If you're using ReSharper, then Code Templates and specifically Live Templates are a quick and easy option.

Related

Where is the documentation on Visual Studio's decorators?

Note: This is not for Visual Studio Code, but for the full version of Visual Studio.
When developing extensions for Visual Studio Code, there is something called Decorators, which can add icons next to each line of code.
I'd like to do the same, but for Visual Studio instead. However, I can't find anything by the name "Decorators" in the documentation. Is it even called that within the full Visual Studio?
Can anyone point me in the right direction?
More specifically, I am interested in making an extension that can produce the icons seen here, and I am unsure what these icons are called in the scope of Visual Studio:
Vertical part where icons are shown is called "glyph margin" and icons in it are called "margin glyphs". Provided link will lead you to a MSDN walkthrough to create your own glyph for a line that has a "todo" text in a comment.
I found a sample that describes it pretty well:
https://github.com/Microsoft/VSSDK-Extensibility-Samples/tree/master/Todo_Classification

Is there a way to extract comments from code files with DTE (Visual Studio Automation)?

I want to extract comments from code files in a Visual Studio extension. Is there a way to do it using Visual Studio Automation without having to parse code text myself?
PS: Roslyn is not a choice, because I'm not restricted to C# and VB.NET only.
Various code elements like CodeClass and CodeFunction have the Comment property that return the header comment, accessible using Visual Studio code model.
And if a document is opened in VS editor, you can check SnapshotSpan classifications for PredefinedClassificationTypeNames.Comment.

Is there a feature in VIsual Studio or Resharper that can extract XAML into a separate file?

In ASP.NET Forms and MVC, you can select a block of code and extract it into a separate user control or file using Resharper and possibly Visual Studio. I cannot find such a feature for XAML. Does it exist in either Resharper or Visual Studio? If so, how do you perform this action?
I think you are looking for this:
https://www.jetbrains.com/help/resharper/ReSharper_by_Language__XAML__Refactorings.html
Resharper allows you to extract styles and resources, but you have to select the XAML and go to Resharper->Refactor->Extract in order to find the options, you won't see them if you use ALT+ENTER.

Add custom code snippet to visual studio intellisense

There is this nice program that enable you to easily create code snippets. I already managed to create snippets but it will be nice if the snippet where to show up in visual studio's intellisense.
For example visual studio already has several built in code snippets such as the one for creating the constructor of a class:
note that it was really easy and fast to use it.
On the other hand when I create my custom snippet with the program that I provided on the first link, these are the steps that I have to do in order to use it:
on step 3 I have to select the folder where the snippet that I created is located then on step 4 locate it.
It will be nice if I could use the code snippet that I created just like the ones that visual studio provides like the constructor one that I showed on the first image. Maybe if I place the snippet that I just created and place it where visual studio store the built in onces it works.
I had to add a shortcut to the snippet.
after adding the shortcut it appears on the intellisense without having to navigate to the folder where it was located by pressing ctrl+k and ctrl+x

Shortcuts for web controls and HTML snippets in Visual Studio

Consider the feature in Visual Studio 2010 for snippets in the HTML Source view of a web page.
type a control name in plaintext with no markup or brackets!
... e.g. hyperlink.
Then hit Tab
Your web control has been auto-completed for you. It's up to you to fill in the other details that you need.
This works for form as well:
<form action="default.aspx" method="post">
</form>
This looks like a real time saver. This is supported in WebForms and ASP.NET MVC projects.
What other snippets are available in Visual Studio 2010 in the Source view of a page?
For the authoritative list of snippets, check out the VS2010 installation folders where the snippets are stored:
C:\Program Files\Microsoft Visual Studio 10.0\Web\Snippets\HTML\1033
There is one folder for ASP.NET and one for plain HTML snippets.
Also, if you use jQuery a lot, there is a set of jQuery snippets that you can add to Visual Studio as well.
Here are a ton (100's) of the short cuts in Visual Studio right from MSDN:
http://msdn.microsoft.com/en-us/library/da5kh0wa.aspx
The one thing that has been around forever but a lot of people forget about is block selection done by holding down the ALT key and use the mouse to select a block of text. Great when you want to copy/cut/delete a bunch of code that is lined up but you don't want the whole line.
Yeah, this is a really cool new set of snippets in VS2010. Here are the articles I used to learn it:
Walkthrough: Using HTML
Snippets
Using HTML Code Snippets in Visual
Studio 2010

Resources