更改代码段中文字的顺序
本文关键字:顺序 文字 段中 代码 | 更新日期: 2023-09-27 18:20:15
我生成了一个简单函数的代码片段
function
是:-
/// <summary>
/// Description
/// </summary>
public static int function(int obj)
{
return obj;
}
代码的Snippet
是:-
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Keywords>
<Keyword>fpub</Keyword>
</Keywords>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>fpub</Title>
<Author>shaveta.drake@hotmail.com</Author>
<Description>Generate public method</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>fpub</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>function</ID>
<ToolTip>Name of Function</ToolTip>
<Default>function</Default>
<Function>First Argument</Function>
</Literal>
<Literal Editable="true">
<ID>obj</ID>
<ToolTip>obj</ToolTip>
<Default>obj</Default>
<Function>Second Argument</Function>
</Literal>
<Literal Editable="true">
<ID>int</ID>
<ToolTip>Datatype</ToolTip>
<Default>int</Default>
<Function>Third Argument</Function>
</Literal>
<Literal Editable="true">
<ID>Description</ID>
<ToolTip>Description</ToolTip>
<Default>Description</Default>
<Function>Fourth Argument</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[/// <summary>
/// $Description$
/// </summary>
public static $int$ $function$($int$ $obj$)
{
return $obj$;
}]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
当我实现snippet
时,
默认订单以描述、开头
而我想从功能开始
那么我有没有办法管理文字的顺序。
在浏览了MSDN文档中的代码片段后,我得出结论,<Code>
元素中对象/文字的外观决定了使用代码片段时的顺序。也就是说,据我所知,你不能更改订单。
我需要为复杂属性创建代码片段,其中文字的顺序对用户非常重要。我在生成的代码上方创建了注释行,其中的文字按要求的顺序使用。
重要部件
...
<Code Language="csharp">
<![CDATA[
// Cfg: $type$ $configname$ def: $defaultvalue$ desc: $description$ cat: $category$ resName: LocDesc_$configname$
/// <summary>
/// $description$
/// </summary>
[LocalizedCategory("$category$", "LocCat_$category$")]
[DefaultValue($defaultvalue$)]
[LocalizedDescription("$description$", "LocDesc_$configname$")]
public $type$ $configname$
{
...
完整的片段
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Localized config item</Title>
<Shortcut>lcfg</Shortcut>
<Description>
Code snippet for an automatically implemented property in Configuration class
</Description>
<Author>Arkance Development</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>configname</ID>
<ToolTip>Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
<Literal>
<ID>defaultvalue</ID>
<ToolTip>Default property value</ToolTip>
<Default>DefaultValue</Default>
</Literal>
<Literal>
<ID>description</ID>
<ToolTip>Property description</ToolTip>
<Default>description</Default>
</Literal>
<Literal>
<ID>category</ID>
<ToolTip>Property category</ToolTip>
<Default>General</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
// Cfg: $type$ $configname$ def: $defaultvalue$ desc: $description$ cat: $category$ resName: LocDesc_$configname$
/// <summary>
/// $description$
/// </summary>
[LocalizedCategory("$category$", "LocCat_$category$")]
[DefaultValue($defaultvalue$)]
[LocalizedDescription("$description$", "LocDesc_$configname$")]
public $type$ $configname$
{
[DebuggerStepThrough()]
get
{
string settingName = "$configname$";
$type$ defaultValue = $defaultvalue$;
$type$ retVal = GetSetting(settingName, defaultValue);
return retVal;
}
[DebuggerStepThrough()]
set
{
string settingName = "$configname$";
SetSetting(settingName, value);
}
}
$end$
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>