Giter Site home page Giter Site logo

microsoft / vs-macros Goto Github PK

View Code? Open in Web Editor NEW
132.0 41.0 41.0 18.87 MB

An extension for Visual Studio 2013+ that enables the use of macros in the IDE. The extension can record most of the features in Visual Studio including text editing operations.

License: Other

C# 60.63% JavaScript 11.66% Rich Text Format 27.71%

vs-macros's Introduction

[Not maintained]

This extension was originally created by a group of interns on the Visual Studio team. It is no longer maintained.

Macros for Visual Studio

An extension for Visual Studio that enables the use of macros to automate repetitive tasks in the IDE. The extension can record most of the commands in Visual Studio including text editing operations.

Features

  • Record and playback active document operations and Visual Studio IDE commands
  • Playback multiple times
  • Manage and persist macros with a Macro Explorer
  • Assign keyboard bindings to any macro
  • Macros recorded as JavaScript files that call VS DTE APIs
  • Macro editing in Visual Studio with DTE IntelliSense
  • Stop playback
  • Sample macros

Example

Suppose you wanted to convert the private variables in the following class to public fields.

class TestClass
{
    private string myString;
    private int someonesInt;
    private List<object> yourCollectionOfObjects;
    private bool macrosAreCool;
}

To do so efficiently, place your cursor before the "p" of the first private then start recording a macro (CTRL+M, R). Select the next word, type in "public" then go to the end of the line, go back two words, select the first letter, make it uppercase (CTRL+SHIFT+U). Finally, go to the next line and place the cursor at the beginning of the line and stop recording (CTRL+M, R again).

You can then playback the macro (CTRL+M, Enter) or play it back multiple times (CTRL+M, I).

Convert private variables to public fields

Getting Started

To install the extension, download and run the VSIX available from the Marketplace at this link: https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.MacrosforVisualStudio. Alternatively, from within Visual Studio open Tools > Extensions and Updates and search for Macros for Visual Studio.

After installing the extension, the Macro menu will appear under Tools > Macros. Under this menu, you'll find commands to record and playback a macro.

Current macro

The Current macro is a temporary macro that holds the last recorded macro. To persist it, use the Macro Explorer toolbar command Save Current Macro (or right-click the Current macro). Name the new macro and assign a shortcut if you wish. The new macro will then be persisted on your file system.

Assigning a shortcut

Predefined keyboard shortcut

To assign a shortcut to a macro, right-click the macro and then Assign shortcut. Select a shortcut from the list and hit OK.

Assign Shortcut

Custom keyboard shortcut

To assign a custom keyboard shortcut like CTRL+SHIFT+; to a macro,

  1. Assign a predefined keyboard shortcut

  2. Go to Tools > Options > Keyboard (or click on "Assign custom keyboard shortcut" in the previous dialog).

  3. Search for Tools.MacroCommand# where # is the number of the predefined shortcut you assigned your macro to.

    Search for Tools.MacroCommand#

  4. Assign a custom shortcut to that command

    Assign Shortcut to Tools.MacroCommand#

Sample macros

Accessibility

  • Decrease Font Size
  • Increase Font Size
  • Maximize Tool Windows

Documents

  • Close Except Active: close all files in Visual Studio except active file
  • Headify All: insert header into each C# file in the solution
  • Remove and Sort All: remove unused usings and then sort, for each C# file in the solution

Editor

  • Beginning of Function: moves cursor to the beginning of the current function
  • Insert Date & Time
  • Insert Date
  • Insert Header: insert header into current C# file
  • Insert Time
  • Pane Center Screen
  • Pane Top Screen
  • Save Backup: saves active document as .bak file in current directory

Snippets (inserts code snippet)

  • For Each Document: to iterate through each open document in Visual Studio

  • For Each Window: to iterate through each open window in Visual Studio

  • Properties: grab one of the properties in Tools >> Options

    For example, to show/hide status bar:

              var property = dte.Properties("Environment", "General")
              property.Item("ShowStatusBar").Value = true
    
  • Undo Context: encapsulate a single undo in macro script

Utilities

  • Find Line: queries find tool for current line
  • Toggle Line Numbers
  • Toggle Word Wrap

Caveats

The following are not supported by the extension right now:

  • Recording interaction with dialogs
  • Recording of 'async' commands like Build may not execute as expected
  • Execute a macro inside another macro

FAQ

  • Can I playback macros from Visual Studio 2010?

No. Macros in this extension are written in JavaScript while macros in Visual Studio 2010 were written in VBA Macros.

If you want to use your old VBA macros, you'll have to manually convert them to JavaScript.

  • How can I modify the shortcut to record, playback and playback multiple times?

Go to Tools > Options > Keyboard and search for Tools.StartRecording, Tools.Playback, Tools.PlaybackMultipleTimes.

  • How can I assign a custom keyboard shortcut to a macro?

See Assigning a custom keyboard shortcut.

  • How can I have my project macro folder in the Macro Explorer

The Macro Explorer displays all macros in its Macro Directory and its sub directories. You can open the Macro Directory by clicking the last blue arrow symbol. But if you create a Folder soft link there (using mklink /D), you can link to whichever folder you want and the Macro Explorer displays the content of your folder of choice, too. This makes it possible to have your macros in your project's version control.

vs-macros's People

Contributors

admiralsnyder avatar justcla avatar madskristensen avatar microsoft-github-policy-service[bot] avatar olegtk avatar timsneath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vs-macros's Issues

Allow writes to Ouput panels

Please consider adding the ability to write to a "named" Output panel.

I have used VB macros where I can write macro output to an Output panel, with a name like "My Ouput Name". The output can be viewed just like "Show output from: Build".

Add shortcut to edit macro

In the macro explorer window, it would be great if there were an option to open the macro's js file from context menu when you right click on a macro.

Detect Control and Shift key states

Please consider adding the ability to determine if a Control or Shift key is held down.

I have used this ability in VB macros to alter the behavior based on these key states.

Thanks

Break points

I once has a macro in visual studio that would put a break point on every function. Is that possible with your extension?

Massive multi-instance bug!

Run two instances of Visual Studio, let's call them A and B.

Open a document in instance A, record and playback a macro, it is modifying the document in VS instance A.

Switch to VS instance B, record and try to play back a macro. It seems as if nothing happens. At all. Now switch back to VS instance A, and see how the document in that instance has been modified!

iterative all documents in visual studio 2017

Hello.
recently i updated my visual studio and start using macro explorer. i tried to use one of the sample macros "removes and sorts all". but i realized if i have a open documents, it doesn't run. so i closed all my open documents and try again this time it open all documents and close them but it doesn't work ether. the problem is command execute before the document completely load. if there was a event or timer that can help wait until document load completely the problem will solve.
i appreciate any sort of help.
thank you.

There is no way to use EnvDTE ENUM into dte.Find.FindReplace fucntion

Here an example of what i made to correct the problem

var EnvDTE = {
vsFindAction: { vsFindActionFind: 1, vsFindActionFindAll: 2, vsFindActionReplace: 3, vsFindActionReplaceAll: 4 },
vsFindOptions: { vsFindOptionsNone: 0, vsFindOptionsMatchWholeWord: 2, vsFindOptionsMatchCase: 4, vsFindOptionsRegularExpression: 8, vsFindOptionsBackwards: 128, vsFindOptionsFromStart: 256, vsFindOptionsMatchInHiddenText: 512, vsFindOptionsWildcards: 1024, vsFindOptionsSearchSubfolders: 4096, vsFindOptionsKeepModifiedDocumentsOpen: 8192 },
vsFindResultsLocation: { vsFindResultsNone: 0, vsFindResults1: 1, vsFindResults2: 2 },
vsFindTarget: { vsFindTargetCurrentDocument: 1, vsFindTargetCurrentDocumentSelection: 2, vsFindTargetCurrentDocumentFunction: 3, vsFindTargetOpenDocuments: 4, vsFindTargetCurrentProject: 5, vsFindTargetSolution: 6, vsFindTargetFiles: 7 }
};

dte.Find.FindReplace(
EnvDTE.vsFindAction.vsFindActionFindAll,
"<\s*?Field\s+?(?=(?:.*ColName|.RowOrdinal|.SourceID)).\s?>",
EnvDTE.vsFindOptions.vsFindOptionsRegularExpression + EnvDTE.vsFindOptions.vsFindOptionsFromStart,
"",
EnvDTE.vsFindTarget.vsFindTargetSolution,
"",
"",
EnvDTE.vsFindResultsLocation.vsFindResults1
)

Unable to replay newly recorded macro

When I try to create a macro, it says it can not save shortcut to-
C:\Users\hauswij\AppData\Local\Microsoft\VisualStudio\14.0\Macros\Macros

I created this directory by hand and it then can save to this dir with a file name Current.js
Next problem I ran into after this was trying to playback the macro. Nothing happens.

I have VS 2015 update 1.

Support recording actions on Modal Windows

I am trying to automate Scaffolding.

I record a Macro for Solution > Project > Add > New Scaffolded Item > I Choose Template > I Enter Entity Name

The macro records following steps only:

dte.ExecuteCommand("ProjectandSolutionContextMenus.Project.Add.NewScaffoldedItem");
dte.ExecuteCommand("File.SaveAll");

Ideas?

Saving a macro on VS2017 fails

100% reproducible:
I record a macro in VS2017, consisting in a short sequence of replace's. I stop recording and try to save the macro, resulting in one of the two errors:
-Cannot create a file when that file already exists.
or:
-Object reference not set to an instance of an object.

[Feature request] Recording macros that change specific Options settings

VS has a lot of Options that I often need to toggle or switch while in the middle of doing something, a common example is the "Just my code"-mode for Debugging, fortunately there's a bunch of extensions that do this specific action already, but I'd like to be able to toggle/change any setting (or a bunch of settings) in VS via a recorded macro which I could then map to a toolbar button.

Some of the settings I find myself needing to toggle without wanting to dig through the Options windows:

  • Debugging: Show raw object layout in Autos/Locals/Watch window
  • Various C# editor options that still aren't controllable via .editorconfig
  • etc

Unreliable playback

I have this macro:

dte.ExecuteCommand("Edit.Find");
dte.Find.FindWhat = 'constructor(';
dte.Find.FindWhat = ')';
dte.ActiveDocument.Selection.CharLeft();
Macro.InsertText(",");
dte.ActiveDocument.Selection.NewLine();
Macro.InsertText("configurator: IConfigurator)");

It can't figure it out how to get it to work. Sometimes it jump to the correct line, sometimes it doesn't do anything, most of the time it puts in only half the text.

I don't have any plugins installed.

VS crash (VS15.9.4)

I'm not sure if this can be solved in VS-Macros, or if VS (or even .NET/CLR) itself is broken beyond repair, but here goes...

I had mapped playback to a repeatable key combination, and held down that playback shortcut. After less than ten repetitions the editor messed up, editing in a location it should not, and then froze. Trying to get it to wake up I got a complete VS crash (including the inevitable and obvious Data Loss, so this should be easy to escalate if required), where an !analyze -v of the crashdump revealed the following:

STACK_TEXT:  
2d9af4dc 689f857e System_Core_ni!System.IO.Pipes.PipeStream.CheckReadOperations+0x2cc326
2d9af4e8 6872af9a System_Core_ni!System.IO.Pipes.PipeStream.Read+0x8e
2d9af504 6a7eb942 mscorlib_ni!System.IO.BinaryReader.ReadBytes+0x42
2d9af51c 6a7e07c8 mscorlib_ni!System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read+0x18
2d9af530 6a7e0773 mscorlib_ni!System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord+0x23
2d9af540 6a7e0307 mscorlib_ni!System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run+0x27
2d9af570 6a7e020f mscorlib_ni!System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize+0x7f
2d9af598 6a7dffdb mscorlib_ni!System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize+0xbb
2d9af5c0 06ca71e7 UNKNOWN!VSMacros.Pipes.Server.WaitForMessage+0x87
2d9af5e8 6a7c60fd mscorlib_ni!System.Threading.ThreadHelper.ThreadStart_Context+0x9d
2d9af5f4 6a7f29a5 mscorlib_ni!System.Threading.ExecutionContext.RunInternal+0xe5
2d9af660 6a7f28b6 mscorlib_ni!System.Threading.ExecutionContext.Run+0x16
2d9af674 6a7f2871 mscorlib_ni!System.Threading.ExecutionContext.Run+0x41
2d9af68c 6a7c6058 mscorlib_ni!System.Threading.ThreadHelper.ThreadStart+0x44

(I think this might have been the reason I stopped using this extension a few years back)

Edit: Upon running VS under another VS as debugger (as the crash is 100% repeatable within mere seconds), it told me a bit more:

System.InvalidOperationException
  HResult=0x80131509
  Message=Pipe hasn't been connected yet.
  Source=System.Core
  StackTrace:
   at System.IO.Pipes.PipeStream.CheckReadOperations()
   at System.IO.Pipes.PipeStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.BinaryReader.ReadBytes(Int32 count) in f:\dd\ndp\clr\src\BCL\system\io\binaryreader.cs:line 536
   at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser input) in f:\dd\ndp\clr\src\BCL\system\runtime\serialization\formatters\binary\binarycommonclasses.cs:line 471
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord() in f:\dd\ndp\clr\src\BCL\system\runtime\serialization\formatters\binary\binaryparser.cs:line 386
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() in f:\dd\ndp\clr\src\BCL\system\runtime\serialization\formatters\binary\binaryparser.cs:line 111
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) in f:\dd\ndp\clr\src\BCL\system\runtime\serialization\formatters\binary\binaryobjectreader.cs:line 172
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) in f:\dd\ndp\clr\src\BCL\system\runtime\serialization\formatters\binary\binaryformatter.cs:line 197
   at VSMacros.Pipes.Server.WaitForMessage()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state) in f:\dd\ndp\clr\src\BCL\system\threading\thread.cs:line 68
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs:line 954
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs:line 901
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) in f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs:line 890
   at System.Threading.ThreadHelper.ThreadStart() in f:\dd\ndp\clr\src\BCL\system\threading\thread.cs:line 105

++luck;

How to debug?

as stated earlier, no break point possible.

alert() is not working too.

Incompatible with VS 2017

the extension doesn't work with VS 2017
Just modifying the manifest is not sufficient, because the ExecutionEngine fails.

I'll update the issue as soon as I know how to fix it.

Error "Could not find a part of the path"

When I try to record a macro after installing I get this dialog:

Could not find a part of the path 'C:\Users\filips\AppData\Local\Microsoft\VisualStudio\14.0\Macros\Macros\Current.js'.

It turns out that indeed - there is no Macros\Macros folder under C:\Users\filips\AppData\Local\Microsoft\VisualStudio\14.0\

Creating the two subfolders seems to fix the problem.

vsFindOptions is undefined

/// <reference path="C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\14.0\Macros\dte.js" />


debugger;
dte.SuppressUI = true
var objSelection  = dte.ActiveDocument.Selection
objSelection.StartOfDocument()
While(objSelection.FindText("#region",   vsFindOptions.vsFindOptionsMatchInHiddenText))
   alert ( " found something")
Loop
objSelection.StartOfDocument()
dte.SuppressUI = false

This code gives the error vsFindOptions is undefined. How do we match lines?

My goal here is to run though the active document and collapse any line that has the text "#region" or "function" in the line

Any help appreciated.

Thanks
Colin

Get Latest Version then open Output to Source Control - Team Foundation

Why doesn't this VS2017 macro open Output window to "Source Control - Team Foundation" after it does "Get Latest Version (Recursive)" for my solution?

dte.ExecuteCommand("ClassViewContextMenus.ClassViewProject.SourceControl.TfsContextGetLatestVersion");
dte.ExecuteCommand("View.Output");
dte.Windows.Item("{34e76e81-ee4a-11d0-ae2e-00a0c90fffc3}").Activate();
dte.Commands.Raise("{1496a755-94de-11d0-8c3f-00c04fc2aae2}", 1627, null, null);

insert new line after last property of class

Hi! First, thanks for this extension.
is there any way to insert new line after last property of class?

public int Foo1 { set; get; }
public int Foo2 { set; get; }
public int Foo 3{ set; get; }
public int Foo4 { set; get; }
//here i want to insert new line
public void Bar()
{
}

Support the clipboard

I would like the ability to place text on the clipboard, and to read text from the clipboard.

I have used the clipboard in VB macros, and have found the feature very handy.

Thanks

Can you please include installation directions in Readme.md?

I'm a first time user interested in the VS-Macros extension. I skimmed the long Readme.md file and found nothing explaining how to actually install the extension into visual studio. Under "Getting Started" it skips the actual installation steps:

After installing the extension, the Macro menu will appear under Tools > Macros.

This is a big barrier to entry for new users like myself.

How do I install this? Do I have to clone the project and compile it myself?

Closing multiple instances simultaneously cause IOException with FolderExpansion.xml

Repro:

  1. Launch multiple instances (at least 3) of VS 2017 (with VS-Macros installed).
  2. Open solutions in each VS.
  3. Right click on the VS icon on the taskbar and select "Close all windows".
    Expected:
    All windows close
    Actual:
    At least one instances gets the following error:
---------------------------
Microsoft Visual Studio
---------------------------
The process cannot access the file 'C:\Users\{username}\AppData\Local\Microsoft\VisualStudio\15.0_80f42237\FolderExpansion.xml' because it is being used by another process.
---------------------------
OK   
---------------------------

It looks like this file is created/used by the VS-Macros extension.

Parameterize macros

Add an interface to specify parameters for a macro
Simple textboxes would go a long way.

Mapped to this or some new global object in the macro scope.

Attempting to run a macro multiple times does not work if you press Enter instead of pressing the OK button.

I pressed the button to run a macro multiple times, the small dialog shows up asking me to enter the number of times the macro should be executed. I entered a number an pressed Enter to confirm, the macro did not execute at all but the macro explorer showed that the macro was running (the run button changed to a stop button).

If I do the same thing but press the OK button everything works as expected.

Search and replace by regex.

Hello, I would like to create a macro that searches and replaces text by regex. At the moment this is what I could come up with (in a javascript file):

dte.ExecuteCommand("Edit.Find");
dte.Find.FindWhat = "test";
dte.Find.ReplaceWith = "test";
//dte.Find.Target = dte.vsFindTarget.vsFindTargetCurrentDocument;
//dte.Find.PatternSyntax  = dte.vsFindPatternSyntax.vsFindPatternSyntaxRegExpr;

The last 2 lines give me errors (the lines where I try to set the target to the current document and the search type to a registry expression). How can I fix this and how can I make this work?

Error while executing macros

If multiple instances of VS2015 are being run , sometimes I see following error while trying to execute a Macro :
'Current.js' error
line 0: The RPC server is unavailable. (Exception from HRESULT:0800706BA)

[help wanted] Macro script for opening first entry in find results 1 window

Hello,

First of all, thank you for this great contribution. However, I find very difficult to write macros since there is no proper documentation.

So, I have a situation that I want to do macro for a global search in entire solution according the selected text and open the first available entry from the find results 1 window. So far I managed to execute the search but find no solution how to take the first item of find results 1 window and finaly open it. Thank you for backup!

var textSelection = dte.ActiveDocument.Selection; dte.ExecuteCommand("Edit.FindInFiles"); dte.Find.FindWhat = textSelection.Text; dte.Find.Action = 2; // Find All dte.Find.Execute();

Tools.MacroCommand# was not added to the list of possible commands for key assignment

Unfortunately my install of this extension did not add the Tools.MacroCommand# to my VS2015 instance, so I cannot assign custom keystrokes to my macros.

I have installed, uninstalled and re-installed, restarting each time, without the Tools.MacroCommand list added to the list of keyboard commands...

My visual studio version reports this version info for my instance.
Microsoft Visual Studio Enterprise 2015
Version 14.0.24720.00 Update 1
Microsoft .NET Framework
Version 4.6.01055

Also, how do you assign a number to a command to use with key assignment? I tried assigning it by assigning the preset command keyboard shortcut of 1 or 2, but no other way exists that I can see to assign a number...

(...by the way, I love the fact that you guys used Javascript as your language of choice... It is my absolute favorite scripting language!!!)

Sample macros get reverted on VS restart

You can edit the sample macros and use them inside your Visual Studio session.
But when VS restarts, the sample macros get reverted to their original state and the edited version is lost.

Steps to reproduce:

  • Open Visual Studio
  • Open Macro Explorer
  • Expand the "Samples->Editor" folder.
  • Right click "Insert Header" macro and choose "Open"
  • Edit and save the "Insert Header" sample.
  • Run the sample. (it works with the changes)
  • Restart Visual Studio
  • Attempt to re-run the same macro (Insert Header)
  • Notice that the macro reverts to its original behavior

iterative all documents in visual studio 2015

Hello.
i just start using the Macros. i simply want to go through all the documents in the solution and then run this command:
dte.ExecuteCommand("Edit.CollapsetoDefinitions");

so i used your one of the sample macros "removes and sorts all". but the problem is command execute before the document completely load. if there was a event or timer that can help wait until document load completely the problem will solve. here is my macro:

iterateFiles();

function iterateFiles() {
    for (var i = 1; i <= dte.Solution.Projects.Count; i++) {
        iterateProjectFiles(dte.Solution.Projects.Item(i).ProjectItems);
    }
}

function iterateProjectFiles(projectItems) {
    for (var i = 1; i <= projectItems.Count; i++) {
        var file = projectItems.Item(i);

        if (file.SubProject != null) {
            formatFile(file);
            iterateProjectFiles(file.ProjectItems);
        } else if (file.ProjectItems != null && file.ProjectItems.Count > 0) {
            formatFile(file);
            iterateProjectFiles(file.ProjectItems);
        } else {
            formatFile(file);
        }
    }
}

function formatFile(file) {
    dte.ExecuteCommand("View.SolutionExplorer");
    if (file.Name.indexOf(".cs", file.Name.length - ".cs".length) !== -1) {
        file.Open();
        file.Document.Activate();

         //here we must wait until document completely load 
        // Format the document
        dte.ExecuteCommand("Edit.CollapsetoDefinitions");


        file.Document.Save();
        file.Document.Close();
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.