Geeks With Blogs

News



Add to Google

Tim Hibbard CEO for EnGraph software

Can somebody please make a Visual Studio add-in that will define the properties of a structure, so that when I type:

Public Structure Coordinates
  
Private _lat As Double
  
Private _lon As Double

It will automatically create this:

Public Property Lat() As Double
  
Get
     
Return _lat
   End
Get
  
Set(ByVal Value As Double)
      _lat = Value
   End
Set
End Property

Public Property Lon() As Double
  
Get
     
Return _lon
   End
Get
  
Set(ByVal Value As Double)
      _lon = Value
   End
Set
End Property

That would save me a truckload of time.

Posted on Friday, September 2, 2005 4:10 PM .NET | Back to top


Comments on this post: Tired of defining structure properties

# re: Tired of defining structure properties
Requesting Gravatar...
A macro like this should get you some of the way. It's a quick and dirty record of my keystrokes so YMMV. Simply type your private declaration like:

Private _This as string

Select the entire line and run the macro:

Option Strict Off
Option Explicit Off
Imports EnvDTE
Imports System.Diagnostics

Public Module RecordingModule


Sub BuildPropertyFromPrivate()
DTE.ActiveDocument.Selection.EndOfLine(True)
DTE.ActiveDocument.Selection.Copy()
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.CharRight()
DTE.ActiveDocument.Selection.Paste()
DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
DTE.ActiveDocument.Selection.WordRight(True)
DTE.ActiveDocument.Selection.Text = "Public Property "
DTE.ActiveDocument.Selection.Delete()
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.CharRight()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Text = "End Property"
DTE.ActiveDocument.Selection.CharRight()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.LineUp(False, 2)
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Text = "Get"
DTE.ActiveDocument.Selection.CharRight()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Text = "End Get"
DTE.ActiveDocument.Selection.CharRight()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Text = "Set (Value as "
DTE.ActiveDocument.Selection.Paste()
DTE.ActiveDocument.Selection.WordLeft(False, 4)
DTE.ActiveDocument.Selection.WordRight(True, 3)
DTE.ActiveDocument.Selection.Delete()
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.Text = ")"
DTE.ActiveDocument.Selection.CharRight()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Text = "End Set"
DTE.ActiveDocument.Selection.CharRight()
DTE.ActiveDocument.Selection.LineUp(False, 3)
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Text = "return"
DTE.ActiveDocument.Selection.Text = " "
DTE.ActiveDocument.Selection.Paste()
DTE.ActiveDocument.Selection.WordLeft(False, 3)
DTE.ActiveDocument.Selection.WordLeft(True)
DTE.ActiveDocument.Selection.Delete()
DTE.ActiveDocument.Selection.WordRight()
DTE.ActiveDocument.Selection.WordRight(True, 2)
DTE.ActiveDocument.Selection.Delete()
DTE.ActiveDocument.Selection.CharRight()
DTE.ActiveDocument.Selection.LineDown(False, 2)
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Paste()
DTE.ActiveDocument.Selection.WordLeft(False, 3)
DTE.ActiveDocument.Selection.WordLeft(True)
DTE.ActiveDocument.Selection.Delete()
DTE.ActiveDocument.Selection.WordRight()
DTE.ActiveDocument.Selection.WordRight(True, 2)
DTE.ActiveDocument.Selection.Text = "= Value"
DTE.ActiveDocument.Selection.CharRight()
DTE.ActiveDocument.Selection.LineDown(False, 2)
End Sub
End Module
Left by Hal Lesesne on Sep 02, 2005 5:24 PM

# re: Tired of defining structure properties
Requesting Gravatar...
try coderush
Left by onur BIYIK on Sep 03, 2005 2:26 PM

Your comment:
 (will show your gravatar)


Copyright © Tim Hibbard | Powered by: GeeksWithBlogs.net