Skip to content

Instantly share code, notes, and snippets.

@garyng
Last active March 27, 2017 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garyng/3a597234d8a24544da5485e8cb1e4f61 to your computer and use it in GitHub Desktop.
Save garyng/3a597234d8a24544da5485e8cb1e4f61 to your computer and use it in GitHub Desktop.
ZenSharp Documentation
// Paste in Visual Studio and try it out!
// For more, see https://garyng.github.io/gtil-gitbook/ReSharper/resharper-plugin-zensharp.html
// -- Access Modifiers --
// p -> public
// _ -> private
// i -> internal
// P -> protected
// -- Types --
// t -> $type$ (ask for user input/"hotspot")
// a -> any primitive type ends with `a` will expand to the array of the type
// ? -> any primitive type ends with `?` will expand to nullable of the type
// -- Primitive Types --
// <t|<Type>[?][a]>[<Identifier>]
// :: Note: [] -> Optional
// | -> Or
// <> -> Required
// s -> string
// by -> byte
// b -> bool
// dt -> DateTime
// d -> double
// i -> int
// ui -> uint
// g -> Guid
// dc -> decimal
// u -> Uri
// x -> XElement
// o -> object
// :: Examples
// b? -> bool?
// ba -> bool[]
// b?a -> bool?[]
// -- Complex Type --
// l -> IList
// ~ -> IEnumerable
// <Access Modifiers><sl|di><<Type>|t><<Type>|t>[<Identifier>]
// sl -> SortedList
// di -> IDictionary
// :: Examples
// li -> IList<int>
// ~s -> IEnumerable<string>
// -- Properties --
// <Access Modifiers><ap|P|vp|p><t|<Type>>[<Identifier>][+[P]]
// ap -> abstract
// P -> static
// vp -> virtual
// p -> "" (normal property)
// -- Property Set Accessor --
// default -> private set;
// + -> public set;
// +P -> protected set;
// :: Examples (Try!)
// :: Note: `name` -> Hotspot (ask for user input)
// ppt -> public `type` `name` { get; private set; }
// pps -> public string `name` { get; private set; }
// ppsTesting -> public string Testing { get; private set; }
// ppsTesting+ -> public string Testing { get; set; }
// ppsTesting+P -> public string Testing { get; protected set; }
// :: More Examples
// pvpiTest+ -> public virtual int Test { get; set; }
// pPi?aTest+P -> public static int?[] Test { get; protected set; }
// pvp~i?aTesting+P -> public virtual IEnumerable<int?[]> Testing { get; protected set; }
// -- Method Attributes --
// :: Note: Specific to NUnit only
// su -> [SetUp]
// tfsu -> [TestFixtureSetUp]
// tftd -> [TestFixtureTearDown]
// td -> [TearDown]
// tc -> [TestCase]
// t -> [Test]
// -- Methods --
// [<Method Attributes>]<Access Modifier><am|vm|M|m>[t|<Type>|T[t]][<Identifier>][,<Type>[<Identifier>]]
// am -> abstract
// vm -> virtual
// M -> static
// m -> void
// :: Examples
// _m -> private void `name`(){}
// _vmt -> private virtual `type` `name`(){}
// _ms -> private string `name`(){}
// _msTesting -> private string Testing(){}
// _msTesting,s -> private string Testing(string `name2`){}
// _msTesting,sparam -> private string Testing(string param){}
// :: Async Method Examples
// _mT -> private async Task `name`(){}
// _mTt -> private async Task<`type`> `name`(){}
// _mTs -> private async Task<string> `name`(){}
// _mTsTesting -> private async Task<string> Testing(){}
// _mTsTesting,s -> private async Task<string> Testing(string `name2`){}
// _mTsTesting,sparam -> private async Task<string> Testing(string param){}
// :: More Examples
// tpmTsTesting,icase -> [NUnit.Framework.TestAttribute]
// public async Task<string> Testing(int case){}
// -- Consts --
// <Access Modifier>c<Type>[<Identifier>]=
// :: Examples
// _cs= -> private const string `S` = ``;
// _csTesting= -> private const string Testing = ``;
// :: Note: Must include the ending =, otherwise it will be interpreted as class
// -- Fields --
// <Access Modifier>[r]<<Type>|t>[<Identifier>][=]
// r -> readonly
// :: Examples
// _s -> private string `_s`;
// _s_testing -> private string _testing;
// _s= -> private string `_s` = `name2`;
// _s_testing= -> private string _testing = `name2`;
// _rs -> private readonly string `_s`;
// _rs_testing -> private readonly string _testing;
// _rs= -> private readonly string `_s` = `name2`;
// _rs_testing= -> private readonly string _testing = `name2`;
// -- Enums --
// <Access Modifier>e[<Identifier>]
// pe -> public enum `name`{}
// peTesting -> public enum Testing{}
// -- Class Attributes --
// :: Note: Specific to NUNit only
// tf -> [TestFixture]
// -- Classes --
// [<Class Attributes>]<Access Modifier>[s]<c|C><Identifier>[:<<Type>|t>]
// s -> sealed :: Note: Unexpandable? (Ambiguous to string)
// :: Examples
// pcTesting -> public class Testing{}
// pcTesting:t -> public class Testing : `type`{}
// pcTesting:o -> public class Testing : object{}
// -- Interfaces --
// :: Scope: Type and namespace
// <Access Modifier>i[<Identifier>][:<<Type>|t>]
// :: Examples
// pi -> public interface `name`{}
// piTesting -> public interface Testing{}
// piTesting:t -> public interface Testing : `type`{}
// piTesting:lt -> public interface Testing : IList<`type`>{}
// -- Logging --
// :: Scope: Statements
// l<f|i|e|t|d>
// f -> Fatal
// i -> Info
// e -> Error
// t -> Trace
// d -> Debug
// :: Examples
// lf -> Log.Fatal("``");
// :: Note: lf" is better (It will become the first entry in Intellisense)
// Others
// dbset -> public DBSet<`name`> `names` { get; set; } :: Scope: Class
// ifr -> if (`name` == null) return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment