Macro help please

Macro help please

Post by Adam Hear » Thu, 17 Mar 2005 18:57:48


New to VS.NET 2003 macros but have a simple question... Is there anyway to
obtain (or infer) the current method name when executing a macro?

I'd want to use it in a macro to place a temporary trace line in the code
that contains the name of the method. I could use reflection to get the name
of the method at runtime but I'd like to know if this is possible using
macros in the IDE.

Thanks in advance!
 
 
 

Macro help please

Post by Carlos J. » Thu, 17 Mar 2005 20:31:15

You can use the (somewhat buggy) FileCodeModel.CodeElementFromPoint()
passing vsCMElement.vsCMElementFunction as 2nd parameter, and then use
CodeElement.Name.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.yqcomputer.com/


"Adam Hearn" < XXXX@XXXXX.COM > escribien el mensaje
>> New to VS.NET 2003 macros but have a simple question... Is there anyway to >> obtain (or infer) the current method name when executing a macro? >> >> I'd want to use it in a macro to place a temporary trace line in the code >> that contains the name of the method. I could use reflection to get the >> name >> of the method at runtime but I'd like to know if this is possible using >> macros in the IDE. >> >> Thanks in advance! >> >>

 
 
 

Macro help please

Post by Adam Hear » Thu, 17 Mar 2005 23:09:21

Thx for that!

Well it works... for the 1st time only - subsequent calls just hang the
Macro Server. Remove the calls to FileCodeModel and it always works! Oh well
:(

"Carlos J. Quintero [.NET MVP]" < XXXX@XXXXX.COM > wrote in

>>>> New to VS.NET 2003 macros but have a simple question... Is there anyway
to >>>> obtain (or infer) the current method name when executing a macro? >>>> >>>> I'd want to use it in a macro to place a temporary trace line in the
code >>>> that contains the name of the method. I could use reflection to get the >>>> name >>>> of the method at runtime but I'd like to know if this is possible using >>>> macros in the IDE. >>>> >>>> Thanks in advance! >>>> >>>> >> >>