开发者

Visual Studio: Is it possible to define custom functions for use in one's own Code Snippets?

开发者 https://www.devze.com 2022-12-20 09:30 出处:网络
I want to write a Visual Studio snippet which allows me to quickly create a class of the form: public SomeClass

I want to write a Visual Studio snippet which allows me to quickly create a class of the form:

public SomeClass
{
    public SomeType SomeProperty { get; private set; }
    public SomeClass(SomeType someProperty) { SomeProperty = someProperty; }
}

I want the parameter on the constructor to have the same name as the property, but lower-cased. I don't want to have to type the name twice. How do I do this?

I've already looked at the XML for snippets and I discovered that there are certain functions that can be used. For example, the built-in "switch" code snippet contains the following instruction:

<Function>GenerateSwitchCases($expression$)</Function>

According to this MSDN documentation page, there are three built-in functions that you can use in this <Function> tag. Unfortunately, neither of them does what I want (lower-case the first letter). Is it possible to define a function that I can then use in m开发者_如何学运维y snippet?


No this is not possible in Visual Studio today. The definition and execution of snippet functions is directly controlled by the C# language service. It is not currently an extensibility point. It is being considered for a future version of the product though.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号