{"id":28625353,"url":"https://github.com/forevolve/vs-snippets","last_synced_at":"2025-07-02T07:04:02.319Z","repository":{"id":82873513,"uuid":"81856779","full_name":"ForEvolve/vs-snippets","owner":"ForEvolve","description":"Visual Studio snippets","archived":false,"fork":false,"pushed_at":"2020-05-29T17:51:22.000Z","size":19,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-12T08:11:27.410Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Vim Snippet","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ForEvolve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-13T18:26:42.000Z","updated_at":"2025-02-21T23:17:19.000Z","dependencies_parsed_at":"2023-07-02T23:15:19.018Z","dependency_job_id":null,"html_url":"https://github.com/ForEvolve/vs-snippets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ForEvolve/vs-snippets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2Fvs-snippets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2Fvs-snippets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2Fvs-snippets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2Fvs-snippets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ForEvolve","download_url":"https://codeload.github.com/ForEvolve/vs-snippets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2Fvs-snippets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263091027,"owners_count":23412343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-12T08:10:23.606Z","updated_at":"2025-07-02T07:04:02.310Z","avatar_url":"https://github.com/ForEvolve.png","language":"Vim Snippet","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Visual Studio snippets\n\n## C# Snippets\n\n### ArrangeActAssert\n\nBy typing `a` + `TAB` + `TAB` (or `aaa` + `TAB` for long) you end up with an empty failing test method body.\n\n```CSharp\n// Arrange\n$end$\n\n// Act\n\n\n// Assert\nthrow new NotImplementedException();\n```\n\n### XUnitFact\n\nBy typing `fa` + `TAB` + `TAB` (or `fact` + `TAB` for long) you end up with an empty failing test method.\n\nThe part `be_a_test_case` is selected and ready to be renamed.\nOnce you renamed your test method and pressed `Enter`, the cursor jump under `// Arrange` to keep it as productive as possible.\n\n```csharp\n[Fact]\npublic void Should_be_a_test_case()\n{\n    // Arrange\n\n\n    // Act\n\n\n    // Assert\n    throw new NotImplementedException();\n}\n```\n\nFor an `async` test case, by typing `af` + `TAB` + `TAB` (or `afact` + `TAB` for long) you end up with an empty failing test method that return an `async Task`.\n\nThe same selection/cursor location behaviors applies.\n\n```csharp\n[Fact]\npublic async Task Should_be_a_test_case()\n{\n    // Arrange\n\n\n    // Act\n\n\n    // Assert\n    throw new NotImplementedException();\n}\n```\n\n### GuardClause (field)\n\nI think that this is by far my favorite snippet.\n\nIf you define your field following the `private readonly ISomeService _fieldName;` and inject it in the controller like this `public MyController(ISomeService fieldName){}`, this snippet is for you!\n\n```CSharp\npublic class MyClass\n{\n    private readonly ISomeService _fieldName;\n    public MyClass(ISomeService fieldName){\n        // Place your cursor here\n    }\n}\n```\n\nFrom there, copy (`ctrl+c`) **fieldName**, place your cursor in the constructor body and type `g` + `TAB` + `TAB` (or `guard` + `TAB` for long) then paste (`ctrl+v`). You should endup with the following in less than a second:\n\n```CSharp\npublic class MyClass\n{\n    private readonly ISomeService _fieldName;\n    public MyClass(ISomeService fieldName){\n        _fieldName = fieldName ?? throw new ArgumentNullException(nameof(fieldName));\n    }\n}\n```\n\n**The complete sequence (this should take ±2sec):**\n\n1.  `dbl-click` OR `ctrl+click` **fieldName**\n1.  `ctrl+c`\n1.  `click` inside the constructor body\n1.  Type `g`\n1.  Hit `TAB` twice\n1.  `ctrl+v`\n1.  `ENTER`\n\n### GuardClause (old)\n\nCreate a guard clause for an injected dependency.\n\n```csharp\nif ($paramName$ == null) { throw new ArgumentNullException(nameof($paramName$)); }\n```\n\n### GuardClause (property)\n\nCreate a guard clause for an injected dependency using the 2017 construct.\nThis snippet offers two parameters: the property name and the parameter name.\n\n```csharp\n$propName$ = $paramName$ ?? throw new ArgumentNullException(nameof($paramName$));\n```\n\n### GuardClause (string)\n\nCreate a guard clause for an injected string dependency.\n\n```csharp\nif (string.IsNullOrWhiteSpace($paramName$)) { throw new ArgumentNullException(nameof($paramName$)); }\n```\n\n### ShouldBeTested\n\nCreate a failing XUnit test method named Should_be_tested. Shortcut: `sbt`.\n\n```csharp\n[Fact]\npublic void Should_be_tested()\n{\n    throw new NotImplementedException();\n}\n```\n\n### Vertical Slice Architecture\n\nHere are a few snippets that works great when implementing a Vertical Slice using the AutoMapper, FluentValidation, and MediatR stack.\n\nAll of those snippets should be used inside another class like:\n\n```csharp\npublic class MyUseCaseOrMyRazorPage\n{\n    use the snippet here\n}\n```\n\n#### Vertical Command (no return value)\n\nCreates all of the classes that are needed for a vertical slice command scenario (that does not return a value).\n\nGenerated classes:\n\n- Command\n- MapperProfile\n- Validator\n- Handler\n\n#### Vertical Command with a return value\n\nCreates all of the classes that are needed for a vertical slice command scenario that returns a value.\n\nGenerated classes:\n\n- Command\n- Result\n- MapperProfile\n- Validator\n- Handler\n\n#### Vertical Query\n\nCreates all of the classes that are needed for a vertical slice query scenario.\n\nGenerated classes:\n\n- Query\n- Result\n- MapperProfile\n- Validator\n- Handler\n\n#### Vertical Razor Pages Form (Query and Command)\n\nCreates all of the classes that are needed for a vertical slice query and command scenario inside a Razor Page (like an Edit page).\n\nGenerated classes:\n\n- Query\n- Command\n- CommandResult\n- MapperProfile\n- QueryValidator\n- CommandValidator\n- QueryHandler\n- CommandHandler\n\n#### Vertical Razor Pages Query-only\n\nCreates all of the classes that are needed for a vertical slice query-only scenario inside a Razor Page (like an Index page).\n\nGenerated classes:\n\n- Query\n- Result\n- MapperProfile\n- Validator\n- Handler\n\n## JavaScript Snippets\n\n### JSModuleDomRdy\n\nAllow to create a jQuery ready JavaScript module.\n\n```JavaScript\n; (function ($, window, document, undefined) {\n    \"use strict\"\n    $(function () {\n        // DOM READY CODE HERE...\n        ~end~\n    });\n}(jQuery, window, document));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforevolve%2Fvs-snippets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforevolve%2Fvs-snippets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforevolve%2Fvs-snippets/lists"}