Last active
March 25, 2020 13:49
-
-
Save kzu/d207b335469527bd97b7 to your computer and use it in GitHub Desktop.
ArgumentNullException C# Code Snippet
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
<?xml version="1.0" encoding="utf-8" ?> | |
<!-- | |
Template for a null check for a parameter. | |
Press notnull[TAB][TAB] to get it. | |
Copy to Documents\Visual Studio 2015\Code Snippets\Visual C#\My Code Snippets\notnull.snippet | |
Restart VS | |
--> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Guard null argument</Title> | |
<Shortcut>notnull</Shortcut> | |
<Description>Throw ArgumentNullException for the given argument</Description> | |
<Author>Daniel Cazzulino</Author> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
</Header> | |
<Snippet> | |
<Imports> | |
<Import> | |
<Namespace>System</Namespace> | |
</Import> | |
</Imports> | |
<Declarations> | |
<Literal> | |
<ID>argument</ID> | |
<ToolTip>Name of the argument to guard</ToolTip> | |
<Default>value</Default> | |
</Literal> | |
</Declarations> | |
<Code Language="csharp"><![CDATA[if ($argument$ == null) throw new ArgumentNullException(nameof($argument$)); | |
$end$]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment