Last active
August 29, 2019 13:46
-
-
Save Eonasdan/4ade9cad3755ff62fd80 to your computer and use it in GitHub Desktop.
zensharp tempaltes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // C# templates | |
| // Sample file | |
| space ::= " " | |
| cursor ::= "$END$" | |
| cursorb ::= "(" cursor ")" | |
| // Resharper macros: | |
| identifier ::= <name default="$name$" macros = "complete()"> | |
| identifier2 ::= <name2 default="$name2$" macros = "complete()"> | |
| // | |
| // Types: | |
| // | |
| suggType ::= <type short="t" expand="$type$" macros = "complete()"> | |
| // Primive types: | |
| maybeType ::= type | "void" | |
| type ::= generic | primType ("?"="?")? ("[]"=a)? | suggType | |
| primType ::= string=s | byte=by | bool=b | "System.DateTime"=dt | decimal=dc | double=d | int=i | uint=ui | "System.Guid"=g | "System.Uri"=u | "System.Xml.Linq.XElement"=x | FIXME=f | |
| // Complex types: | |
| generic1 ::= (SCG "." ("IList"=l | "IEnumerable"="~")) "<" type ">" | |
| generic2 ::= (SCG "." ("SortedList"=sl | "IDictionary"=di)) "<" type ", " type ">" | |
| SCG ::= "System.Collections.Generic" | |
| generic ::= generic1 | generic2 | |
| access ::= (internal=i | public=p | private=_ | protected=P) space | |
| // Auto properties: | |
| property ::= access ("abstract "=pa | "static "=P | "virtual "=pv | ""=p) type space identifier propertyBody cursor | |
| propertyBody ::= "{ get;" propertySetAccessor " set; }" | |
| propertySetAccessor ::= "protected "="+p" | "private "="-" | "" | |
| // Methods: | |
| method ::= access ("virtual "=vm | "abstract "=am | "static "=M | ""=m) (type | "void") space identifier methodArgs methodBody | |
| methodBody ::= " { " cursor " }" | |
| methodArgs ::= "(" ((""="," | ""="(") arg)? ")" | |
| arg ::= primType " " identifier2 | |
| // Consts: | |
| const ::= access "const "=c primType space identifier "= """ identifier """;" | |
| // Fields: | |
| field ::= access ("readonly "=r)? type space identifier ("="="=" identifier2 ";" | ";") | |
| // Classes: | |
| class ::= access ("sealed "=s)? ("class"=c | "static class"=C) space classBody | |
| classBody ::= identifier (" : "=":" type)? "{" cursor "}" | |
| //Enums: | |
| enum ::= access space "enum"=e space identifier "{" cursor "}" | |
| scope "InCSharpClass" { | |
| start ::= method | property | field | const | other | |
| other ::= | |
| | ""=tsetup "[NUnit.Framework.SetUpAttribute] public void TestSetup(){" cursor "}" | |
| | ""=tfsetup "[NUnit.Framework.TestFixtureSetUpAttribute] public void FixtureSetup(){" cursor "}" | |
| | ""=test "[NUnit.Framework.TestAttribute] public void Test" identifier "(){" cursor "}" | |
| | class | |
| } | |
| scope "InCSharpTypeAndNamespace" { | |
| start ::= | |
| | class | |
| | interface | |
| | enum | |
| interface ::= access "interface"=i space classBody | |
| } | |
| scope "InCSharpInterface" { | |
| start ::= | |
| | type space identifier propertyBody cursor | |
| | method | |
| | property | |
| propertyBody ::= "{ get; }" | "{ get; set; }"="+" | |
| access ::= "" | |
| methodBody ::= ";" | |
| } | |
| scope "InCSharpStruct" { | |
| // start ::= "" | |
| } | |
| scope "InCSharpStatement" { | |
| start ::= | |
| | "if ("=ifr identifier " == null) return;" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment