
Signature
Mike Kozlowski
http://www.klio.org/mlk/
I use the following macro in VS.NET 2003 (probably works
in 2002 as well). Just go to the Macro Explorer and go
into the editor, and paste this in:
Sub CSAddProperty()
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.StartOfLine
(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
DTE.ActiveDocument.Selection.WordRight()
DTE.ActiveDocument.Selection.EndOfLine(True)
DTE.ActiveDocument.Selection.WordLeft(True)
DTE.ActiveDocument.Selection.Copy()
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "public "
DTE.ActiveDocument.Selection.Paste()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "{"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "get {
return "
DTE.ActiveDocument.Selection.Paste()
DTE.ActiveDocument.Selection.Text = "; } }"
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "set { "
DTE.ActiveDocument.Selection.Paste()
DTE.ActiveDocument.Selection.Text = " = vale"
DTE.ActiveDocument.Selection.DeleteLeft()
DTE.ActiveDocument.Selection.Text = "ue; }"
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.StartOfLine
(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.WordLeft(False, 3)
DTE.ActiveDocument.Selection.StartOfLine
(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, True)
DTE.ActiveDocument.Selection.WordRight(True, 3)
DTE.ActiveDocument.Selection.DeleteLeft()
DTE.ActiveDocument.Selection.StartOfLine
(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn)
DTE.ActiveDocument.Selection.LineDown()
DTE.ActiveDocument.Selection.StartOfLine
(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.WordLeft(False, 5)
DTE.ActiveDocument.Selection.StartOfLine
(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, True)
DTE.ActiveDocument.Selection.WordRight(True, 2)
DTE.ActiveDocument.Selection.DeleteLeft()
DTE.ActiveDocument.Selection.LineDown(False, 2)
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.StartOfLine
(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn)
End Sub
This isn't a very smart macro, I'll warn you, but for
simple data types it usually does most of the busywork
for me. I put the cursor over a data definition and then
invoke it. I still have to modify the property name but
it works all right.
If any one requests, I also have macros to:
- add properties in C++
- blindly add code comments in C++ (not intelligently at
all)
- Wrap the current line with the "undef new" style
pragmas.
- add a region in C#
- make a region for a property in C#
--Todd C. Gleason
>-----Original Message-----
>Developing in C# with VS.NET 2002, I want to create properties to
[quoted text clipped - 4 lines]
>
>Can anyone point me at what I'm missing?