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

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.

Related

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.

Visual Studio: Defining File Type Regardless of File Extension

Where to define, what kind of type a particular file within Visual Studio solution is?
I have observed that file extensions do not necessarily have to relate to the actual file types within VS.(observed within Visual Studio 2010, 2012).
For example: I have an existing Visual Studio solution. In another tool, I have created an HTML file with .html extension. After importing it into Visual Studio solution, the file does not gain HTML Intellisense and Code Completion.
On the other hand, I can create an HTML file within Visual Studio through: Visual Studio -> FILE -> New File -> HTML Page
This file will gain all its HTML related Code Highlight, Intellisense, and Code Completion features. I can then rename its extension to, say, .txt. The file will still keep its HTML properties such as code highlight, intellisense, etc..
My question therefore is, where can I define/change, what kind of file type (HTML, CSS, JavaScript) the particular file is, regardless of its extension? This is important, to be able to assign appropriate Intellisense, Code Highlight, Code Completion features.

How to insert code snippet for Debug.WriteLine(); in 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.

Visual Studio 2008 resx files editor

I need to make some translations of external application forms (I try to add a new language support). I have only form's resx files.
Can you recommend any simple tool which allows me to translate form's texts (only texts if it's possible)?
WinRes.exe, it is included with the SDK. Run it from the Visual Studio command prompt.

Automatically adding specified text at beginning of files in VS 2008

Is there a way to have Visual Studio 2008 automatically add heading information to files? For example, "Copyright 2008" or something along those lines. I've been digging through the options, but nothing seems to be jumping out at me.
I assume you'd like to modify the class file templates. They're in:
%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033
More specific details here
I found a better solution than modifying the template file directly. This utility allows you to create and save header/footer templates and apply them to entire source trees.
C# Header Designer from MSDN Code Gallery

Resources