Custom snippet with DateTime.Now

I am trying to create a small custom code snippet for my C # code in VS2010. It basically inserts a block of comments for informational purposes. Inside this code, although I want the current date to be automatically inserted when inserting the fragment.

Here is the current snippet that I have:

<CodeSnippet Format="1.0.0"> <Header> <Title> C# Class Comments </Title> <Shortcut>ccom</Shortcut> </Header> <Snippet> <Declarations> <Object> <ID>DateTime</ID> <Type>System.DateTime</Type> <Function>DateTime.Now()</Function> </Object> <Literal> <ID>Author</ID> <ToolTip>Replace with name creator of class.</ToolTip> <Default>"Author name"</Default> </Literal> <Literal> <ID>Date</ID> <ToolTip>Replace with date class was created</ToolTip> <Default>"Date"</Default> </Literal> <Literal> <ID>Modified</ID> <ToolTip>Replace with modified date of class</ToolTip> <Default>"Modified"</Default> </Literal> <Literal> <ID>Description</ID> <ToolTip>Replace with a short description of what the class is used for</ToolTip> <Default>"Description"</Default> </Literal> </Declarations> <Code Language="CSharp"> <![CDATA[ //*******************************************************************************; // Author: $Author$ // Created Date: $DateTime$ // Modified Date: $Modified$ // Description: $Description$ //*******************************************************************************; ]]> </Code> </Snippet> </CodeSnippet> 

What do I need to do to insert the date when the fragment was inserted into the code?

+4
source share
1 answer

This, unfortunately, is not real. Snippet Visual Studio does not support replacement macros for items such as current date / time

+6
source

Source: https://habr.com/ru/post/1393544/


All Articles