Creating a new Guid inside a code snippet using c#
c#, code-snippets
Solution
This is what I did instead with a VS Macro
Public Sub InsertPartialGuid()
Dim objSel As TextSelection = DTE.ActiveDocument.Selection
Dim NewGUID As String = String.Format("{0}", (System.Guid.NewGuid().ToString().ToUpper().Split("-")(0)))
objSel.Insert(NewGUID, vsInsertFlags.vsInsertFlagsContainNewText)
objSel = Nothing
End Sub
Problem
I want to make an intellisense code snippet using Ctl K + Ctl X that actually executes code when it runs... for example, I would like to do the following: ``` <![CDATA[string.Format("{MM/dd/yyyy}", System.DateTime.Now);]]> ``` But rather than giving me that string value, I want the date in the format specified. Another example of what I want is to create a new Guid but truncate to the first octet, so I would want to use a create a new Guid using System.Guid.NewGuid(); to give me {798400D6-7CEC-41f9-B6AA-116B926802FE} for example but I want the value: 798400D6 from the code snippet. I'm open to not using an Intellisense Code Snippet.. I just thought that would be easy.