Add a set of Namespaces to every Class file? - visual-studio-2010

Often when working in VS2010 I find that I have a list of namespaces I want in all files. For example
using Common.Logging;
Is there a way I can configure this, preferably at a project or solution level?

There really isn't something built-in to do that. You can edit the Class.zip file in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache\CSharp\Code\1033 to change the usings in the default class created by "Add Class".
You might want to consider using a custom snippet instead of "add class" if you want something project/solution specific.

Related

HowTo get all interfaces types from visual studio solution?

I'm trying to write an extension to visual studio.
I need to get a list of all the interfaces types found in all the projects in the current opened solution.
So far i have tried doing this using the EnvDev namespace.
Is there a way of doing this without parsing the project's .cs files ?
Thanks,
Chai.

What type of extension for VS (and how) to make, to generate C# or C++ code from some text [more so a model]?

I am new to Visual Studio Extensibility and want to make an addin/extension which shall do the following:
It should read all the files with a specific file extension (assume "*.ump").
It should process the text/code/whatever in the files.
It should create new Class/Code file with some code in it. [The code will be produced in step 2, just need to know how to do it?]
Yet, I have been racking my brains through extensibility, saw the single file generators .... and addins which go through ProjectItems and can detect the file extension,
BUT I HAVE NOT BEEN ABLE TO FIND a complete tutorial, guide or explanation as to how or what to do!!
Please help...
You don't want to read all files with a specific file extension in Visual C++ project nor standard Visual C# project. You may do that with hand-made MSBuild project (included in the solution).
In Visual C++ projects, there is a way to define custom tools. They are run as separate processes, so you can implement them in anything you want. Studio will ask you whether you want to define a tool (they are defined in special xml files; studio has dialog for editing them) when you add a file with extension unknown to it. In Visual C# projects, just manually write a MSBuild tasks and insert them into the project.
Do whatever you want. IIRC the generated files will have to be included in the project though. Well, for MSBuild, just tweak the project to your heart's desire, but in Visual C++ they have to.
You can combine MSBuild (csproj,vbproj) and VisualC++ projects in a single solution, so I recommend using separate.
If you ever find out you need to compile for different target where you can't use Visual Studio, you'll be glad that you have stand-alone tool you were just calling from Studio and not something that embeds in it.

Vs2010 using log4net with Intellisense

I'm using vs2010 and I need to log a multithreading application.
So I decided to use log4net, but as I'm not used to work with this, Intellisense is gonna be worth.
I download the .xsd from http://csharptest.net/downloads/schema/log4net.xsd and put this in VSFolder/Xml/Schemas.
But, how can I say to my log4net.config to use the XSD Schema?
Use the menu XML -> Schemas...
The menu is only there if you have the config file (or any other xml file) open.
Instead of putting it into a VS folder, put it somewhere inside your solution's folder tree. It doesn't even need to be included in any projects. just put it there and it works...
Or into: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas and you're sorted once and forever.

Visual Studio Go to Definition

Go To definition in Visual studio 2005 works only for files that are in my project. It never works for files that are included in external libraries like mfc. When I say Go To Definition for mfc function it always shows me the header file . Is this expected behavior?
And also how does this whole thing Go To Definition work?
Thanks
I'd make the small investment required in Visual Assist. Besides all the great features it offers, it has the Alt+G command which works way better than the Visual Studio go to definition :)
For the MFC source files (at least the Feature Pack ones) I learned to find out what folder are they in (usually at C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc) and add that folder to the Find in Files dialog.
It's not as direct as Go to Definition, and you may have to browse among the find results, but it works...
Note: I second #flippy's answer of Visual Assist, it's really great.
External libraries are references to their compiled DLLs rather than the source when referencing your own projects.
The idea is that you don't need any more than the interface to external classes, but, if you would like to see the internals of DLLs you can use a tool such as Reflector.
Yes only the interfaces for MFC will be given in header file.Unless it is implemented with Template you will not be able to access the actual definition.The dlls have implementation for those interfaces.
Well if you think about it logically, as far as visual studio knows the only definition of the MFC object that is available is the definition it sees in the associated MFC header file, so unless you actually have the entire source for MFC it won't be able to look anywhere else.
The way that intellisense/go to definition works is via a file that is created when you compile the application. It stores a mapping between variables/functions and where they are declared (or could potentially be declared, in polymorphic situations), and when you right click to say "go to definition" it references that file.
Yes this is the expected behavior. Only the declarations (header files) of the MFC code are available on your box and hence that is the only location that it can take you to.
What are you expecting it to show?

How to NOT include Visual Studio Project folder names in generated namespaces

How do I prevent the name of the Solution Folder in a VS project from being appended to the namespace generated for new items added to the solution folder?
Example: C# project in a VS solution
Default Namespace set in C# project properties: "BigClient.Domain"
If you create a solution folder in this project called "MySpecialStuff" and then add a new class to the 'MySpecialStuff" solution folder, VS creates the new .cs file with a "BigClient.Domain.MySpecialStuff" namespace. I want to find a way to allow the namespace of the newly-added class to retain just the 'project-level' namespace of "BigClient.Domain" instead of VS appending the "MySpecialStuff" solution-folder-name to the namespace.
I seem to recall reading a blog post by someone that this was possible (either via options/settings in VS or a registry setting) but I cannot recall where or how now that I want it :)
My platform is VS 2008 if answer = different for different VS versions.
If you have ReSharper installed, on the settings for the directory (F4), set Namespace Provider to false.
Make a new class template or change Visual Studio's class template. See the MSDN documentation for how to this. In the template file, you quickly see the line that inserts the 'safe' namespace name.

Resources