Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Added new snippets. #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>Contract.Ensures(!string.IsNullOrWhiteSpace(Contract.Result()))</Title>
<Shortcut>cesnw</Shortcut>
<Description>Emits an 'ensures' clause specifying result not null or white space</Description>
<Author>Jonathan de Halleux</Author>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 You could change this to your name instead. 😄

</Header>
<Snippet>
<Imports>
<Import>
<Namespace>System.Diagnostics.Contracts</Namespace>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 Rather than use this strategy, you can use a non-editable literal to automatically reference Contract using the shortest available form. It does make the behavior different, so perhaps this is best left for a separate change that gets applied to all snippets or none of them.

</Import>
</Imports>
<Declarations>
</Declarations>
<Code Language="CSharp" Kind="method body"><![CDATA[Contract.Ensures(!string.IsNullOrWhiteSpace(Contract.Result<string>()));
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>Contract.Invariant</Title>
<Shortcut>cisnw</Shortcut>
<Description>Emits a 'Contract.Invariant' not string.IsNullOrWhiteSpace clause</Description>
<Author>Jonathan de Halleux</Author>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>System.Diagnostics.Contracts</Namespace>
</Import>
</Imports>
<Declarations>
<Object Editable="true">
<ID>expression</ID>
<ToolTip>expression that is not null or white space</ToolTip>
<Default>m_X</Default>
<Function>
</Function>
</Object>
</Declarations>
<Code Language="CSharp" Kind="method body"><![CDATA[Contract.Invariant(!string.IsNullOrWhiteSpace($expression$));$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>Contract.Requires&lt;ArgumentException&gt;(!string.IsNullOrWhiteSpace(..))</Title>
<Shortcut>cresnw</Shortcut>
<Description>Emits a 'requires with exception' not IsNullOrWhiteSpace</Description>
<Author>Jonathan de Halleux</Author>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>System.Diagnostics.Contracts</Namespace>
</Import>
</Imports>
<Declarations>
<Object Editable="true">
<ID>variable</ID>
<ToolTip>argument name</ToolTip>
<Default>arg</Default>
<Function>
</Function>
</Object>
</Declarations>
<Code Language="CSharp" Kind="method body"><![CDATA[Contract.Requires<ArgumentException>(!string.IsNullOrWhiteSpace($variable$));$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>Contract.Requires(!string.IsNullOrWhiteSpace(..))</Title>
<Shortcut>crsnw</Shortcut>
<Description>Emits a 'requires' not IsNullOrWhiteSpace</Description>
<Author>Jonathan de Halleux</Author>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>System.Diagnostics.Contracts</Namespace>
</Import>
</Imports>
<Declarations>
<Object Editable="true">
<ID>variable</ID>
<ToolTip>argument name</ToolTip>
<Default>arg</Default>
<Function>
</Function>
</Object>
</Declarations>
<Code Language="CSharp" Kind="method body"><![CDATA[Contract.Requires(!string.IsNullOrWhiteSpace($variable$));$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>