If I was to have:
/// <summary>
/// My summary
/// </summary>
/// <param name='args'></param>
on the clipboard pasted it on top of the method static void Main(string[] args)
, it will look like:
class Program
{
/// <summary>
/// This is my summary
/// </summary>
/// <param name='args'></param>
static void Main(string[] args)
{
}
}
Note: The text I had on the clipboard had no indentation (4 white spaces on the left). When I pasted it, Visual Studio was able to figure out that it needed indentation.
I would like to do the same thing with a macro. I do not want to use the clipboard as I have the text I want to insert in a variable (myText
). I have something like:
Sub TemporaryMacro()
Dim myText As String = "/// <summary>" _
& vbCrLf & "/// My summary" _
& vbCrLf & "/// </summary>" _
& vbCrLf & "/// <param name='args'></param>"
DTE.ActiveDocument.Selection.Text = myText
End Sub
When I run that macro I end up with:
class Program
{
/// <summary>
/// <summary>
/// /// My summary
/// /// </summary>
/// /// <paramref name=" name='args'></param>"/></summary>
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
}
}
Note: I do get a different result.
I have also tried:
Public Module RecordingModule
Sub TemporaryMacro()
Dim myText As String = "/// <summary>" _
& vbCrLf & "/// My summary" _
& vbCrLf & "/// </summary>" _
& vbCrLf & "/// <param name='args'></param>"
DTE.ActiveDocument.Selection.Insert(myText)
End Sub
End Module
which results in:
class Program
{
/// <summary>
/// My summary
/// </summary>
/// <param name='args'></param>
static void Main(string[] args)
{
}
}
I know I can place myText
on the clipboard and then paste it. That does not make sense though. How can I achieve the same behavior as if I where pasting myText
without having it to place it on the clipboard?