genericは結構エロイ
src: class A<T> where T : A<T> { static A() { Console.WriteLine("init:" + typeof(T).Name); } } class AA : A<AA> { } class BB : A<BB> { } class CC : A<Program> { } //err! class Program { static void Main(string[] args) { AA a = new AA(); BB b = new BB(); } } display: init:AA init:BB
なんてコードも難なく通る。こいつは使えるぜ!
制約条件のあたりがトリッキー。ぐるぐる。
nimpl
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>nimpl</Title> <Shortcut>nimpl</Shortcut> <Description>throw NotImplementedException</Description> <Author>gnarl</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>descr</ID> <Default>this method is not implemented.</Default> <ToolTip>description</ToolTip> </Literal> </Declarations> <Code Language="csharp"><![CDATA[throw new NotImplementedException("$descr$");$selected$$end$ ]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>