├── .vscode └── launch.json ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── TUTORIALS.md ├── images └── vscode-csharp-snippets.png ├── package.json ├── snippets └── csharp.json └── videos ├── csproj_2_aspnetcore_helloworld_snippet.gif └── csproj_2_csharp_helloworld_snippet.gif /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.1.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch Extension", 6 | "type": "extensionHost", 7 | "request": "launch", 8 | "runtimeExecutable": "${execPath}", 9 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ] 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # C# Snippets Changelog 2 | 3 | ### Change Log 4 | * All notable changes to the "vscode-csharp-snippets" extension will be documented in this file. 5 | 6 | 7 | 8 | ## [1.1.0] (2020-12-04) 9 | 10 | ``` 11 | New Snippets 12 | ``` 13 | - `[api_controller]` :: Creates the base of a controller 14 | - `[api_delete]` :: Creates the Delete Action of the WebApi 15 | - `[api_get]` :: Creates the Get Action of the WebApi 16 | - `[api_put]` :: Creates the Put Action of the WebApi 17 | - `[api_post]` :: Creates the Post Action of the WebApi 18 | - `[method]` :: Creates a Method structure 19 | - `[method_async]` :: Creates an Async Method structure 20 | - `[rz_code]` :: Creates a code block for Razor 21 | - `[rz_if]` :: Creates an if statement for Razor 22 | - `[rz_iflese]` :: Creates an if else statement for Razor 23 | - `[rz_implements]` :: Implements an interface for Razor 24 | - `[rz_inherits]` :: Creates an inherits directive for Razor 25 | - `[rz_inject]` :: Creates an inject directive for Razor 26 | - `[rz_foreach]` :: Creates a foreach statement for Razor 27 | - `[rz_functions]` :: Creates a functions block for Razor 28 | - `[rz_model]` :: Specifies the model to use for Razor 29 | - `[rz_namespace]` :: Specifies the namespace to use for Razor 30 | - `[rz_renderbody]` :: Creates a RenderBody for Razor 31 | - `[rz_switch]` :: Creates a switch statement for Razor 32 | - `[rz_try]` :: Creates a try catch finally for Razor 33 | - `[rz_using]` :: Creates an using statement for Razor 34 | - `[rz_viewbag]` :: Creates a ViewBag for Razor 35 | - `[rz_viewdata]` :: Creates a ViewData for Razor 36 | - `[rz_while]` :: Creates a while loop for Razor 37 | ``` 38 | Renamed 39 | ``` 40 | - `[ac_rz_code]` to `[rz_directive]` :: Creates a directive block for Razor 41 | - `[ac_rz_comment]` to `[rz_comment]` :: Creates a comment block for Razor 42 | - `[ac_rz_for]` to `[rz_for]` :: Creates a for statement for Razor 43 | - `[ac_rz_raw]` to `[rz_raw]` :: Creates a HTML markup for Razor 44 | 45 | 46 | ## [1.0.2] (2020-11-22) 47 | 48 | ``` 49 | New Snippets 50 | ``` 51 | - `[ac_comment]` :: Creates a comment block for ASP.NET 52 | - `[ac_rz_code]` :: Creates a code block for Razor 53 | - `[ac_rz_comment]` :: Creates a comment block for Razor 54 | - `[ac_rz_for]` :: Creates a for statement for Razor 55 | - `[ac_rz_raw]` :: Creates a HTML markup for Razor 56 | - `[ex_md5_from_stream]` :: Extension for get the MD5 value from a stream 57 | - `[ex_stream_to_string]` :: Extension for convert a stream to string 58 | - `[ex_string_to_stream]` :: Extension for convert a string to stream 59 | - `[todo]` :: Creates a TODO comment 60 | 61 | 62 | ## [1.0.1] (2020-11-14) 63 | 64 | ``` 65 | New Snippets 66 | ``` 67 | - `[sln_2019]` :: Creates a soluction file for Visual Studio 2019 (.NET Core and ASP.NET Core) 68 | 69 | ``` 70 | Renamed 71 | ``` 72 | - `[sln]` to `[sln_2017]` :: Creates a soluction file for Visual Studio 2017 (.NET Core and ASP.NET Core) 73 | 74 | 75 | ## [1.0.0] (2020-11-11) 76 | 77 | ``` 78 | New Snippets 79 | ``` 80 | - `[ac_action]` :: Creates a MVC/Api Action 81 | - `[ac_csproj_3.1]` :: Creates a MVC/Api Action 82 | - `[class]` :: Creates a class 83 | - `[dowhile]` :: Creates a do while loop 84 | - `[else]` :: Creates an else statement 85 | - `[enum]` :: Creates an enum type 86 | - `[exception]` :: Creates an exception class 87 | - `[for]` :: Creates a for loop 88 | - `[foreach]` :: Creates a foreach statement 89 | - `[if]` :: Creates an if statement 90 | - `[ifelse]` :: Creates an if else statement 91 | - `[iif]` :: Creates a conditional operator 92 | - `[interface]` :: Creates an interface 93 | - `[lock]` :: Creates a lock statement 94 | - `[main]` :: Creates a Console Main structure 95 | - `[msgbox]` :: Creates a Windows Message Box 96 | - `[namespace]` :: Creates a Namespace 97 | - `[struct]` :: Creates a struct 98 | - `[switch]` :: Creates a switch statement 99 | - `[tls]` :: Creates a C# 9 top-level statement 100 | - `[try]` :: Creates a try catch 101 | - `[tryf]` :: Creates a try catch finally 102 | - `[using]` :: Creates an using 103 | - `[while]` :: Creates a while loop 104 | 105 | 106 | ## [0.6.1] (2020-11-10) 107 | 108 | ``` 109 | Bug Fixing 110 | ``` 111 | - Fixed a typo error in the `[record]` C# snippet 112 | 113 | 114 | ## [0.6.0] (2020-11-10) 115 | 116 | ``` 117 | General 118 | ``` 119 | * Created a new tutorial to create a gRPC demo using the new snippets added in this version 120 | 121 | * Renamed of the ASP.NET Core Snippets 122 | 123 | - All the Snippets for ASP.NET Core have been renamed from `[dnac_*]` to `[ac_*]`. 124 | 125 | ``` 126 | New Snippets 127 | ``` 128 | - `[ac_#helloworld_WebApi]` :: ASP.NET Core 5 - Creates a Web Api HelloWorld sample 129 | - `[ac_csproj_5]` :: Creates the content of the csproj file for ASP.NET Core 5 130 | - `[crk]` :: Creates a call to ReadKey 131 | - `[cwl]` :: Creates a call to WriteLine 132 | - `[gRPC_client_csproj]` :: Creates the csproj content for a Grpc Client in .NET 5 133 | - `[gRPC_client_program]` :: Creates the Program class for a simple Grpc Client in .NET 5 134 | - `[gRPC_proto]` :: Creates a sample Proto file for the Grpc App 135 | - `[gRPC_server_csproj]` :: Creates the csproj content for a Grpc Server in .NET 5 136 | - `[gRPC_server_program]` :: Creates the Program class for the Grpc Server in .NET 5 137 | - `[gRPC_server_service]` :: Creates the Service for the Grpc Server in .NET 5 138 | - `[gRPC_server_settings]` :: Creates the Settings content file for the Grpc Server in .NET 5 139 | - `[gRPC_server_startup]` :: Creates the Startup class for the Grpc Server in .NET 5 140 | - `[prop]` :: Creates a property 141 | - `[propinit]` :: Creates an init property 142 | - `[propr]` :: Creates a property read-only 143 | - `[record]` :: Creates a record type 144 | - `[recordd]` :: Creates a record type with deconstructor 145 | 146 | 147 | ## [0.5.0] (2020-10-17) 148 | 149 | ``` 150 | Bug Fixing 151 | ``` 152 | - Thanks to [Jaguar9383 (Sviataslau Karavatski)](https://github.com/Jaguar9383) for resolve a typo error with `[singleton]` 153 | - Thanks to [jonhaddow (Jon Haddow)](https://github.com/jonhaddow) for resolve a typo error with `[xml_]` 154 | - Thanks to [guntbert (Guntbert Reiter)](https://github.com/guntbert) for fix a typo error in the `README.md` file 155 | 156 | ``` 157 | New Snippets 158 | ``` 159 | - `[mstest]` :: Contribution of [massimilianokraus (Massimiliano Kraus)](https://github.com/massimilianokraus) Creates a MS-Test class 160 | - `[csproj_3.1]` :: Creates the content of the csproj file for .NET Core 3.1 161 | - `[csproj_5]` :: Creates the content of the csproj file for .NET 5 162 | 163 | 164 | ## [0.3.1] (2018-03-02) 165 | 166 | ``` 167 | General 168 | ``` 169 | * Deleted some Snippets 170 | 171 | - Thanks to [doggy8088 (Will)](https://github.com/doggy8088) for ask me and share with me his feedback about delete some snippets in the extension that you can find in the OmniSharp extension too. Now, you can use OmniSharp and this extension together without disable the C# snippets in OmniSharp. You will find this extension as an ideal complement of OmniSharp now. 172 | 173 | 174 | ## [0.2.0] (2017-08-16) 175 | 176 | ``` 177 | ASP.NET Core Snippets 178 | ``` 179 | * Existing snippets modified 180 | 181 | - `[dnac_csproj_2.0]` has been deleted the tag **preview** for the 2.0 version to be aligned with the .NET Core 2.0 final version published 182 | 183 | 184 | ## [0.1.6] (2017-08-04) 185 | 186 | ``` 187 | General C# Snippets 188 | ``` 189 | * Existing snippets modified 190 | 191 | - `[singleton]` :: Modified the snippet resolving a bug 192 | 193 | * New snippets 194 | 195 | - `[singletonl]` :: Creates a singleton class with System.Lazy 196 | - `[singletonts]` :: Creates a singleton class as thread-safe without using locks 197 | 198 | ``` 199 | .NET Core Snippets 200 | ``` 201 | * New snippets 202 | 203 | - `[sln]` :: sln Generator for Visual Studio 2017 (.NET Core and ASP.NET Core) 204 | 205 | ``` 206 | ASP.NET Core Snippets 207 | ``` 208 | * New snippets 209 | 210 | - `[dnac_controller]` :: ASP.NET Core - Creates the base of a controller 211 | - `[dnac_startupenv]` :: ASP.NET Core - Creates the Startup constructor to be used with the web hosting environment 212 | 213 | 214 | ## [0.1.5] (2017-07-21) 215 | 216 | * Added a new section of snippets, for Xml Comments 217 | 218 | ``` 219 | XML Comments Snippets 220 | ``` 221 | * New snippets 222 | 223 | - `[xml_]` :: Xml Comment - Gives you a way to indicate that text within a description should be marked as code 224 | - `[xml_]` :: Xml Comment - Gives you a way to indicate multiple lines as code. Use to indicate that text within a description should be marked as code 225 | - `[xml_]` :: Xml Comment - Lets you specify an example of how to use a method or other library member 226 | - `[xml_]` :: Xml Comment - Lets you specify which exceptions can be thrown 227 | - `[xml_]` :: Xml Comment - Lets you refer to comments in another file that describe the types and members in your source code 228 | - `[xml_]` :: Xml Comment - A list or table can have as many blocks as needed 229 | - `[xml_]` :: Xml Comment - Is for use inside a tag, such as , , or , and lets you add structure to the text 230 | - `[xml_]` :: Xml Comment - Should be used in the comment for a method declaration to describe one of the parameters for the method 231 | - `[xml_]` :: Xml Comment - Gives you a way to indicate that a word in the code comments, for example in a or block refers to a parameter 232 | - `[xml_]` :: Xml Comment - Lets you document the access of a member 233 | - `[xml_]` :: Xml Comment - Is used to add information about a type, supplementing the information specified with 234 | - `[xml_]` :: Xml Comment - Should be used in the comment for a method declaration to describe the return value 235 | - `[xml_]` :: Xml Comment - Lets you specify a link from within text. Use to indicate that text should be placed in a See Also section 236 | - `[xml_]` :: Xml Comment - Lets you specify the text that you might want to appear in a See Also section 237 | - `[xml_]` :: Xml Comment - Should be used to describe a type or a type member 238 | - `[xml_]` :: Xml Comment - Should be used in the comment for a generic type or method declaration to describe a type parameter 239 | - `[xml_]` :: Xml Comment - Enable consumers of the documentation file to format the word in some distinct way, for example in italics 240 | - `[xml_]` :: Xml Comment - Lets you describe the value that a property represents 241 | 242 | 243 | ## [0.1.4] (2017-07-16) 244 | 245 | ``` 246 | General C# Snippets 247 | ``` 248 | * New snippets 249 | 250 | - `[guid]` :: Creates a new instance of the Guid structure 251 | - `[guidn]` :: Creates as string, a new instance of the Guid structure without hyphens 252 | - `[immutable]` :: Creates an immutable object 253 | - `[propi]` :: Creates an immutable property 254 | 255 | ``` 256 | ASP.NET Core Snippets 257 | ``` 258 | * New snippets 259 | 260 | - `[dnac_conf]` :: ASP.NET Core - Creates a way to configure the JSON configuration provider 261 | - `[dnac_conf_file]` :: ASP.NET Core - Creates a way to configure the JSON configuration provider with a custom config file 262 | 263 | 264 | ## [0.1.3] (2017-07-13) 265 | 266 | Included a new section with C# Snippets for ASP.NET Core. 267 | 268 | ``` 269 | General C# Snippets 270 | ``` 271 | * New snippets 272 | 273 | - `[classa]` :: Creates an abstract class declaration 274 | - `[classd]` :: Creates a disposable class 275 | - `[csproj_1.1]` :: Creates the content of the csproj file for .NET Core 1.1 276 | - `[linq_distinct]` :: Creates a LINQ Distinct sentence 277 | - `[linq_where]` :: Creates a LINQ Where sentence 278 | - `[singleton]` :: Creates a singleton class 279 | 280 | ``` 281 | ASP.NET Core Snippets 282 | ``` 283 | * New snippets 284 | 285 | - `[dnac_csproj_2.0]` :: ASP.NET Core 2.0 Preview2 Final csproj Generator 286 | - `[dnac_#helloworld_WebApp]` :: ASP.NET Core - Creates a HelloWorld sample - WebApp 287 | - `[dnac_#helloworld_Startup]` :: ASP.NET Core - Creates a HelloWorld sample - Startup 288 | 289 | 290 | ## [0.1.2] (2017-07-11) 291 | 292 | ``` 293 | General C# Snippets 294 | ``` 295 | * New snippets 296 | 297 | - `[#helloworld]` :: Creates a HelloWorld sample 298 | - `[cclear]` :: Creates a call to Clear 299 | - `[const]` :: Creates a constant 300 | - `[cr]` :: Creates a call to ReadLine 301 | - `[csproj_1.0]` :: Creates the content of the csproj file for .NET Core 1.0 302 | - `[csproj_2.0]` :: Creates the content of the csproj file for .NET Core 2.0 303 | - `[pum]` :: Creates a public string method declaration 304 | - `[pvm]` :: Creates a public void method declaration 305 | 306 | * Existing snippets modified 307 | 308 | - `[con_general_output]` is now `[cgo]` (the content of the snippet has changed too) 309 | 310 | 311 | ## [0.1.1] (2017-07-09) - Initial release 312 | 313 | ``` 314 | General C# Snippets 315 | ``` 316 | * Snippets 317 | 318 | - `[#if]` 319 | - `[#region]` 320 | - `[~]` 321 | - `[class]` 322 | - `[ctor]` 323 | - `[cw]` 324 | - `[do]` 325 | - `[else]` 326 | - `[enum]` 327 | - `[exception]` 328 | - `[for]` 329 | - `[foreach]` 330 | - `[forr]` 331 | - `[if]` 332 | - `[indexer]` 333 | - `[interface]` 334 | - `[invoke]` 335 | - `[iterator]` 336 | - `[lock]` 337 | - `[namespace]` 338 | - `[prop]` 339 | - `[propfull]` 340 | - `[propg]` 341 | - `[sim]` 342 | - `[struct]` 343 | - `[svm]` 344 | - `[switch]` 345 | - `[try]` 346 | - `[tryf]` 347 | - `[using]` 348 | - `[while]` 349 | - ~~`[con_general_output]`~~ 350 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | ## Copyright (c) 2015-2018 geeks.ms/Jorge, LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C# Snippets for Visual Studio Code 2 | 3 | ![Downloads](https://img.shields.io/visual-studio-marketplace/d/jorgeserrano.vscode-csharp-snippets) 4 | ![Installs](https://img.shields.io/visual-studio-marketplace/i/jorgeserrano.vscode-csharp-snippets) 5 | [![Visual Studio Code Extension](https://img.shields.io/visual-studio-marketplace/v/jorgeserrano.vscode-csharp-snippets?label=Version)](https://marketplace.visualstudio.com/items?itemName=jorgeserrano.vscode-csharp-snippets) 6 | ![Issues](https://img.shields.io/github/issues/J0rgeSerran0/vscode-csharp-snippets?color=B22DFF) 7 | ![Issues Pull Requests](https://img.shields.io/github/issues-pr/J0rgeSerran0/vscode-csharp-snippets?color=B22DFF) 8 | 9 | 10 | ![alt text](https://github.com/J0rgeSerran0/vscode-csharp-snippets/raw/master/images/vscode-csharp-snippets.png "C# Snippets") 11 | 12 | This extension for Visual Studio Code adds snippets for C#. 13 | 14 | You can find this extension in the [Visual Studio Code Marketplace](https://marketplace.visualstudio.com/items?itemName=jorgeserrano.vscode-csharp-snippets). 15 | 16 | See the [CHANGELOG](CHANGELOG.md) for the latest changes included. 17 | 18 | 19 | ## Usage 20 | Put the cursor on the C# file. 21 | 22 | Type part of a snippet, press `tab`, and the snippet unfolds. 23 | 24 | If you have problems to see the snippets, press `Ctrl`+`Space` (Windows, Linux) or `Cmd`+`Space` (OSX). 25 | 26 | (**see the [TUTORIALS](TUTORIALS.md) to know more**) 27 | 28 | 29 | ### C# general snippets 30 | ```csharp 31 | #helloworld 32 | ~ 33 | cclear 34 | cgo 35 | class 36 | classa 37 | classd 38 | const 39 | cr 40 | crk 41 | csproj_1.0 42 | csproj_1.1 43 | csproj_2.0 44 | csproj_2.1 45 | csproj_3.1 46 | csproj_5 47 | cwl 48 | dowhile 49 | else 50 | enum 51 | exception 52 | for 53 | foreach 54 | guid 55 | guidn 56 | if 57 | ifelse 58 | iif 59 | immutable 60 | interface 61 | linq_distinct 62 | linq_where 63 | lock 64 | main 65 | method 66 | method_async 67 | msgbox 68 | mstest 69 | namespace 70 | prop 71 | propi 72 | propinit 73 | propr 74 | pum 75 | pvm 76 | record 77 | singleton 78 | singletonl 79 | singletonts 80 | struct 81 | switch 82 | tls 83 | todo 84 | try 85 | tryf 86 | using 87 | while 88 | ``` 89 | 90 | ### Visual Studio snippets 91 | ```csharp 92 | sln_2017 93 | sln_2019 94 | ``` 95 | 96 | ### ASP.NET Core C# snippets 97 | ```csharp 98 | ac_#helloworld_Startup 99 | ac_#helloworld_WebApp 100 | ac_#helloworld_WebApi 101 | ac_action 102 | ac_comment 103 | ac_conf 104 | ac_conf_file 105 | ac_controller 106 | ac_csproj_2.0 107 | ac_csproj_2.1 108 | ac_csproj_3.1 109 | ac_csproj_5 110 | ac_startupenv 111 | ``` 112 | 113 | ### ASP.NET Core Web Api C# snippets 114 | ```csharp 115 | api_controller 116 | api_delete 117 | api_get 118 | api_put 119 | api_post 120 | ``` 121 | 122 | ### .NET Extensions 123 | ```csharp 124 | ex_md5_from_stream 125 | ex_stream_to_string 126 | ex_string_to_stream 127 | ``` 128 | 129 | ### gRPC C# snippets (.NET 5) 130 | ```csharp 131 | gRPC_client_csproj 132 | gRPC_client_program 133 | gRPC_proto 134 | gRPC_server_csproj 135 | gRPC_server_program 136 | gRPC_server_service 137 | gRPC_server_settings 138 | gRPC_server_startup 139 | ``` 140 | 141 | ### ASP.NET Core Razor C# snippets 142 | ```csharp 143 | rz_code 144 | rz_comment 145 | rz_directive 146 | rz_dowhile 147 | rz_for 148 | rz_foreach 149 | rz_functions 150 | rz_if 151 | rz_ifelse 152 | rz_implements 153 | rz_inherits 154 | rz_inject 155 | rz_model 156 | rz_namespace 157 | rz_raw 158 | rz_renderbody 159 | rz_switch 160 | rz_try 161 | rz_using 162 | rz_viewbag 163 | rz_viewdata 164 | rz_while 165 | ``` 166 | 167 | ### XML Comments snippets 168 | ```csharp 169 | xml_ 170 | xml_ 171 | xml_ 172 | xml_ 173 | xml_ 174 | xml_ 175 | xml_ 176 | xml_ 177 | xml_ 178 | xml_ 179 | xml_ 180 | xml_ 181 | xml_ 182 | xml_ 183 | xml_ 184 | xml_ 185 | xml_ 186 | xml_ 187 | ``` 188 | 189 | 190 | ## Installation 191 | 192 | 1. Install Visual Studio Code 1.5.0 or higher 193 | 2. Launch Visual Studio Code 194 | 3. From the command palette `Ctrl`-`Shift`-`P` (Windows, Linux) or `Cmd`-`Shift`-`P` (OSX) 195 | 4. Select `Install Extension` 196 | 5. Search and choose the extension 197 | 6. Reload Visual Studio Code 198 | -------------------------------------------------------------------------------- /TUTORIALS.md: -------------------------------------------------------------------------------- 1 | ## Demos - Use of the C# snippets 2 | 3 | 4 | ### Hello World Sample (.NET Core 2.0 Console App with C#) 5 | 6 | Snippets used: `[csproj_2.0]` and `[#helloworld]` 7 | 8 | * The video has a duration of 50 seconds. In this time, you will be able to generate your first .NET Core app. 9 | 10 | ![alt text](https://github.com/J0rgeSerran0/vscode-csharp-snippets/raw/master/videos/csproj_2_csharp_helloworld_snippet.gif "C# Snippets") 11 | 12 | 13 | ### Hello World Sample (ASP.NET Core 2.0 with C#) 14 | 15 | Snippets used: `[dnac_csproj_2.0]` `[dnac_#helloworld_Startup]` and `[dnac_#helloworld_WebApp]` 16 | 17 | > The dnac* snippets have been renamed to ac_* 18 | 19 | * The video has a duration of 50 seconds. In this time, you will be able to generate your first ASP.NET Core app. 20 | 21 | ![alt text](https://github.com/J0rgeSerran0/vscode-csharp-snippets/raw/master/videos/csproj_2_aspnetcore_helloworld_snippet.gif "C# Snippets") 22 | 23 | 24 | ### Hello World Sample (.NET 5 and Grpc C#) - STEP BY STEP 25 | 26 | Snippets used: `[gRPC_client_csproj]` `[gRPC_client_program]` `[gRPC_proto]` `[gRPC_server_csproj]` `[gRPC_server_program]` `[gRPC_server_service]` `[gRPC_server_settings]` and `[gRPC_server_startup]` 27 | 28 | [gRPC for .NET](https://github.com/grpc/grpc-dotnet) 29 | 30 | 31 | #### Project structure 32 | 1. Create a folder (for example: **GrpcHelloWorld**) 33 | 2. Create three folders (**Client**, **Proto**, **Server**) 34 | 35 | #### Client 36 | 1. Go to the **Client** folder 37 | 2. Create a file named *Client.csproj.cs* 38 | 3. Apply the `[gRPC_client_csproj]` snippet 39 | 4. Rename the file to *Client.csproj* 40 | 5. Create a file named *Program.cs* 41 | 6. Apply the `[gRPC_client_program]` snippet 42 | 43 | #### Proto file 44 | 1. Go to the **Proto** folder 45 | 2. Create a file named *greet.proto.cs* 46 | 3. Apply the `[gRPC_proto]` snippet 47 | 4. Rename the file to *greet.proto* 48 | 49 | #### Server 50 | 1. Go to the **Server** folder 51 | 2. Create a file named *Server.csproj.cs* 52 | 3. Apply the `[gRPC_server_csproj]` snippet 53 | 4. Rename the file to *Server.csproj* 54 | 5. Create a file named *Program.cs* 55 | 6. Apply the `[gRPC_server_program]` snippet 56 | 7. Create a file named *GreeterService.cs* 57 | 8. Apply the `[gRPC_server_service]` snippet 58 | 9. Create a file named *appsettings.json.cs* 59 | 10. Apply the `[gRPC_server_settings]` snippet 60 | 11. Rename the file to *appsettings.json* 61 | 12. Create a file named *Startup.cs* 62 | 13. Apply the `[gRPC_server_startup]` snippet 63 | 64 | #### Build 65 | 1. Open the terminal 66 | 2. Go to the **Client** folder 67 | 3. Write the command **dotnet build --source https://api.nuget.org/v3/index.json** 68 | 4. Go to the **Server** folder 69 | 5. Write the command **dotnet build --source https://api.nuget.org/v3/index.json** 70 | 71 | #### Testing 72 | 1. Open two terminals or command line windows 73 | 2. Go to the **Client** and **Server** folders 74 | 3. Start the **Server** writting the command **dotnet run** or the **Server.exe** from the bin folder 75 | 4. Start the **Client** writting the command **dotnet run** or the **Client.exe** from the bin folder 76 | -------------------------------------------------------------------------------- /images/vscode-csharp-snippets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/J0rgeSerran0/vscode-csharp-snippets/3522981cf1700ce0e7ae13a5b57cfd5d2b67a9d8/images/vscode-csharp-snippets.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-csharp-snippets", 3 | "publisher": "jorgeserrano", 4 | "displayName": "C# Snippets", 5 | "description": "C# Snippets for Visual Studio Code", 6 | "icon": "images/vscode-csharp-snippets.png", 7 | "version": "1.1.0", 8 | "author": "Jorge Serrano", 9 | "license": "SEE LICENSE IN LICENSE.md", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/J0rgeSerran0/vscode-csharp-snippets.git" 13 | }, 14 | "categories": [ 15 | "Other", 16 | "Programming Languages", 17 | "Snippets" 18 | ], 19 | "keywords": [ 20 | ".NET", 21 | ".NET Core", 22 | ".NET 5", 23 | "ASP.NET", 24 | "gRPC", 25 | "Visual Studio", 26 | "C#", 27 | "csharp", 28 | "languages", 29 | "dotnet", 30 | "programming languages", 31 | "snippet", 32 | "snippets", 33 | "Razor" 34 | ], 35 | "contributors": [ 36 | { 37 | "name": "Jorge Serrano", 38 | "url": "http://geeks.ms/Jorge/" 39 | } 40 | ], 41 | "engines": { 42 | "vscode": "^1.5.0" 43 | }, 44 | "contributes": { 45 | "snippets": [ 46 | { 47 | "language": "csharp", 48 | "path": "./snippets/csharp.json" 49 | } 50 | ] 51 | } 52 | } -------------------------------------------------------------------------------- /snippets/csharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "Creates a HelloWorld sample":{ 3 | "prefix": "#helloworld", 4 | "body": [ 5 | "using System;", 6 | "", 7 | "namespace ConsoleApp", 8 | "{", 9 | "\tpublic class Program", 10 | "\t{", 11 | "\t\tpublic static void Main(string[] args)", 12 | "\t\t{", 13 | "\t\t\tConsole.WriteLine(\"Hello World!\");", 14 | "\t\t}", 15 | "\t}", 16 | "}" 17 | ], 18 | "description": "Creates a HelloWorld sample" 19 | }, 20 | "Creates a destructor for the containing class":{ 21 | "prefix": "~", 22 | "body": [ 23 | "~${1:Program}()", 24 | "{", 25 | "\t$0", 26 | "}" 27 | ], 28 | "description": "Creates a destructor for the containing class" 29 | }, 30 | "Creates a call to Clear":{ 31 | "prefix": "cclear", 32 | "body": [ 33 | "Console.Clear();", 34 | "$0" 35 | ], 36 | "description": "Creates a call to Clear" 37 | }, 38 | "General output to console":{ 39 | "prefix": "cgo", 40 | "body": [ 41 | "Console.WriteLine(\"Console app started\");", 42 | "", 43 | "$0", 44 | "Console.WriteLine(\"Press any key to exit...\");", 45 | "Console.ReadKey(true);" 46 | ], 47 | "description": "General output to console" 48 | }, 49 | "Creates a class":{ 50 | "prefix": "class", 51 | "body": [ 52 | "public class ${1:MyClass}", 53 | "{", 54 | "\t$0", 55 | "}" 56 | ], 57 | "description": "Creates a class" 58 | }, 59 | "Creates an abstract class declaration":{ 60 | "prefix": "classa", 61 | "body": [ 62 | "public abstract class ${1:MyClass}", 63 | "{", 64 | "\t$0", 65 | "}" 66 | ], 67 | "description": "Creates an abstract class declaration" 68 | }, 69 | "Creates a disposable class":{ 70 | "prefix": "classd", 71 | "body": [ 72 | "public class ${1:MyClass} : IDisposable", 73 | "{", 74 | "", 75 | "\tpublic void Dispose()", 76 | "\t{", 77 | "\t\tGC.SuppressFinalize(this);", 78 | "\t}", 79 | "", 80 | "\t$0", 81 | "}" 82 | ], 83 | "description": "Creates a disposable class" 84 | }, 85 | "Creates a constant":{ 86 | "prefix": "const", 87 | "body": [ 88 | "${1:public} const ${2:string} ${3:CONSTANT_NAME} = \"${4:value}\";", 89 | "$0" 90 | ], 91 | "description": "Creates a constant" 92 | }, 93 | "Creates a call to ReadLine":{ 94 | "prefix": "cr", 95 | "body": [ 96 | "Console.ReadLine();", 97 | "$0" 98 | ], 99 | "description": "Creates a call to ReadLine" 100 | }, 101 | "Creates a call to ReadKey":{ 102 | "prefix": "crk", 103 | "body": [ 104 | "Console.ReadKey();", 105 | "$0" 106 | ], 107 | "description": "Creates a call to ReadKey" 108 | }, 109 | "Creates a call to WriteLine":{ 110 | "prefix": "cwl", 111 | "body": [ 112 | "Console.WriteLine($\"${1:Text}\");", 113 | "$0" 114 | ], 115 | "description": "Creates a call to WriteLine" 116 | }, 117 | "Creates a do while loop":{ 118 | "prefix": "dowhile", 119 | "body": [ 120 | "do", 121 | "{", 122 | "\t$0", 123 | "} while (${1:true})" 124 | ], 125 | "description": "Creates a do while loop" 126 | }, 127 | "Creates an else statement":{ 128 | "prefix": "else", 129 | "body": [ 130 | "else", 131 | "{", 132 | "\t$0", 133 | "}" 134 | ], 135 | "description": "Creates an else statement" 136 | }, 137 | "Creates an enum type":{ 138 | "prefix": "enum", 139 | "body": [ 140 | "public enum ${1:MyEnumType}", 141 | "{", 142 | "\t$0", 143 | "}" 144 | ], 145 | "description": "Creates an enum type" 146 | }, 147 | "Creates an exception class":{ 148 | "prefix": "exception", 149 | "body": [ 150 | "public class ${1:MyException} : System.Exception", 151 | "{", 152 | "\tpublic $1() {}", 153 | "\tpublic $1(string message) : base(message) {}", 154 | "\tpublic $1(string message, System.Exception inner) : base(message, inner) {}", 155 | "\tpublic $1(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) {}", 156 | "}" 157 | ], 158 | "description": "Creates an exception class" 159 | }, 160 | "Creates a for loop":{ 161 | "prefix": "for", 162 | "body": [ 163 | "for (var ${1:i} = 0; $1 < ${2:length}; $1++)", 164 | "{", 165 | "\t$0", 166 | "}" 167 | ], 168 | "description": "Creates a for loop" 169 | }, 170 | "Creates a foreach statement":{ 171 | "prefix": "foreach", 172 | "body": [ 173 | "foreach (var ${1:item} in ${2:collection})", 174 | "{", 175 | "\t$0", 176 | "}" 177 | ], 178 | "description": "Creates a foreach statement" 179 | }, 180 | "Creates a new instance of the Guid structure":{ 181 | "prefix": "guid", 182 | "body": [ 183 | "Guid ${1:guid} = Guid.NewGuid();", 184 | "$0" 185 | ], 186 | "description": "Creates a new instance of the Guid structure" 187 | }, 188 | "Creates as string, a new instance of the Guid structure without hyphens":{ 189 | "prefix": "guidn", 190 | "body": [ 191 | "string ${1:guid} = Guid.NewGuid().ToString(\"N\");", 192 | "$0" 193 | ], 194 | "description": "Creates as string, a new instance of the Guid structure without hyphens" 195 | }, 196 | "Creates an if statement":{ 197 | "prefix": "if", 198 | "body": [ 199 | "if (${1:true})", 200 | "{", 201 | "\t$0", 202 | "}" 203 | ], 204 | "description": "Creates an if statement" 205 | }, 206 | "Creates an if else statement":{ 207 | "prefix": "ifelse", 208 | "body": [ 209 | "if (${1:true})", 210 | "{", 211 | "\t$0", 212 | "}", 213 | "else", 214 | "{", 215 | "\t", 216 | "}" 217 | ], 218 | "description": "Creates an if else statement" 219 | }, 220 | "Creates a conditional operator":{ 221 | "prefix": "iif", 222 | "body": [ 223 | "var ${1:value} = ${2:true};", 224 | "var ${3:result} = (${1} ? ${4:true} : ${5:false});", 225 | "$0" 226 | ], 227 | "description": "Creates a conditional operator" 228 | }, 229 | "Creates an immutable object":{ 230 | "prefix": "immutable", 231 | "body": [ 232 | "${1:public} class ${2:ImmutableObject}", 233 | "{", 234 | "\tprivate readonly ${3:string} ${4:_name};", 235 | "\tpublic $3 ${5:Name} => $4", 236 | "", 237 | "\tpublic $2($3 ${6:name})", 238 | "\t{", 239 | "\t\t$4 = $6;", 240 | "\t}", 241 | "}" 242 | ], 243 | "description": "Creates an immutable object" 244 | }, 245 | "Creates an interface":{ 246 | "prefix": "interface", 247 | "body": [ 248 | "public interface I${1:MyInterface}", 249 | "{", 250 | "\t$0", 251 | "}" 252 | ], 253 | "description": "Creates an interface" 254 | }, 255 | "Creates a LINQ Distinct sentence":{ 256 | "prefix": "linq_distinct", 257 | "body": [ 258 | "${1:var} ${2:data} = (from ${3:item} in ${4:collection}", 259 | "\t\t\tselect $3).Distinct()" 260 | ], 261 | "description": "Creates a LINQ Distinct sentence" 262 | }, 263 | "Creates a LINQ Where sentence":{ 264 | "prefix": "linq_where", 265 | "body": [ 266 | "${1:var} ${2:data} = from ${3:item} in ${4:collection}", 267 | "\t\t\twhere $3.${5:FieldName}.${6:Contains}(\"${7:Text}\")", 268 | "\t\t\tselect $3;" 269 | ], 270 | "description": "Creates a LINQ Where sentence" 271 | }, 272 | "Creates a lock statement":{ 273 | "prefix": "lock", 274 | "body": [ 275 | "lock (${1:true})", 276 | "{", 277 | "\t$0", 278 | "}" 279 | ], 280 | "description": "Creates a lock statement" 281 | }, 282 | "Creates a Console Main structure":{ 283 | "prefix": "main", 284 | "body": [ 285 | "public static void Main(string[] args)", 286 | "{", 287 | "\t$0", 288 | "}" 289 | ], 290 | "description": "Creates a Console Main structure" 291 | }, 292 | "Creates a Method structure":{ 293 | "prefix": "method", 294 | "body": [ 295 | "${1:public} ${2:void} ${3:MyMethod}(${4:string} ${5:parameter})", 296 | "{", 297 | "\t$0", 298 | "}" 299 | ], 300 | "description": "Creates a Method structure" 301 | }, 302 | "Creates an Async Method structure":{ 303 | "prefix": "method_async", 304 | "body": [ 305 | "${1:public} async ${2:Task}<${3:object}> ${4:MyMethodAsync}(${5:string} ${6:parameter})", 306 | "{", 307 | "\t$0", 308 | "}" 309 | ], 310 | "description": "Creates an async Method structure" 311 | }, 312 | "Creates a Windows Message Box":{ 313 | "prefix": "msgbox", 314 | "body": [ 315 | "System.Windows.Forms.MessageBox.Show(\"${1:Hello}\");", 316 | "$0" 317 | ], 318 | "description": "Creates a Windows Message Box" 319 | }, 320 | "Creates a Namespace":{ 321 | "prefix": "namespace", 322 | "body": [ 323 | "namespace ${1:MyNamespace}", 324 | "{", 325 | "\t$0", 326 | "}" 327 | ], 328 | "description": "Creates a Namespace" 329 | }, 330 | "Creates a property": { 331 | "prefix": "prop", 332 | "body": [ 333 | "${1:public} ${2:string} ${3:Name} { get; set; }", 334 | "", 335 | "$0" 336 | ], 337 | "description": "Creates a property" 338 | }, 339 | "Creates an immutable property": { 340 | "prefix": "propi", 341 | "body": [ 342 | "private readonly ${1:string} ${2:_name};", 343 | "", 344 | "public $1 ${3:Name} => $2;", 345 | "$0" 346 | ], 347 | "description": "Creates an immutable property" 348 | }, 349 | "Creates an init property": { 350 | "prefix": "propinit", 351 | "body": [ 352 | "public ${1:string} ${2:Name} { get; init; }", 353 | "", 354 | "$0" 355 | ], 356 | "description": "Creates an init property" 357 | }, 358 | "Creates a property read-only": { 359 | "prefix": "propr", 360 | "body": [ 361 | "public ${1:string} ${2:Name} { get; private set; }", 362 | "", 363 | "$0" 364 | ], 365 | "description": "Creates a property read-only" 366 | }, 367 | "Creates a public string method declaration": { 368 | "prefix": "pum", 369 | "body": [ 370 | "public ${1:string} ${2:Method}(${3:string} ${4:parameter})", 371 | "{", 372 | "\t$0", 373 | "\treturn System.NotImplementedException;", 374 | "}" 375 | ], 376 | "description": "Creates a public string method declaration" 377 | }, 378 | "Creates a public void method declaration": { 379 | "prefix": "pvm", 380 | "body": [ 381 | "public void ${1:Method}(${2:string} ${3:parameter})", 382 | "{", 383 | "\t$0", 384 | "}" 385 | ], 386 | "description": "Creates a public void method declaration" 387 | }, 388 | "Creates a record type":{ 389 | "prefix": "record", 390 | "body": [ 391 | "public record Person(${1:string} ${2:Name});" 392 | ], 393 | "description": "Creates a record type" 394 | }, 395 | "Creates a record type with deconstructor":{ 396 | "prefix": "recordd", 397 | "body": [ 398 | "public record Person", 399 | "{", 400 | "\tpublic Person(${1:string} ${2:name}, ${3:int} ${4:age}) => (${5:Name}, ${6:Age}) = ($2, $4);", 401 | "", 402 | "\tpublic $1 $5 { get; set; }", 403 | "\tpublic $3 $6 { get; set; }", 404 | "", 405 | "public void Deconstructor(out $1 $2, out $3 $4) => ($2, $4) = ($5, $6);", 406 | "}" 407 | ], 408 | "description": "Creates a record type with deconstructor" 409 | }, 410 | "Creates a singleton class": { 411 | "prefix": "singleton", 412 | "body": [ 413 | "public sealed class ${1:MyClass}", 414 | "{", 415 | "\tprivate static volatile I${2:MyObject} instance;", 416 | "\tprivate static Object syncRootObject = new Object();", 417 | "", 418 | "\tpublic static I${2} Instance", 419 | "\t{", 420 | "\t\tget", 421 | "\t\t{", 422 | "\t\t\tif (instance == null)", 423 | "\t\t\t{", 424 | "\t\t\t\tlock (syncRootObject)", 425 | "\t\t\t\t{", 426 | "\t\t\t\t\tif (instance == null)", 427 | "\t\t\t\t\t{", 428 | "\t\t\t\t\t\tinstance = new $0${3:MyObject}();", 429 | "\t\t\t\t\t}", 430 | "\t\t\t\t}", 431 | "\t\t\t}", 432 | "\t\t\treturn instance;", 433 | "\t\t}", 434 | "\t}", 435 | "}" 436 | ], 437 | "description": "Creates a singleton class" 438 | }, 439 | "Creates a singleton class with System.Lazy": { 440 | "prefix": "singletonl", 441 | "body": [ 442 | "public sealed class ${1:MyClass} : I${2:MyObject}", 443 | "{", 444 | "\tprivate static readonly Lazy _instance = new Lazy(() => new ${1}());", 445 | "", 446 | "\tpublic static I${2} Instance { get { return _instance.Value; } }", 447 | "\t", 448 | "\tprivate ${1}()", 449 | "\t{", 450 | "\t}", 451 | "}" 452 | ], 453 | "description": "Creates a singleton class with System.Lazy" 454 | }, 455 | "Creates a singleton class as thread-safe without using locks": { 456 | "prefix": "singletonts", 457 | "body": [ 458 | "public sealed class ${1:MyClass} : I${2:MyObject}", 459 | "{", 460 | "\tprivate static readonly I${2} _instance = new ${1}();", 461 | "", 462 | "\tstatic ${1}() {}", 463 | "", 464 | "\tprivate ${1}() {}", 465 | "", 466 | "\tpublic static I${2} Instance { get { return _instance; } }", 467 | "\t", 468 | "}" 469 | ], 470 | "description": "Creates a singleton class as thread-safe without using locks" 471 | }, 472 | "Creates a struct": { 473 | "prefix": "struct", 474 | "body": [ 475 | "public struct ${1:MyStruct}", 476 | "{", 477 | "\t$0", 478 | "}" 479 | ], 480 | "description": "Creates a struct" 481 | }, 482 | "Creates a switch statement": { 483 | "prefix": "switch", 484 | "body": [ 485 | "switch (${1:value})", 486 | "{", 487 | "\tcase ${2:value1}:", 488 | "\t\tbreak;", 489 | "\tdefault:", 490 | "\t\tbreak;", 491 | "}", 492 | "$0" 493 | ], 494 | "description": "Creates a switch statement" 495 | }, 496 | "Creates a C# 9 top-level statement": { 497 | "prefix": "tls", 498 | "body": [ 499 | "System.Console.WriteLine(\"${1:Hello World!}\");" 500 | ], 501 | "description": "Creates a C# 9 top-level statement" 502 | }, 503 | "Creates a TODO comment": { 504 | "prefix": "todo", 505 | "body": [ 506 | "// TODO: $0" 507 | ], 508 | "description": "Creates a TODO comment" 509 | }, 510 | "Creates a try catch": { 511 | "prefix": "try", 512 | "body": [ 513 | "try", 514 | "{", 515 | "\t$0", 516 | "}", 517 | "catch (${1:System.Exception} ex)", 518 | "{", 519 | "\t // TODO", 520 | "}" 521 | ], 522 | "description": "Creates a try catch" 523 | }, 524 | "Creates a try catch finally": { 525 | "prefix": "tryf", 526 | "body": [ 527 | "try", 528 | "{", 529 | "\t$0", 530 | "}", 531 | "catch (${1:System.Exception} ex)", 532 | "{", 533 | "\t // TODO", 534 | "}", 535 | "finally", 536 | "{", 537 | "\t", 538 | "}" 539 | ], 540 | "description": "Creates a try catch finally" 541 | }, 542 | "Creates an using":{ 543 | "prefix": "using", 544 | "body": [ 545 | "using ${1:System}$0;" 546 | ], 547 | "description": "Creates an using" 548 | }, 549 | "Creates a while loop":{ 550 | "prefix": "while", 551 | "body": [ 552 | "while (${1:true})", 553 | "{", 554 | "\t$0", 555 | "}" 556 | ], 557 | "description": "Creates a while loop" 558 | }, 559 | "csproj Generator for .NET Core 1.0":{ 560 | "prefix": "csproj_1.0", 561 | "body": [ 562 | "", 563 | "\t", 564 | "\t\tExe", 565 | "\t\tnetcoreapp1.0", 566 | "\t", 567 | "" 568 | ], 569 | "description": "csproj Generator for .NET Core 1.0" 570 | }, 571 | "csproj Generator for .NET Core 1.1":{ 572 | "prefix": "csproj_1.1", 573 | "body": [ 574 | "", 575 | "\t", 576 | "\t\tExe", 577 | "\t\tnetcoreapp1.1", 578 | "\t", 579 | "" 580 | ], 581 | "description": "csproj Generator for .NET Core 1.1" 582 | }, 583 | "csproj Generator for .NET Core 2.0":{ 584 | "prefix": "csproj_2.0", 585 | "body": [ 586 | "", 587 | "\t", 588 | "\t\tExe", 589 | "\t\tnetcoreapp2.0", 590 | "\t", 591 | "" 592 | ], 593 | "description": "csproj Generator for .NET Core 2.0" 594 | }, 595 | "csproj Generator for .NET Core 3.1":{ 596 | "prefix": "csproj_3.1", 597 | "body": [ 598 | "", 599 | "\t", 600 | "\t\tExe", 601 | "\t\tnetcoreapp3.1", 602 | "\t", 603 | "" 604 | ], 605 | "description": "csproj Generator for .NET Core 3.1" 606 | }, 607 | "csproj Generator for .NET 5":{ 608 | "prefix": "csproj_5", 609 | "body": [ 610 | "", 611 | "\t", 612 | "\t\tExe", 613 | "\t\tnet5.0", 614 | "\t", 615 | "" 616 | ], 617 | "description": "csproj Generator for .NET 5" 618 | }, 619 | "sln Generator for Visual Studio 2017 (.NET Core and ASP.NET Core)":{ 620 | "prefix": "sln_2017", 621 | "body": [ 622 | "Microsoft Visual Studio Solution File, Format Version 12.00", 623 | "# Visual Studio 15", 624 | "VisualStudioVersion = 15.0.26124.0", 625 | "MinimumVisualStudioVersion = 15.0.26124.0", 626 | "Project(\"{${1:FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"${2:SolutionName}\", \"$2\\\\${3:ProjectName}.csproj\", \"{${4:3E6CAA7F-C72A-428D-91C8-74ADBD56D3CA}}\"", 627 | "EndProject", 628 | "Global", 629 | "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution", 630 | "\t\tDebug|Any CPU = Debug|Any CPU", 631 | "\t\tDebug|x64 = Debug|x64", 632 | "\t\tDebug|x86 = Debug|x86", 633 | "\t\tRelease|Any CPU = Release|Any CPU", 634 | "\t\tRelease|x64 = Release|x64", 635 | "\t\tRelease|x86 = Release|x86", 636 | "\tEndGlobalSection", 637 | "\tGlobalSection(SolutionProperties) = preSolution", 638 | "\t\tHideSolutionNode = FALSE", 639 | "\tEndGlobalSection", 640 | "EndGlobal" 641 | ], 642 | "description": "sln Generator for Visual Studio 2017 (.NET Core and ASP.NET Core)" 643 | }, 644 | "sln Generator for Visual Studio 2019 (.NET Core and ASP.NET Core)":{ 645 | "prefix": "sln_2019", 646 | "body": [ 647 | "Microsoft Visual Studio Solution File, Format Version 12.00", 648 | "# Visual Studio Version 16", 649 | "VisualStudioVersion = 16.0.30711.63", 650 | "MinimumVisualStudioVersion = 10.0.40219.1", 651 | "Project(\"{${1:FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"${2:SolutionName}\", \"$2\\\\${3:ProjectName}.csproj\", \"{${4:3E6CAA7F-C72A-428D-91C8-74ADBD56D3CA}}\"", 652 | "EndProject", 653 | "Global", 654 | "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution", 655 | "\t\tDebug|Any CPU = Debug|Any CPU", 656 | "\t\tDebug|x64 = Debug|x64", 657 | "\t\tDebug|x86 = Debug|x86", 658 | "\t\tRelease|Any CPU = Release|Any CPU", 659 | "\t\tRelease|x64 = Release|x64", 660 | "\t\tRelease|x86 = Release|x86", 661 | "\tEndGlobalSection", 662 | "\tGlobalSection(SolutionProperties) = preSolution", 663 | "\t\tHideSolutionNode = FALSE", 664 | "\tEndGlobalSection", 665 | "EndGlobal" 666 | ], 667 | "description": "sln Generator for Visual Studio 2019 (.NET Core and ASP.NET Core)" 668 | }, 669 | "Xml Comment - Gives you a way to indicate that text within a description should be marked as code":{ 670 | "prefix": "xml_", 671 | "body": [ 672 | "/// ${1:text}" 673 | ], 674 | "description": "Xml Comment - Gives you a way to indicate that text within a description should be marked as code" 675 | }, 676 | "Xml Comment - Gives you a way to indicate multiple lines as code. Use to indicate that text within a description should be marked as code":{ 677 | "prefix": "xml_", 678 | "body": [ 679 | "/// ", 680 | "/// ${1:content}", 681 | "/// " 682 | ], 683 | "description": "Xml Comment - Gives you a way to indicate multiple lines as code. Use to indicate that text within a description should be marked as code" 684 | }, 685 | "Xml Comment - Lets you specify an example of how to use a method or other library member":{ 686 | "prefix": "xml_", 687 | "body": [ 688 | "/// ", 689 | "/// ${1:description}", 690 | "/// " 691 | ], 692 | "description": "Xml Comment - Lets you specify an example of how to use a method or other library member" 693 | }, 694 | "Xml Comment - Lets you specify which exceptions can be thrown":{ 695 | "prefix": "xml_", 696 | "body": [ 697 | "/// ${2:description}" 698 | ], 699 | "description": "Xml Comment - Lets you specify which exceptions can be thrown" 700 | }, 701 | "Xml Comment - Lets you refer to comments in another file that describe the types and members in your source code":{ 702 | "prefix": "xml_", 703 | "body": [ 704 | "/// " 705 | ], 706 | "description": "Xml Comment - Lets you refer to comments in another file that describe the types and members in your source code" 707 | }, 708 | "Xml Comment - A list or table can have as many blocks as needed":{ 709 | "prefix": "xml_", 710 | "body": [ 711 | "/// ", 712 | "/// ", 713 | "/// ${1:term}", 714 | "/// ${2:description}", 715 | "/// ", 716 | "/// ", 717 | "/// ${3:term}", 718 | "/// ${4:description}", 719 | "/// ", 720 | "/// " 721 | ], 722 | "description": "Xml Comment - A list or table can have as many blocks as needed" 723 | }, 724 | "Xml Comment - Is for use inside a tag, such as , , or , and lets you add structure to the text":{ 725 | "prefix": "xml_", 726 | "body": [ 727 | "/// ${1:content}" 728 | ], 729 | "description": "Xml Comment - Is for use inside a tag, such as , , or , and lets you add structure to the text" 730 | }, 731 | "Xml Comment - Should be used in the comment for a method declaration to describe one of the parameters for the method":{ 732 | "prefix": "xml_", 733 | "body": [ 734 | "/// ${2:description}" 735 | ], 736 | "description": "Xml Comment - Should be used in the comment for a method declaration to describe one of the parameters for the method" 737 | }, 738 | "Xml Comment - Gives you a way to indicate that a word in the code comments, for example in a or block refers to a parameter":{ 739 | "prefix": "xml_", 740 | "body": [ 741 | "/// " 742 | ], 743 | "description": "Xml Comment - Gives you a way to indicate that a word in the code comments, for example in a or block refers to a parameter" 744 | }, 745 | "Xml Comment - Lets you document the access of a member":{ 746 | "prefix": "xml_", 747 | "body": [ 748 | "/// ${2:description}" 749 | ], 750 | "description": "Xml Comment - Lets you document the access of a member" 751 | }, 752 | "Xml Comment - Is used to add information about a type, supplementing the information specified with ":{ 753 | "prefix": "xml_", 754 | "body": [ 755 | "/// ${1:description}" 756 | ], 757 | "description": "Xml Comment - Is used to add information about a type, supplementing the information specified with " 758 | }, 759 | "Xml Comment - Should be used in the comment for a method declaration to describe the return value":{ 760 | "prefix": "xml_", 761 | "body": [ 762 | "/// ${1:description}" 763 | ], 764 | "description": "Xml Comment - Should be used in the comment for a method declaration to describe the return value" 765 | }, 766 | "Xml Comment - Lets you specify a link from within text. Use to indicate that text should be placed in a See Also section":{ 767 | "prefix": "xml_", 768 | "body": [ 769 | "/// " 770 | ], 771 | "description": "Xml Comment - Lets you specify a link from within text. Use to indicate that text should be placed in a See Also section" 772 | }, 773 | "Xml Comment - Lets you specify the text that you might want to appear in a See Also section":{ 774 | "prefix": "xml_", 775 | "body": [ 776 | "/// " 777 | ], 778 | "description": "Xml Comment - Lets you specify the text that you might want to appear in a See Also section" 779 | }, 780 | "Xml Comment - Should be used to describe a type or a type member":{ 781 | "prefix": "xml_", 782 | "body": [ 783 | "/// ${1:description}" 784 | ], 785 | "description": "Xml Comment - Should be used to describe a type or a type member" 786 | }, 787 | "Xml Comment - Should be used in the comment for a generic type or method declaration to describe a type parameter":{ 788 | "prefix": "xml_", 789 | "body": [ 790 | "/// ${2:description}" 791 | ], 792 | "description": "Xml Comment - Should be used in the comment for a generic type or method declaration to describe a type parameter" 793 | }, 794 | "Xml Comment - Enable consumers of the documentation file to format the word in some distinct way, for example in italics":{ 795 | "prefix": "xml_", 796 | "body": [ 797 | "/// " 798 | ], 799 | "description": "Xml Comment - Enable consumers of the documentation file to format the word in some distinct way, for example in italics" 800 | }, 801 | "Xml Comment - Lets you describe the value that a property represents":{ 802 | "prefix": "xml_", 803 | "body": [ 804 | "/// ${1:property-description}" 805 | ], 806 | "description": "Xml Comment - Lets you describe the value that a property represents" 807 | }, 808 | "ASP.NET Core 2.0 csproj Generator":{ 809 | "prefix": "ac_csproj_2.0", 810 | "body": [ 811 | "", 812 | "\t", 813 | "\t\tnetcoreapp2.0", 814 | "\t", 815 | "\t", 816 | "\t\t", 817 | "\t", 818 | "\t", 819 | "\t\t", 820 | "\t", 821 | "" 822 | ], 823 | "description": "ASP.NET Core 2.0 csproj Generator" 824 | }, 825 | "ASP.NET Core 2.1 csproj Generator":{ 826 | "prefix": "ac_csproj_2.1", 827 | "body": [ 828 | "", 829 | "\t", 830 | "\t\tnetcoreapp2.1", 831 | "\t", 832 | "\t", 833 | "\t\t", 834 | "\t", 835 | "\t", 836 | "\t\t", 837 | "\t", 838 | "" 839 | ], 840 | "description": "ASP.NET Core 2.1 csproj Generator" 841 | }, 842 | "ASP.NET Core 3.1 csproj Generator":{ 843 | "prefix": "ac_csproj_3.1", 844 | "body": [ 845 | "", 846 | "\t", 847 | "\t\tnetcoreapp3.1", 848 | "\t", 849 | "" 850 | ], 851 | "description": "ASP.NET Core 3.1 csproj Generator" 852 | }, 853 | "ASP.NET 5 csproj Generator":{ 854 | "prefix": "ac_csproj_5", 855 | "body": [ 856 | "", 857 | "\t", 858 | "\t\tnet5.0", 859 | "\t", 860 | "" 861 | ], 862 | "description": "ASP.NET Core 5 csproj Generator" 863 | }, 864 | "ASP.NET Core - Creates a HelloWorld sample - Startup":{ 865 | "prefix": "ac_#helloworld_Startup", 866 | "body": [ 867 | "using System;", 868 | "using System.Collections.Generic;", 869 | "using System.Linq;", 870 | "using System.Threading.Tasks;", 871 | "using Microsoft.AspNetCore.Builder;", 872 | "using Microsoft.AspNetCore.Hosting;", 873 | "using Microsoft.AspNetCore.Http;", 874 | "using Microsoft.Extensions.DependencyInjection;", 875 | "", 876 | "namespace WebApp", 877 | "{", 878 | "\tpublic class Startup", 879 | "\t{", 880 | "\t\tpublic void ConfigureServices(IServiceCollection services)", 881 | "\t\t{", 882 | "\t\t}", 883 | "", 884 | "\t\tpublic void Configure(IApplicationBuilder app, IHostingEnvironment env)", 885 | "\t\t{", 886 | "\t\t\tif (env.IsDevelopment())", 887 | "\t\t\t{", 888 | "\t\t\t\tapp.UseDeveloperExceptionPage();", 889 | "\t\t\t}", 890 | "", 891 | "\t\t\tapp.Run(async (context) =>", 892 | "\t\t\t{", 893 | "\t\t\t\tawait context.Response.WriteAsync(\"Hello World!\");", 894 | "\t\t\t});", 895 | "\t\t}", 896 | "\t}", 897 | "}" 898 | ], 899 | "description": "ASP.NET Core - Creates a HelloWorld sample - Startup" 900 | }, 901 | "ASP.NET Core - Creates a HelloWorld sample - WebApp":{ 902 | "prefix": "ac_#helloworld_WebApp", 903 | "body": [ 904 | "using System;", 905 | "using System.Collections.Generic;", 906 | "using System.IO;", 907 | "using System.Linq;", 908 | "using System.Threading.Tasks;", 909 | "using Microsoft.AspNetCore;", 910 | "using Microsoft.AspNetCore.Hosting;", 911 | "using Microsoft.Extensions.Configuration;", 912 | "using Microsoft.Extensions.Logging;", 913 | "", 914 | "namespace WebApp", 915 | "{", 916 | "\tpublic class Program", 917 | "\t{", 918 | "\t\tpublic static void Main(string[] args)", 919 | "\t\t{", 920 | "\t\t\tBuildWebHost(args).Run();", 921 | "\t\t}", 922 | "", 923 | "\t\tpublic static IWebHost BuildWebHost(string[] args) =>", 924 | "\t\tWebHost.CreateDefaultBuilder(args)", 925 | "\t\t\t.UseStartup()", 926 | "\t\t\t.Build();", 927 | "\t}", 928 | "}" 929 | ], 930 | "description": "ASP.NET Core - Creates a HelloWorld sample - WebApp" 931 | }, 932 | "ASP.NET Core - Creates a HelloWorld sample - WebApi":{ 933 | "prefix": "ac_#helloworld_WebApi", 934 | "body": [ 935 | "using System;", 936 | "using Microsoft.AspNetCore;", 937 | "using Microsoft.AspNetCore.Builder;", 938 | "using Microsoft.AspNetCore.Http;", 939 | "using Microsoft.AspNetCore.Routing;", 940 | "", 941 | "Console.WriteLine(\"http://localhost:5000/hello/test\");", 942 | "WebHost.Start(routes => routes.MapGet(\"hello/{name}\", (request, response, data) => response.WriteAsync($\"Hello, {data.Values[\"name\"]}\")));", 943 | "Console.ReadKey();" 944 | ], 945 | "description": "ASP.NET Core - Creates a HelloWorld sample - WebApi" 946 | }, 947 | "ASP.NET Core - Creates a MVC/Api Action":{ 948 | "prefix": "ac_action", 949 | "body": [ 950 | "[${1:HttpGet}(nameof($2))]", 951 | "public async Task ${2:ActionName}(${3:string} ${4:name})", 952 | "{", 953 | "\t$0", 954 | "\treturn Ok;", 955 | "}" 956 | ], 957 | "description": "ASP.NET Core - Creates a MVC/Api Action" 958 | }, 959 | "ASP.NET Core - Creates a comment block in ASP.NET":{ 960 | "prefix": "ac_comment", 961 | "body": [ 962 | "<%-- $0 -->" 963 | ], 964 | "description": "ASP.NET Core - Creates a comment block in ASP.NET" 965 | }, 966 | "ASP.NET Core - Creates a way to configure the JSON configuration provider":{ 967 | "prefix": "ac_conf", 968 | "body": [ 969 | "// Remember imports: using Microsoft.Extensions.Configuration;", 970 | "public IConfiguration Configuration { get; set; }", 971 | "", 972 | "public Startup(IConfiguration configuration)", 973 | "{", 974 | "\tConfiguration = configuration;", 975 | "}" 976 | ], 977 | "description": "ASP.NET Core - Creates a way to configure the JSON configuration provider" 978 | }, 979 | "ASP.NET Core - Creates a way to configure the JSON configuration provider with a custom config file":{ 980 | "prefix": "ac_conf_file", 981 | "body": [ 982 | "var builder = new ConfigurationBuilder()", 983 | ".SetBasePath(env.ContentRootPath)", 984 | ".AddJsonFile(\"${1:mySettings}.json\", optional: true, reloadOnChange: true);", 985 | "", 986 | "// Remember to create the property", 987 | "// public IConfiguration Configuration { get; set; }", 988 | "Configuration = builder.Build();" 989 | ], 990 | "description": "ASP.NET Core - Creates a way to configure the JSON configuration provider with a custom config file" 991 | }, 992 | "ASP.NET Core - Creates the base of a controller":{ 993 | "prefix": "ac_controller", 994 | "body": [ 995 | "namespace ${1:Name}.Controllers", 996 | "{", 997 | "", 998 | "\tusing Microsoft.AspNetCore.Mvc;", 999 | "", 1000 | "\tpublic class ${2:Name}Controller : Controller", 1001 | "\t{", 1002 | "\t\tpublic IActionResult Index()", 1003 | "\t\t{", 1004 | "\t\t\treturn View();", 1005 | "\t\t}", 1006 | "", 1007 | "\t\tpublic IActionResult ${3:Welcome}()", 1008 | "\t\t{", 1009 | "\t\t\tViewData[\"Message\"] = \"Your welcome message\";", 1010 | "", 1011 | "\t\t\treturn View();", 1012 | "\t\t}", 1013 | "\t}", 1014 | "}" 1015 | ], 1016 | "description": "ASP.NET Core - Creates the base of a controller" 1017 | }, 1018 | "ASP.NET Core - Creates the Startup constructor to be used with the web hosting environment":{ 1019 | "prefix": "ac_startupenv", 1020 | "body": [ 1021 | "public Startup(IHostingEnvironment env)", 1022 | "{", 1023 | "\tvar builder = new ConfigurationBuilder()", 1024 | "\t\t.SetBasePath(env.ContentRootPath)", 1025 | "\t\t.AddJsonFile(\"appsettings.json\", optional: false, reloadOnChange: true)", 1026 | "\t\t.AddJsonFile($\"appsettings.{env.EnvironmentName}.json\", optional: true)", 1027 | "\t\t.AddEnvironmentVariables();", 1028 | "", 1029 | "\tConfiguration = builder.Build();", 1030 | "}" 1031 | ], 1032 | "description": "ASP.NET Core - Creates the Startup constructor to be used with the web hosting environment" 1033 | }, 1034 | "ASP.NET Core Web Api - Creates the base of a controller":{ 1035 | "prefix": "api_controller", 1036 | "body": [ 1037 | "namespace ${1:Name}.Controllers", 1038 | "{", 1039 | "", 1040 | "\tusing Microsoft.AspNetCore.Mvc;", 1041 | "", 1042 | "\t[Route(\"api/[controller]\")]", 1043 | "\t[ApiController]", 1044 | "\tpublic class ${2:Name}Controller : ControllerBase", 1045 | "\t{", 1046 | "\t\t[HttpGet]", 1047 | "\t\tpublic async Task Get()", 1048 | "\t\t{", 1049 | "\t\t\t$0", 1050 | "\t\t\treturn Ok();", 1051 | "\t\t}", 1052 | "\t}", 1053 | "}" 1054 | ], 1055 | "description": "ASP.NET Core Web Api - Creates the base of a controller" 1056 | }, 1057 | "ASP.NET Core Web Api - Creates the Delete Action of the WebApi":{ 1058 | "prefix": "api_delete", 1059 | "body": [ 1060 | "[HttpDelete(\"{${1:value}\\}\")]", 1061 | "public async Task ${2:DeleteAsync}(${3:string} $1)", 1062 | "{", 1063 | "\t$0", 1064 | "}" 1065 | ], 1066 | "description": "ASP.NET Core Web Api - Creates the Delete Action of the WebApi" 1067 | }, 1068 | "ASP.NET Core Web Api - Creates the Get Action of the WebApi":{ 1069 | "prefix": "api_get", 1070 | "body": [ 1071 | "[HttpGet(\"{${1:value}\\}\")]", 1072 | "public async Task> ${3:GetAsync}(${4:string} $1)", 1073 | "{", 1074 | "\t$0", 1075 | "}" 1076 | ], 1077 | "description": "ASP.NET Core Web Api - Creates the Get Action of the WebApi" 1078 | }, 1079 | "ASP.NET Core Web Api - Creates the Put Action of the WebApi":{ 1080 | "prefix": "api_put", 1081 | "body": [ 1082 | "[HttpPut(\"{${1:value}\\}\")]", 1083 | "public async Task ${2:PutAsync}(${3:string} $1)", 1084 | "{", 1085 | "\t$0", 1086 | "}" 1087 | ], 1088 | "description": "ASP.NET Core Web Api - Creates the Put Action of the WebApi" 1089 | }, 1090 | "ASP.NET Core Web Api - Creates the Post Action of the WebApi":{ 1091 | "prefix": "api_post", 1092 | "body": [ 1093 | "[HttpPost(\"{${1:value}\\}\")]", 1094 | "public async Task ${2:PostAsync}([FromBody] ${3:string} $1)", 1095 | "{", 1096 | "\t$0", 1097 | "}" 1098 | ], 1099 | "description": "ASP.NET Core Web Api - Creates the Post Action of the WebApi" 1100 | }, 1101 | "ASP.NET Core Razor - Creates a code block for Razor":{ 1102 | "prefix": "rz_code", 1103 | "body": [ 1104 | "@code {", 1105 | "\t$0", 1106 | "}" 1107 | ], 1108 | "description": "ASP.NET Core Razor - Creates a code block for Razor" 1109 | }, 1110 | "ASP.NET Core Razor - Creates a comment block for Razor":{ 1111 | "prefix": "rz_comment", 1112 | "body": [ 1113 | "@* $0 *@" 1114 | ], 1115 | "description": "ASP.NET Core Razor - Creates a comment block for Razor" 1116 | }, 1117 | "ASP.NET Core Razor - Creates a directive block for Razor":{ 1118 | "prefix": "rz_directive", 1119 | "body": [ 1120 | "@{", 1121 | "\t$0", 1122 | "}" 1123 | ], 1124 | "description": "ASP.NET Core Razor - Creates a directive block for Razor" 1125 | }, 1126 | "ASP.NET Core Razor - Creates a do while loop for Razor": { 1127 | "prefix": "rz_dowhile", 1128 | "body": [ 1129 | "@{ var ${1:flag} = ${2:true}; }", 1130 | "@do", 1131 | "{", 1132 | "\t$0", 1133 | "} while ($1)" 1134 | ], 1135 | "description": "ASP.NET Core Razor - Creates a do while loop for Razor" 1136 | }, 1137 | "ASP.NET Core Razor - Creates a for statement for Razor":{ 1138 | "prefix": "rz_for", 1139 | "body": [ 1140 | "@for (var ${1:i} = 0; $1 < ${2:length}; $1++)", 1141 | "{", 1142 | "\t$0", 1143 | "}" 1144 | ], 1145 | "description": "ASP.NET Core Razor - Creates a for statement for Razor" 1146 | }, 1147 | "ASP.NET Core Razor - Creates a foreach statement for Razor":{ 1148 | "prefix": "rz_foreach", 1149 | "body": [ 1150 | "@foreach (var ${1:person} in ${2:people})", 1151 | "{", 1152 | "\t<${3:p}>${4:Name}: @$1.$4", 1153 | "\t$0", 1154 | "}" 1155 | ], 1156 | "description": "ASP.NET Core Razor - Creates a foreach statement for Razor" 1157 | }, 1158 | "ASP.NET Core Razor - Creates a functions block for Razor":{ 1159 | "prefix": "rz_functions", 1160 | "body": [ 1161 | "@functions {", 1162 | "\t$0", 1163 | "}" 1164 | ], 1165 | "description": "ASP.NET Core Razor - Creates a functions block for Razor" 1166 | }, 1167 | "ASP.NET Core Razor - Creates an if statement for Razor":{ 1168 | "prefix": "rz_if", 1169 | "body": [ 1170 | "@if (${1:true})", 1171 | "{", 1172 | "\t$0", 1173 | "}" 1174 | ], 1175 | "description": "ASP.NET Core Razor - Creates an if statement for Razor" 1176 | }, 1177 | "ASP.NET Core Razor - Creates an if else statement for Razor":{ 1178 | "prefix": "rz_ifelse", 1179 | "body": [ 1180 | "@if (${1:true})", 1181 | "{", 1182 | "\t$0", 1183 | "}", 1184 | "else", 1185 | "{", 1186 | "\t$2", 1187 | "}" 1188 | ], 1189 | "description": "ASP.NET Core Razor - Creates an if else statement for Razor" 1190 | }, 1191 | "ASP.NET Core Razor - Implements an interface for Razor":{ 1192 | "prefix": "rz_implements", 1193 | "body": [ 1194 | "@implements I${1:MyInterface}", 1195 | "", 1196 | "\t$0" 1197 | ], 1198 | "description": "ASP.NET Core Razor - Implements an interface for Razor" 1199 | }, 1200 | "ASP.NET Core Razor - Creates an inherits directive for Razor":{ 1201 | "prefix": "rz_inherits", 1202 | "body": [ 1203 | "@inherits ${1:MyClassToInheritFrom}", 1204 | "", 1205 | "\t$0" 1206 | ], 1207 | "description": "ASP.NET Core Razor - Creates an inherits directive for Razor" 1208 | }, 1209 | "ASP.NET Core Razor - Creates an inject directive for Razor":{ 1210 | "prefix": "rz_inject", 1211 | "body": [ 1212 | "@inject I${1:MyInterface} ${2:MyInterface}", 1213 | "$0" 1214 | ], 1215 | "description": "ASP.NET Core Razor - Creates an inject directive for Razor" 1216 | }, 1217 | "ASP.NET Core Razor - Specifies the model to use for Razor":{ 1218 | "prefix": "rz_model", 1219 | "body": [ 1220 | "@model ${1:MyModel}", 1221 | "$0" 1222 | ], 1223 | "description": "ASP.NET Core Razor - Specifies the model to use for Razor" 1224 | }, 1225 | "ASP.NET Core Razor - Specifies the namespace to use for Razor":{ 1226 | "prefix": "rz_namespace", 1227 | "body": [ 1228 | "@namespace ${1:MyNamespace}", 1229 | "$0" 1230 | ], 1231 | "description": "ASP.NET Core Razor - Specifies the namespace to use for Razor" 1232 | }, 1233 | "ASP.NET Core Razor - Creates a HTML markup for Razor":{ 1234 | "prefix": "rz_raw", 1235 | "body": [ 1236 | "@Html.Raw(\"<${1:span}>${2:Hello World}\")" 1237 | ], 1238 | "description": "ASP.NET Core Razor - Creates a HTML markup for Razor" 1239 | }, 1240 | "ASP.NET Core Razor - Creates a RenderBody for Razor":{ 1241 | "prefix": "rz_renderbody", 1242 | "body": [ 1243 | "@RenderBody()" 1244 | ], 1245 | "description": "ASP.NET Core Razor - Creates RenderBody for Razor" 1246 | }, 1247 | "ASP.NET Core Razor - Creates a switch statement for Razor": { 1248 | "prefix": "rz_switch", 1249 | "body": [ 1250 | "@switch (${1:value})", 1251 | "{", 1252 | "\tcase ${2:value1}:", 1253 | "\t\tbreak;", 1254 | "\tdefault:", 1255 | "\t\tbreak;", 1256 | "}", 1257 | "$0" 1258 | ], 1259 | "description": "ASP.NET Core Razor - Creates a switch statement for Razor" 1260 | }, 1261 | "ASP.NET Core Razor - Creates a try catch finally for Razor":{ 1262 | "prefix": "rz_try", 1263 | "body": [ 1264 | "@try", 1265 | "{", 1266 | "\t$0", 1267 | "}", 1268 | "catch (${1:Exception} ${2:ex})", 1269 | "{", 1270 | "\t<${3:p}>Error: @$2.Message", 1271 | "}", 1272 | "finally", 1273 | "{", 1274 | "\t", 1275 | "}" 1276 | ], 1277 | "description": "ASP.NET Core Razor - Creates a try catch finally for Razor" 1278 | }, 1279 | "ASP.NET Core Razor - Creates an using statement for Razor":{ 1280 | "prefix": "rz_using", 1281 | "body": [ 1282 | "@using (${1:Html.BeginForm()})", 1283 | "{", 1284 | "\t$0", 1285 | "}" 1286 | ], 1287 | "description": "ASP.NET Core Razor - Creates an using statement for Razor" 1288 | }, 1289 | "ASP.NET Core Razor - Creates a ViewBag for Razor": { 1290 | "prefix": "rz_viewbag", 1291 | "body": [ 1292 | "@ViewBag.${1:MyViewBagName}", 1293 | "$0" 1294 | ], 1295 | "description": "ASP.NET Core Razor - Creates a ViewBag for Razor" 1296 | }, 1297 | "ASP.NET Core Razor - Creates a ViewData for Razor": { 1298 | "prefix": "rz_viewdata", 1299 | "body": [ 1300 | "@ViewData[\"${1:myViewData}\"]", 1301 | "$0" 1302 | ], 1303 | "description": "ASP.NET Core Razor - Creates a ViewData for Razor" 1304 | }, 1305 | "ASP.NET Core Razor - Creates a while loop for Razor": { 1306 | "prefix": "rz_while", 1307 | "body": [ 1308 | "@{ var ${1:flag} = ${2:true}; }", 1309 | "@while ($1)", 1310 | "{", 1311 | "\t$0", 1312 | "\t$1 = ${3:false};", 1313 | "}" 1314 | ], 1315 | "description": "ASP.NET Core Razor - Creates a while loop for Razor" 1316 | }, 1317 | ".NET Core - Creates a MS-Test class":{ 1318 | "prefix": "mstest", 1319 | "body": [ 1320 | "using Microsoft.VisualStudio.TestTools.UnitTesting;", 1321 | "using System;", 1322 | "", 1323 | "namespace ${1:ProjectNamespace}.Test", 1324 | "{", 1325 | "\t[TestClass]", 1326 | "\tpublic class ${2:ClassName}Test", 1327 | "\t{", 1328 | "\t\t[TestMethod]", 1329 | "\t\tpublic void ${3:MethodName}()", 1330 | "\t\t{", 1331 | "\t\t\t", 1332 | "\t\t}", 1333 | "\t}", 1334 | "}" 1335 | ], 1336 | "description": "Creates a MS-Test class with the basic usings and configurable namespace, class and method names" 1337 | }, 1338 | "gRPC .Net 5 - Creates csproj for the Client":{ 1339 | "prefix": "gRPC_client_csproj", 1340 | "body": [ 1341 | "", 1342 | "", 1343 | "\t", 1344 | "\t\tnet5.0", 1345 | "\t", 1346 | "", 1347 | "\t", 1348 | "\t\t", 1349 | "", 1350 | "\t\t", 1351 | "\t\t", 1352 | "\t\t", 1353 | "\t", 1354 | "", 1355 | "" 1356 | ], 1357 | "description": "gRPC .NET 5 - Creates the csproj for the Client" 1358 | }, 1359 | "gRPC .Net 5 - Creates the Program class for a simple Client":{ 1360 | "prefix": "gRPC_client_program", 1361 | "body": [ 1362 | "using Greet;", 1363 | "using Grpc.Net.Client;", 1364 | "using System;", 1365 | "using System.Threading.Tasks;", 1366 | "", 1367 | "namespace Client", 1368 | "{", 1369 | "\tpublic class Program", 1370 | "\t{", 1371 | "\t\tpublic static async Task Main(string[] args)", 1372 | "\t\t{", 1373 | "\t\t\ttry", 1374 | "\t\t\t{", 1375 | "\t\t\t\tusing var channel = GrpcChannel.ForAddress(\"http://localhost:5000\");", 1376 | "\t\t\t\tvar client = new Greeter.GreeterClient(channel);", 1377 | "", 1378 | "\t\t\t\tvar reply = await client.SayHelloAsync(new HelloRequest { Name = \"GreeterClient\" });", 1379 | "\t\t\t\tConsole.WriteLine(\"Greeting: \" + reply.Message);", 1380 | "\t\t\t}", 1381 | "\t\t\tcatch (Exception ex)", 1382 | "\t\t\t{", 1383 | "\t\t\t\tConsole.WriteLine($\"ERROR: {ex.Message}\");", 1384 | "\t\t\t}", 1385 | "", 1386 | "\t\t\tConsole.WriteLine(\"Shutting down\");", 1387 | "\t\t\tConsole.WriteLine(\"Press any key to exit...\");", 1388 | "\t\t\tConsole.ReadKey();", 1389 | "\t\t}", 1390 | "\t}", 1391 | "}" 1392 | ], 1393 | "description": "gRPC .NET 5 - Creates the Program class for the Client" 1394 | }, 1395 | "gRPC .Net 5 - Creates a Proto sample file for the App":{ 1396 | "prefix": "gRPC_proto", 1397 | "body": [ 1398 | "// Create a Proto folder and keep there this greet.proto file", 1399 | "syntax = \"proto3\";", 1400 | "", 1401 | "package greet;", 1402 | "", 1403 | "// Greeting service definition", 1404 | "service Greeter {", 1405 | "\t// Sends a greeting", 1406 | "\trpc SayHello (HelloRequest) returns (HelloReply);", 1407 | "}", 1408 | "", 1409 | "// The request message containing the user's name", 1410 | "message HelloRequest {", 1411 | "\tstring name = 1;", 1412 | "}", 1413 | "", 1414 | "// The response message containing the greetings", 1415 | "message HelloReply {", 1416 | "\tstring message = 1;", 1417 | "}" 1418 | ], 1419 | "description": "gRPC .NET 5 - Creates a Proto sample file for the App" 1420 | }, 1421 | "gRPC .Net 5 - Creates csproj for the Server":{ 1422 | "prefix": "gRPC_server_csproj", 1423 | "body": [ 1424 | "", 1425 | "", 1426 | "\t", 1427 | "\t\tnet5.0", 1428 | "\t", 1429 | "", 1430 | "\t", 1431 | "\t\t", 1432 | "", 1433 | "\t\t", 1434 | "\t", 1435 | "", 1436 | "" 1437 | ], 1438 | "description": "gRPC .NET 5 - Creates the csproj for the Server" 1439 | }, 1440 | "gRPC .Net 5 - Creates the Program class for the Server":{ 1441 | "prefix": "gRPC_server_program", 1442 | "body": [ 1443 | "using Microsoft.AspNetCore.Hosting;", 1444 | "using Microsoft.Extensions.Hosting;", 1445 | "", 1446 | "namespace Server", 1447 | "{", 1448 | "\tpublic class Program", 1449 | "\t{", 1450 | "\t\tpublic static void Main(string[] args)", 1451 | "\t\t{", 1452 | "\t\t\tCreateHostBuilder(args).Build().Run();", 1453 | "\t\t}", 1454 | "", 1455 | "\t\tpublic static IHostBuilder CreateHostBuilder(string[] args) =>", 1456 | "\t\t\tHost.CreateDefaultBuilder(args)", 1457 | "\t\t\t\t.ConfigureWebHostDefaults(webBuilder =>", 1458 | "\t\t\t\t{", 1459 | "\t\t\t\t\twebBuilder.UseStartup();", 1460 | "\t\t\t\t});", 1461 | "\t}", 1462 | "}" 1463 | ], 1464 | "description": "gRPC .NET 5 - Creates the Program class for the Server" 1465 | }, 1466 | "gRPC .Net 5 - Creates the Service class for the Server":{ 1467 | "prefix": "gRPC_server_service", 1468 | "body": [ 1469 | "using Greet;", 1470 | "using Grpc.Core;", 1471 | "using Microsoft.Extensions.Logging;", 1472 | "using System.Threading.Tasks;", 1473 | "", 1474 | "namespace Server", 1475 | "{", 1476 | "\tpublic class GreeterService : Greeter.GreeterBase", 1477 | "\t{", 1478 | "\t\tprivate readonly ILogger _logger;", 1479 | "", 1480 | "\t\tpublic GreeterService(ILoggerFactory loggerFactory)", 1481 | "\t\t{", 1482 | "\t\t\t_logger = loggerFactory.CreateLogger();", 1483 | "\t\t}", 1484 | "", 1485 | "\t\tpublic override Task SayHello(HelloRequest request, ServerCallContext context)", 1486 | "\t\t{", 1487 | "\t\t\t_logger.LogInformation($\"Sending hello to {request.Name}\");", 1488 | "\t\t\treturn Task.FromResult(new HelloReply { Message = \"Hello \" + request.Name });", 1489 | "\t\t}", 1490 | "\t}", 1491 | "}" 1492 | ], 1493 | "description": "gRPC .NET 5 - Creates the Service class for the Server" 1494 | }, 1495 | "gRPC .Net 5 - Creates the Settings (appsettings.json) content for the Server":{ 1496 | "prefix": "gRPC_server_settings", 1497 | "body": [ 1498 | "{", 1499 | "\t\"Logging\": {", 1500 | "\t\t\"LogLevel\": {", 1501 | "\t\t\t\"Default\": \"Information\"", 1502 | "\t\t}", 1503 | "\t},", 1504 | "\t\"AllowedHosts\": \"*\",", 1505 | "\t\"Kestrel\": {", 1506 | "\t\t\"EndpointDefaults\": {", 1507 | "\t\t\t\"Protocols\": \"Http2\"", 1508 | "\t\t}", 1509 | "\t}", 1510 | "}" 1511 | ], 1512 | "description": "gRPC .NET 5 - Creates the Settings (appsettings.json) content for the Server" 1513 | }, 1514 | "gRPC .Net 5 - Creates the Startup class for the Server":{ 1515 | "prefix": "gRPC_server_startup", 1516 | "body": [ 1517 | "using Microsoft.AspNetCore.Builder;", 1518 | "using Microsoft.AspNetCore.Hosting;", 1519 | "using Microsoft.Extensions.DependencyInjection;", 1520 | "using Microsoft.Extensions.Hosting;", 1521 | "", 1522 | "namespace Server", 1523 | "{", 1524 | "\tpublic class Startup", 1525 | "\t{", 1526 | "\t\tpublic void ConfigureServices(IServiceCollection services)", 1527 | "\t\t{", 1528 | "\t\t\tservices.AddGrpc();", 1529 | "\t\t}", 1530 | "", 1531 | "\t\tpublic void Configure(IApplicationBuilder app, IWebHostEnvironment env)", 1532 | "\t\t{", 1533 | "\t\t\tif (env.IsDevelopment())", 1534 | "\t\t\t{", 1535 | "\t\t\t\tapp.UseDeveloperExceptionPage();", 1536 | "\t\t\t}", 1537 | "", 1538 | "\t\t\tapp.UseRouting();", 1539 | "", 1540 | "\t\t\tapp.UseEndpoints(endpoints =>", 1541 | "\t\t\t{", 1542 | "\t\t\t\tendpoints.MapGrpcService();", 1543 | "\t\t\t});", 1544 | "\t\t}", 1545 | "\t}", 1546 | "}" 1547 | ], 1548 | "description": "gRPC .NET 5 - Creates the Startup class for the Server" 1549 | }, 1550 | "Extension for get the MD5 value from a stream": { 1551 | "prefix": "ex_md5_from_stream", 1552 | "body": [ 1553 | "public static string GetMD5(this System.IO.Stream stream)", 1554 | "{", 1555 | "\tstream.Position = 0;", 1556 | "\tvar arrayByteHashValue = new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(stream);", 1557 | "\treturn BitConverter.ToString(arrayByteHashValue).Replace(\"-\", String.Empty).ToLower();", 1558 | "}" 1559 | ], 1560 | "description": "Extension for get the MD5 value from a stream" 1561 | }, 1562 | "Extension for convert a stream to string": { 1563 | "prefix": "ex_stream_to_string", 1564 | "body": [ 1565 | "public static string ToString(this System.IO.Stream stream)", 1566 | "{", 1567 | "\tstream.Position = 0;", 1568 | "\treturn new System.IO.StreamReader(stream).ReadToEnd();", 1569 | "}" 1570 | ], 1571 | "description": "Extension for convert a stream to string" 1572 | }, 1573 | "Extension for convert a string to stream": { 1574 | "prefix": "ex_string_to_stream", 1575 | "body": [ 1576 | "public static System.IO.Stream ConvertToStream(this string source)", 1577 | "{", 1578 | "\tvar byteArray = System.Text.Encoding.UTF8.GetBytes(source);", 1579 | "\treturn new System.IO.MemoryStream(byteArray);", 1580 | "}" 1581 | ], 1582 | "description": "Extension for convert a string to stream" 1583 | } 1584 | } 1585 | -------------------------------------------------------------------------------- /videos/csproj_2_aspnetcore_helloworld_snippet.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/J0rgeSerran0/vscode-csharp-snippets/3522981cf1700ce0e7ae13a5b57cfd5d2b67a9d8/videos/csproj_2_aspnetcore_helloworld_snippet.gif -------------------------------------------------------------------------------- /videos/csproj_2_csharp_helloworld_snippet.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/J0rgeSerran0/vscode-csharp-snippets/3522981cf1700ce0e7ae13a5b57cfd5d2b67a9d8/videos/csproj_2_csharp_helloworld_snippet.gif --------------------------------------------------------------------------------