Brian Schmitt
Brian Schmitt

Reputation: 6068

Visual Studio Macro - Code Gen Language

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?

Upvotes: 1

Views: 1257

Answers (2)

Brian Schmitt
Brian Schmitt

Reputation: 6068

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

DTE.ActiveDocument.Language = "CSharp"

Upvotes: 2

Gulzar Nazim
Gulzar Nazim

Reputation: 52178

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.

Upvotes: 4

Related Questions