omnisharp-vscode/snippets/csharp.json

478 строки
13 KiB
JSON
Исходник Обычный вид История

2015-12-03 13:25:00 +03:00
{
2017-05-06 06:52:59 +03:00
"Attribute using recommended pattern": {
"prefix": "attribute",
"body": [
"[System.AttributeUsage(System.AttributeTargets.${1:All}, Inherited = ${2:false}, AllowMultiple = ${3:true})]",
"sealed class ${4:My}Attribute : System.Attribute",
2017-05-06 06:52:59 +03:00
"{",
" // See the attribute guidelines at",
" // http://go.microsoft.com/fwlink/?LinkId=85236",
" readonly string positionalString;",
" ",
" // This is a positional argument",
" public ${4:My}Attribute(string positionalString)",
2017-05-06 06:52:59 +03:00
" {",
" this.positionalString = positionalString;",
" ",
" // TODO: Implement code here",
" ${5:throw new System.NotImplementedException();}",
2017-05-06 06:52:59 +03:00
" }",
" ",
" public string PositionalString",
" {",
" get { return positionalString; }",
" }",
" ",
" // This is a named argument",
" public int NamedInt { get; set; }",
"}"
],
"description": "Attribute using recommended pattern"
},
"Checked block": {
"prefix": "checked",
"body": [
"checked",
"{",
" $0",
"}"
],
"description": "Checked block"
},
"Class": {
"prefix": "class",
"body": [
"class ${1:Name}",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "Class"
},
"Console.WriteLine": {
"prefix": "cw",
"body": [
"System.Console.WriteLine($0);"
],
"description": "Console.WriteLine"
},
"do...while loop": {
"prefix": "do",
"body": [
"do",
"{",
" $0",
"} while (${1:true});"
2017-05-06 06:52:59 +03:00
],
"description": "do...while loop"
},
"Else statement": {
"prefix": "else",
"body": [
"else",
"{",
" $0",
"}"
],
"description": "Else statement"
},
"Enum": {
"prefix": "enum",
"body": [
"enum ${1:Name}",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "Enum"
},
"Implementing Equals() according to guidelines": {
"prefix": "equals",
"body": [
"// override object.Equals",
"public override bool Equals(object obj)",
2017-05-06 06:52:59 +03:00
"{",
" //",
" // See the full list of guidelines at",
" // http://go.microsoft.com/fwlink/?LinkID=85237",
" // and also the guidance for operator== at",
" // http://go.microsoft.com/fwlink/?LinkId=85238",
" //",
" ",
" if (obj == null || GetType() != obj.GetType())",
" {",
" return false;",
" }",
" ",
" // TODO: write your implementation of Equals() here",
" ${1:throw new System.NotImplementedException();}",
" return base.Equals (obj);",
"}",
"",
"// override object.GetHashCode",
"public override int GetHashCode()",
"{",
" // TODO: write your implementation of GetHashCode() here",
" ${2:throw new System.NotImplementedException();}",
" return base.GetHashCode();",
"}"
],
"description": "Implementing Equals() according to guidelines"
},
"Exception": {
"prefix": "exception",
"body": [
"[System.Serializable]",
"public class ${1:My}Exception : ${2:System.Exception}",
2017-05-06 06:52:59 +03:00
"{",
" public ${1:My}Exception() { }",
" public ${1:My}Exception(string message) : base(message) { }",
" public ${1:My}Exception(string message, System.Exception inner) : base(message, inner) { }",
" protected ${1:My}Exception(",
2017-05-06 06:52:59 +03:00
" System.Runtime.Serialization.SerializationInfo info,",
" System.Runtime.Serialization.StreamingContext context) : base(info, context) { }",
2017-05-06 06:52:59 +03:00
"}"
],
"description": "Exception"
},
"Foreach statement": {
"prefix": "foreach",
"body": [
"foreach (${1:var} ${2:item} in ${3:collection})",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "Foreach statement"
},
"Reverse for loop": {
"prefix": "forr",
"body": [
"for (int ${1:i} = ${2:length} - 1; ${1:i} >= 0 ; ${1:i}--)",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "Reverse for loop"
},
"for loop": {
"prefix": "for",
"body": [
"for (int ${1:i} = 0; ${1:i} < ${2:length}; ${1:i}++)",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "for loop"
},
"if statement": {
"prefix": "if",
"body": [
"if (${1:true})",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "if statement"
},
"Indexer": {
"prefix": "indexer",
"body": [
"${1:public} ${2:object} this[${3:int} index]",
2017-05-06 06:52:59 +03:00
"{",
" get { $4 }",
" set { $0 }",
2017-05-06 06:52:59 +03:00
"}"
],
"description": "Indexer"
},
"Interface": {
"prefix": "interface",
"body": [
"interface I${1:Name}",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "Interface"
},
"Safely invoking an event": {
"prefix": "invoke",
"body": [
"${1:EventHandler} temp = ${2:MyEvent};",
2017-05-06 06:52:59 +03:00
"if (temp != null)",
"{",
" temp($0);",
"}"
],
"description": "Safely invoking an event"
},
"Simple iterator": {
"prefix": "iterator",
"body": [
"public System.Collections.Generic.IEnumerator<${1:ElementType}> GetEnumerator()",
2017-05-06 06:52:59 +03:00
"{",
" $0throw new System.NotImplementedException();",
" yield return default(${1:ElementType});",
2017-05-06 06:52:59 +03:00
"}"
],
"description": "Simple iterator"
},
"Named iterator/indexer pair using a nested class": {
"prefix": "iterindex",
"body": [
"public ${1:Name}Iterator ${1:Name}",
2017-05-06 06:52:59 +03:00
"{",
" get",
" {",
" return new ${1:Name}Iterator(this);",
2017-05-06 06:52:59 +03:00
" }",
"}",
"",
"public class ${1:Name}Iterator",
2017-05-06 06:52:59 +03:00
"{",
" readonly ${2:ClassName} outer;",
2017-05-06 06:52:59 +03:00
" ",
" internal ${1:Name}Iterator(${2:ClassName} outer)",
2017-05-06 06:52:59 +03:00
" {",
" this.outer = outer;",
" }",
" ",
" // TODO: provide an appropriate implementation here",
" public int Length { get { return 1; } }",
" ",
" public ${3:ElementType} this[int index]",
2017-05-06 06:52:59 +03:00
" {",
" get",
" {",
" //",
" // TODO: implement indexer here",
" //",
" // you have full access to ${2:ClassName} privates",
2017-05-06 06:52:59 +03:00
" //",
" ${4:throw new System.NotImplementedException();}",
" return default(${3:ElementType});",
2017-05-06 06:52:59 +03:00
" }",
" }",
" ",
" public System.Collections.Generic.IEnumerator<${3:ElementType}> GetEnumerator()",
2017-05-06 06:52:59 +03:00
" {",
" for (int i = 0; i < this.Length; i++)",
" {",
" yield return this[i];",
" }",
" }",
"}"
],
"description": "Named iterator/indexer pair using a nested class"
},
"Lock statement": {
"prefix": "lock",
"body": [
"lock (${1:this})",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "Lock statement"
},
"MessageBox.Show": {
"prefix": "mbox",
"body": [
"System.Windows.Forms.MessageBox.Show(\"${1:Text}\");$0"
2017-05-06 06:52:59 +03:00
],
"description": "MessageBox.Show"
},
"Namespace": {
"prefix": "namespace",
"body": [
"namespace ${1:Name}",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "Namespace"
},
"#if": {
"prefix": "ifd",
"body": [
"#if ${1:true}",
2017-05-06 06:52:59 +03:00
" $0",
"#endif"
],
"description": "#if"
},
"#region": {
"prefix": "region",
"body": [
"#region ${1:Name}",
2017-05-06 06:52:59 +03:00
" $0",
"#endregion"
],
"description": "#region"
},
"Property and backing field": {
"prefix": "propfull",
"body": [
"private ${1:int} ${2:myVar};",
"public ${1:int} ${3:MyProperty}",
2017-05-06 06:52:59 +03:00
"{",
" get { return ${2:myVar}; }",
" set { ${2:myVar} = value; }",
2017-05-06 06:52:59 +03:00
"}",
"$0"
],
"description": "Property and backing field"
},
"propg": {
"prefix": "propg",
"body": [
"public ${1:int} ${2:MyProperty} { get; private set; }$0"
2017-05-06 06:52:59 +03:00
],
"description": "An automatically implemented property with a 'get' accessor and a private 'set' accessor. C# 3.0 or higher"
},
"prop": {
"prefix": "prop",
"body": [
"public ${1:int} ${2:MyProperty} { get; set; }$0"
2017-05-06 06:52:59 +03:00
],
"description": "An automatically implemented property. C# 3.0 or higher"
},
"sim": {
"prefix": "sim",
"body": [
"static int Main(string[] args)",
"{",
" $0",
" return 0;",
"}"
],
"description": "int Main()"
},
"Struct": {
"prefix": "struct",
"body": [
"struct ${1:Name}",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "Struct"
},
"svm": {
"prefix": "svm",
"body": [
"static void Main(string[] args)",
"{",
" $0",
"}"
],
"description": "void Main()"
},
"Switch statement": {
"prefix": "switch",
"body": [
"switch (${1:switch_on})",
2017-05-06 06:52:59 +03:00
"{",
" $0",
" default:",
"}"
],
"description": "Switch statement"
},
"Try finally": {
"prefix": "tryf",
"body": [
"try",
"{",
" $1",
2017-05-06 06:52:59 +03:00
"}",
"finally",
"{",
" $0",
"}"
],
"description": "Try finally"
},
"Try catch": {
"prefix": "try",
"body": [
"try",
"{",
" $1",
2017-05-06 06:52:59 +03:00
"}",
"catch (${2:System.Exception})",
2017-05-06 06:52:59 +03:00
"{",
" $0",
" throw;",
"}"
],
"description": "Try catch"
},
"Unchecked block": {
"prefix": "unchecked",
"body": [
"unchecked",
"{",
" $0",
"}"
],
"description": "Unchecked block"
},
"Unsafe statement": {
"prefix": "unsafe",
"body": [
"unsafe",
"{",
" $0",
"}"
],
"description": "Unsafe statement"
},
"Using statement": {
"prefix": "using",
"body": [
"using (${1:resource})",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "Using statement"
},
"While loop": {
"prefix": "while",
"body": [
"while (${1:true})",
2017-05-06 06:52:59 +03:00
"{",
" $0",
"}"
],
"description": "While loop"
},
"constructor": {
"prefix": "ctor",
"body": [
"${1:public} ${2:ClassName}(${3:Parameters})",
"{",
" $0",
2017-05-06 06:52:59 +03:00
"}"
],
"description": "constructor"
},
"xUnit Test": {
2017-05-06 06:52:59 +03:00
"prefix": "fact",
"body": [
"[Fact]",
"public void ${1:TestName}()",
2017-05-06 06:52:59 +03:00
"{",
"//Given",
"",
"//When",
"",
"//Then",
"}$0"
2017-05-06 06:52:59 +03:00
],
"description": "create xunit test method"
}
}