VS2008 Macro: Perform action on every code file in the solution - visual-studio

I have recently noticed how interesting Visual Studio's macros are. I did not use VB for ages so it took me a while until i finally managed to write a little macro that performs some stuff on the currently open document.
Enthusiastically, I next wanted to use this macro on every source code file (.cs) in the solution without having to manually open all files. Could you give me a quick hint on how to do this?

Check out the DTE object reference. Inside a macro you can reference some really neat global properties, like DTE.Solution, which returns a Solution object that describes the currently open solution (and, not surprisingly, has a Projects property, which is a collection of all Projects in the solution). You should be able to iterate over pretty much anything you want at that point!
Have fun :)

Related

VS F# canopy test adding folder

I want to ask you, if it´s somehow possible, to add folder, to sort out Test´s a little bit.. When i am doing in C# parts, there is normally option
right click-> add ->new folder
In F# case, it looks like it´s missing.
I tried to add it even out of VS, via the Win. explorer, but its not working.
Edit: I have found quite poor solution and that´s actually, that you create new folder in C# part and then cut it out and paste to F# section but it´s a bit weird, so any ideas are welcome.
It is not implemented in VS2013 but you can use F# Power Tools extension (http://fsprojects.github.io/VisualFSharpPowerTools/) or create it manually (http://marcinjuraszek.com/2014/03/folders-in-f-projects-how-to-do-it-what-to-avoid.html)
You can either use F# Project Extender or edit the project file manually. Details are here.
Edit: This article explains how to keep your project organized without folders.

Visual Studio extensions for code generation...what's the best way

So we have this tool, it's a web page, we drop a large piece of text in textBox a (say sql) run the tool
and it generates the guts of a code file in TextBoxb (say a custom view class model).
it's written in C#.
I know there are several ways to create visual studio extensions.
What I'd like to know is, what's the best/easiest/fastest way to take a c# dll that has a method that takes text in and returns text out, and turn it into a VisualStudio extenson, that takes text in and creates a files, adds it to the project and puts the text into it.
We're using Vs2008 and VS2010, and I'm okay the best soloution only work on 2010.
The closest I've found by googling so far is this:
http://visualstudiomagazine.com/articles/2009/03/01/generate-code-from-custom-file-formats.aspx
but they are for custom file formats only, i want to generate*.cs and *.rdlc and similar files.
I'd also like to be able to add methods to an existing class.
tutorial walkthroughs or better approaches woud be greatly appreicated.
VS package Builder is the answer. Lots easier.

Automatic way to move Visual Studio project into LINQPad?

I thoroughly enjoy the amazing power of LINQPAD (thanks, Joseph Albahari!) and particularly LINQPad's Dump method. Frequently I take an existing Visual Studio project and move it into LINQPad for the sole purpose of adding a couple Dump statements to see what the data looks like--though Visual Studio's data popups are certainly useful, the Dump output is just much easier to digest. To do this, I open each file I need from the current project, copy and paste the individual classes over to LINQPad, add assemblies and using statements, attempt to run so that LINQPad will tell me what I missed, and repeat until I find all the orphan references.
This method seems antithetical to the elegant, streamlined nature of LINQPad. Is there an easier way? Any chance of seeing "Import Project" on LINQPad's File menu any time soon? If not, I may end up writing a utility myself...
If you just want to call .Dump() in VS, check out this:
http://code.google.com/p/linqpadvisualizer/
Importing an entire VS project into LINQPad might be impractical... but I'm going to look in to whether just references can easily be copied over from a .csproj.
LINQPad is awesome and I also manually import projects occasionally. I haven't heard Mr. Albahari mention anything about "Import Project" functionality. And I'd be surprised if he would be interested in implementing something like this anytime soon.
Of course, he is very receptive to suggestions so I recommend posting your idea in his Nutshell forum which he frequents.
Additionally, check out the TypeSerializer in Service Stack libraries. I believe its Dump extension method is wrapped by LINQPad's which then encodes the output in XHTML. It might just be easier for you to use it directly in your code.

visual studio macro to execute a file from the solution

I wrote a small tool which sits in my solution (as a project), which runs in the background and helps me debug my main project.
I'd like to run the tool with a macro but I haven't found how to get the build path and execute it in the background.
Any VB macro experts ?
To answer your question partly, apparently you can get the solution path from within a macro like this:
System.IO.Path.GetDirectoryName(DTE.Solution.FullName)
I found this in some of the macros listed here. Since you say you've got a project within that solution, you could try DTE.Solution.FindProjectItem and progress from there. It's difficult to give more information without knowing more details about your exact scenario.

Can I rename a dataset in the VS 2005 properties window and have this refactor through my code?

I tried the above but when I attempted to rebuild I received errors as the compiler couldn't find the dataset by it's old name.
I know it might be lazy, but I'm used to being able to rename an item in it's properties window and have the refactoring happen silently behind the scenes for me. Is there a way I can do the same thing with a dataset or should I use the find and replace function (along with a fair bit of double checking). My project isn't especailly big so find-replace-check won't take to long but I might need to do it on bigger projects in future
G
EDIT: Attempting the below solution gives the following error
The file 'DataSet.cs' could not be refactored. The current object is auto-generated and only supports renaming through the DataSet Designer.
I would think that the VS2005 refactoring rename that's built in would handle this. Right-click an instance the object name in the code editor and select rename.
You can look here for further info: http://msdn.microsoft.com/en-us/library/ms379618.aspx#vs05_refac_topic8

Resources