How can I Enumerate Projects/Files in a Visual Studio Solution Extension? - visual-studio

I would like to obtain a collection of all .cs files in a solution for analysis from a Visual Studio Extension. There are a couple methods of doing this on SO, but these are outdated and clunky. Specifically, they utilize old COM compatibility libraries, and require casting and inspecting GUIDs stored as strings.
How do I list all the projects in the current solution using EnvDTE?
Enumerate all files in current visual studio project
Visual Studio Extension get all classes and interfaces metadata
Any method which also gives access to some parse tree would be especially useful (in my case).

Related

Convert Visual Studio exe-project in lib-project

I am developing an application (exe) in c++ with visual studio. I am not that experienced. Now, I came to the conclusion that it might be better to compile the general program functionality into an lib or dll file, which I then would use in a different visual studio project, where I basically implement the functions from the lib files for the more specific purpose of my project. With my current setup, I get the impression that I am starting to mix the gerenal functionality with the specific problem statement.
Basically I am asking for a way to convert my current full visual studio project into two separate projects, one for the gerenal lib files representing the classes and program modules, and one for the specific problem implementation. Is it possible to also keep everything in one visual studio project (edit: solution) for convenience?

What is the difference between Reference Assemblies and Public Assemblies in Visual Studio

I have been investigating some issues with Web Performance Test Plugins in Visual Studio 2013. When adding references to the necessary dlls (e.g. Microsoft.VisualStudio.QualityTools.WebTestFramework.dll) I noticed that there are multiple entries for the same dll available in the 'Add References' window. On my system I have five choices for WebTestFramework.
Some of these I see are from earlier versions of Visual Studio which are also installed on my machine. However, I see that some are duplicates, e.g.:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\WebTestFramework.dll
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\WebTestFramework.dll
I've compared the hashes of these two files and they are identical. So, why are they present in my VS 2013 (v12.0) installation twice? Why is there both a 'ReferenceAssemblies' and a 'PublicAssemblies' folder?
Well, ideally the implementation assembly doesn't appear in the list. But the control over what appears in the list isn't fine-grained enough, it can only be configured by directory, not individual assemblies. A further constraint is that Microsoft is often forced to pick less than desirable storage locations for an assembly to maintain backwards compatibility with previous VS versions so they don't break existing projects. And the test frameworks have changed a great deal through the VS versions, took them a while to get all the quirks ironed out.
Always pick the reference assembly when one is offered. They are meant to isolate you from these rapid changes and often intentionally are not a copy of the implementation assembly. You'll get it to work when you pick the implementation assembly but you risk having your test project broken in the next VS version. YMMV.

How can I make Visual Studio update namespaces when I move classes?

I remember that when I worked with Java tools, I could easily reorganise classes and packages by dragging and dropping them in the IDE. This would automatically update namespaces to match the new file system structure.
In the .NET world, I believe the .NET languages' specifications don't require namespaces to match folder structure. However, I would still like to be able to move class files, or even namespaces, around, and have Visual Studio automatically update the namespaces correspondingly.
How can I achieve this? I'm more interested in a Visual Studio 2010 solution, but I still consider answers for other versions acceptable.

Get a list of projects/references within a Visual Studio 2010 Extension

I'm creating a Visual Studio 2010 extension package (Microsoft.VisualStudio.Shell.Package) that needs to analyze all of the projects and those project's references. I would assume that this is done with a service (e.g. Package.GetService(typeof(IMenuCommandService))). What I need is the interface that contains the functionality to get a list of projects and references for those projects. Also, any advice on where to find a reference that contains the available interfaces within visual studio would be much appreciated.
Note that I've seen multiple people trying to do something similar using DTE from a macro. That's not what I'm trying to do. I'm trying to do the same thing from within a Visual Studio Extension.
So even though you're doing this as part of an extension, you'll still need to use the DTE APIs to get all of the information you want. It may seem backwards but that's just how it works. You should grab the DTE object via (EnvDTE.DTE)Package.GetService(typeof(SDTE)). Once you have a EnvDTE.Project, access it's Object member and cast that to a VSLangProj.VSProject if it's a C# or VB project. This has the reference information you need.

Visual Studio 2010 localization resource files, how to add in strings automatically?

I have a certain project that has a resource directory with a .resx for each language supported in the product.
Right now I am adding these strings by hand using the visual studio 2010 IDE, but because there are a large number of strings, this manual management of these resources can get tricky, and something can easily get omitted in perhaps just 1 .resx file.
Do you get a good resource addon for visual studio 2010, that will allow you to sync and validate a group of resx files? The built in functionality for handling resx seems the same as it was in 2008, and requires a lot of manual effort.
I guess what would be nice would be to have the ability to define all resources in the main language, then have these strings carried across to the remaining languages automatically.
Does such functionality exist? Even a good codeplex project perhaps?
For those of you guys with the same problem I found this - http://zetaresourceeditor.codeplex.com/, seems very good.
Visual Localizer is free, supports snychronization of resource files (among other things) and works in Visual Studio 2010 (also in 2008 and 2012).

Resources