summaryrefslogtreecommitdiff
path: root/luasnip_snippets/csharp.json
diff options
context:
space:
mode:
authorVito G. Graffagnino <vito@graffagnino.xyz>2022-09-04 16:08:53 +0100
committerVito G. Graffagnino <vito@graffagnino.xyz>2022-09-04 16:08:53 +0100
commit02af2c0299b923946092a49cdbae20ba837cb4be (patch)
tree23fcf489571530124a7faf0975170ba976fc2c18 /luasnip_snippets/csharp.json
parent9c43c4fe5a8e913fc85caa37922e420d4bf2ee1b (diff)
latex tweaks
Diffstat (limited to 'luasnip_snippets/csharp.json')
-rw-r--r--luasnip_snippets/csharp.json396
1 files changed, 396 insertions, 0 deletions
diff --git a/luasnip_snippets/csharp.json b/luasnip_snippets/csharp.json
new file mode 100644
index 0000000..2cde7e5
--- /dev/null
+++ b/luasnip_snippets/csharp.json
@@ -0,0 +1,396 @@
+{
+ "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",
+ "{",
+ " // 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)",
+ " {",
+ " this.positionalString = positionalString;",
+ " ",
+ " // TODO: Implement code here",
+ " ${5:throw new System.NotImplementedException();}",
+ " }",
+ " ",
+ " 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}", "{", " $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});"],
+ "description": "do...while loop"
+ },
+ "Else statement": {
+ "prefix": "else",
+ "body": ["else", "{", " $0", "}"],
+ "description": "Else statement"
+ },
+ "Enum": {
+ "prefix": "enum",
+ "body": ["enum ${1:Name}", "{", " $0", "}"],
+ "description": "Enum"
+ },
+ "Implementing Equals() according to guidelines": {
+ "prefix": "equals",
+ "body": [
+ "// override object.Equals",
+ "public override bool Equals(object obj)",
+ "{",
+ " //",
+ " // 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}",
+ "{",
+ " 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(",
+ " System.Runtime.Serialization.SerializationInfo info,",
+ " System.Runtime.Serialization.StreamingContext context) : base(info, context) { }",
+ "}"
+ ],
+ "description": "Exception"
+ },
+ "Foreach statement": {
+ "prefix": "foreach",
+ "body": [
+ "foreach (${1:var} ${2:item} in ${3:collection})",
+ "{",
+ " $0",
+ "}"
+ ],
+ "description": "Foreach statement"
+ },
+ "Reverse for loop": {
+ "prefix": "forr",
+ "body": [
+ "for (int ${1:i} = ${2:length} - 1; ${1:i} >= 0 ; ${1:i}--)",
+ "{",
+ " $0",
+ "}"
+ ],
+ "description": "Reverse for loop"
+ },
+ "for loop": {
+ "prefix": "for",
+ "body": [
+ "for (int ${1:i} = 0; ${1:i} < ${2:length}; ${1:i}++)",
+ "{",
+ " $0",
+ "}"
+ ],
+ "description": "for loop"
+ },
+ "if statement": {
+ "prefix": "if",
+ "body": ["if (${1:true})", "{", " $0", "}"],
+ "description": "if statement"
+ },
+ "Indexer": {
+ "prefix": "indexer",
+ "body": [
+ "${1:public} ${2:object} this[${3:int} index]",
+ "{",
+ " get { $4 }",
+ " set { $0 }",
+ "}"
+ ],
+ "description": "Indexer"
+ },
+ "Interface": {
+ "prefix": "interface",
+ "body": ["interface I${1:Name}", "{", " $0", "}"],
+ "description": "Interface"
+ },
+ "Safely invoking an event": {
+ "prefix": "invoke",
+ "body": [
+ "${1:EventHandler} temp = ${2:MyEvent};",
+ "if (temp != null)",
+ "{",
+ " temp($0);",
+ "}"
+ ],
+ "description": "Safely invoking an event"
+ },
+ "Simple iterator": {
+ "prefix": "iterator",
+ "body": [
+ "public System.Collections.Generic.IEnumerator<${1:ElementType}> GetEnumerator()",
+ "{",
+ " $0throw new System.NotImplementedException();",
+ " yield return default(${1:ElementType});",
+ "}"
+ ],
+ "description": "Simple iterator"
+ },
+ "Named iterator/indexer pair using a nested class": {
+ "prefix": "iterindex",
+ "body": [
+ "public ${1:Name}Iterator ${1:Name}",
+ "{",
+ " get",
+ " {",
+ " return new ${1:Name}Iterator(this);",
+ " }",
+ "}",
+ "",
+ "public class ${1:Name}Iterator",
+ "{",
+ " readonly ${2:ClassName} outer;",
+ " ",
+ " internal ${1:Name}Iterator(${2:ClassName} outer)",
+ " {",
+ " this.outer = outer;",
+ " }",
+ " ",
+ " // TODO: provide an appropriate implementation here",
+ " public int Length { get { return 1; } }",
+ " ",
+ " public ${3:ElementType} this[int index]",
+ " {",
+ " get",
+ " {",
+ " //",
+ " // TODO: implement indexer here",
+ " //",
+ " // you have full access to ${2:ClassName} privates",
+ " //",
+ " ${4:throw new System.NotImplementedException();}",
+ " return default(${3:ElementType});",
+ " }",
+ " }",
+ " ",
+ " public System.Collections.Generic.IEnumerator<${3:ElementType}> GetEnumerator()",
+ " {",
+ " 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})", "{", " $0", "}"],
+ "description": "Lock statement"
+ },
+ "MessageBox.Show": {
+ "prefix": "mbox",
+ "body": ["System.Windows.Forms.MessageBox.Show(\"${1:Text}\");$0"],
+ "description": "MessageBox.Show"
+ },
+ "Namespace": {
+ "prefix": "namespace",
+ "body": ["namespace ${1:Name}", "{", " $0", "}"],
+ "description": "Namespace"
+ },
+ "#if": {
+ "prefix": "ifd",
+ "body": ["#if ${1:true}", " $0", "#endif"],
+ "description": "#if"
+ },
+ "#region": {
+ "prefix": "region",
+ "body": ["#region ${1:Name}", " $0", "#endregion"],
+ "description": "#region"
+ },
+ "Property and backing field": {
+ "prefix": "propfull",
+ "body": [
+ "private ${1:int} ${2:myVar};",
+ "public ${1:int} ${3:MyProperty}",
+ "{",
+ " get { return ${2:myVar}; }",
+ " set { ${2:myVar} = value; }",
+ "}",
+ "$0"
+ ],
+ "description": "Property and backing field"
+ },
+ "propg": {
+ "prefix": "propg",
+ "body": ["public ${1:int} ${2:MyProperty} { get; private set; }$0"],
+ "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"],
+ "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}", "{", " $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})", "{", " $0", " default:", "}"],
+ "description": "Switch statement"
+ },
+ "Try finally": {
+ "prefix": "tryf",
+ "body": ["try", "{", " $1", "}", "finally", "{", " $0", "}"],
+ "description": "Try finally"
+ },
+ "Try catch": {
+ "prefix": "try",
+ "body": [
+ "try",
+ "{",
+ " $1",
+ "}",
+ "catch (${2:System.Exception})",
+ "{",
+ " $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})", "{", " $0", "}"],
+ "description": "Using statement"
+ },
+ "While loop": {
+ "prefix": "while",
+ "body": ["while (${1:true})", "{", " $0", "}"],
+ "description": "While loop"
+ },
+ "constructor": {
+ "prefix": "ctor",
+ "body": [
+ "${1:public} ${2:$TM_FILENAME_BASE}(${3:Parameters})",
+ "{",
+ " $0",
+ "}"
+ ],
+ "description": "constructor"
+ },
+ "xUnit Test": {
+ "prefix": "fact",
+ "body": [
+ "[Fact]",
+ "public void ${1:TestName}()",
+ "{",
+ "//Given",
+ "",
+ "//When",
+ "",
+ "//Then",
+ "}$0"
+ ],
+ "description": "create xunit test method"
+ },
+ "Creates a Method structure": {
+ "prefix": "method",
+ "body": [
+ "${1:public} ${2:void} ${3:MyMethod}(${4:string} ${5:parameter})",
+ "{",
+ "\t$0",
+ "}"
+ ],
+ "description": "Creates a Method structure"
+ },
+ "Creates an Async Method structure": {
+ "prefix": "method_async",
+ "body": [
+ "${1:public} async ${2:Task}<${3:object}> ${4:MyMethodAsync}(${5:string} ${6:parameter})",
+ "{",
+ "\t$0",
+ "}"
+ ],
+ "description": "Creates an async Method structure"
+ },
+ "cls": {
+ "prefix": "cls",
+ "body": ["${1:public} class ${2:$TM_FILENAME_BASE}", "{", "\t$0", "}"],
+ "description": "Create new class"
+ }
+}