views:

374

answers:

2

I am writing a macro for Visual studio that will generate some code.

I would like for the macro to generate for both C# and VB, is there a way to determine what language is being used in the active (current) document?

+4  A: 

Have you considered using T4?

T4 is a code generator built right into Visual Studio. If you're using C#, you'll have a sub .cs file, or if you're using VB, a sub .vb file. That's the file that will hold the result of the generation. This is the same visual metaphor used to the express the template/generated file relationship with .designer files you've seen elsewhere in Visual Studio.

Gulzar
Yes I am aware of T4. In this case I need a macro to bind to a shortcut key.
Brian Schmitt
A: 

I just located a bit of code, it seems that it's a hidden property:

DTE.ActiveDocument.Language = "CSharp"
Brian Schmitt