Hi,

In this post I will gather my Visual Studio code snippets

First a snippet for creating a property and backing field, and raising OnPropertyChanged when the backing field has changed.

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>proppropertychanged</Title>
			<Shortcut>proppropertychanged</Shortcut>
			<Description>Code snippet for property and backing field, and raising OnPropertyChanged when the backing field has changed</Description>
			<Author>Christian Klint Baltz Nielsen</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>Property type</ToolTip>
					<Default>int</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>Property name</ToolTip>
					<Default>MyProperty</Default>
				</Literal>
				<Literal>
					<ID>field</ID>
					<ToolTip>The variable backing this property</ToolTip>
					<Default>myVar</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[private $type$ $field$;
	public $type$ $property$
	{
		get { return $field$;}
		set 
		{ 
			if($field$ != value)
			{
				$field$ = value;
				OnPropertyChanged(() => $property$);
			}
		}
	}
	$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

It will create the following code:

private string _imageLabel;
public string ImageLabel
{
	get { return _imageLabel; }
	set
	{
		if (_imageLabel != value)
		{
			_imageLabel = value;
			OnPropertyChanged(() => ImageLabel);
		}
	}
}

Another one for creating a 'lazy loading property' or 'self initializing property'

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>proplazyload</Title>
            <Shortcut>proplazyload</Shortcut>
            <Description>Code snippet for property and backing field, with initializing backing field if its null</Description>
            <Author>Christian Klint Baltz Nielsen</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>type</ID>
                    <ToolTip>Property type</ToolTip>
                    <Default>int</Default>
                </Literal>
                <Literal>
                    <ID>property</ID>
                    <ToolTip>Property name</ToolTip>
                    <Default>MyProperty</Default>
                </Literal>
                <Literal>
                    <ID>field</ID>
                    <ToolTip>The variable backing this property</ToolTip>
                    <Default>myVar</Default>
                </Literal>
            </Declarations>
            <Code Language="csharp"><![CDATA[private $type$ $field$;
    public $type$ $property$
    {
        get 
		{ 
			if($field$ == null)
			{
				$field$ = new $type$();
			}
			return $field$;
		}
    }
    $end$]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

It will create the following code:

private string _imageLabel;
public string ImageLabel
{
    get
    {
        if (_imageLabel == null)
        {
            _imageLabel = new string();
        }
        return _imageLabel;
    }
}

 

Very often I call my return variable 'result', so a snippet that 'return result' would be nice for me. Here it is:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>if</Title>
			<Shortcut>rr</Shortcut>
			<Description>Code snippet for returning result</Description>
			<Author>Christian Klint Baltz Nielsen</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
				<SnippetType>SurroundsWith</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Code Language="csharp"><![CDATA[return result; $end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

and the output:

return result;

As always feel to ask or comment.

 


You can delete a TFS branch from the Visual Studio Developer Command Prompt, using the 'tf destroy' command. The syntax is as follows:

C:\tf delete $/TeamProject/Branch

This is also valid for folder or files.

C:\tf delete $/MyTeamProject/Folder
C:\tf delete $/MyTeamProject/Folder/File

Of course remember to put any Branch/Folder/Files with spaces in, inside quotes:

C:\tf delete $/MyTeamProject/"Branch No 1" 

As always, feel free to comment, or ask.

Sometimes, and as far as I have been able to determine after I have cancelled a build, the “Find in Files” function in Visual Studio (2010 and 2012) isn’t working. It wouldn’t search all the files in my solution.
According to the below, the solution is, amoun other, to press <Ctrl + Scroll lock>. This key combination however is the only one I’ve tried.


Quote
Hi all,

Thank you for your continued interest in this bug. We have been able to reproduce the issue intermittently in several versions of Visual Studio running on several versions of Windows and have identified the root cause as external to VS. The Windows team unfortunately did not have time to fix this for their current release, but we are working with them to hopefully have this bug fixed for a future version of Windows. At present, the workaround (as many of you noted) is to press Ctrl+Scroll Lock, Ctrl+Break, or the Break key alone.

Again, thanks for all of the details you provided about this bug. If you have any further questions or comments, please feel free to post again here; although this issue was closed quite a while ago, I'll make sure it stays on our radar.

Thanks, Brittany Behrens Program Manager, VS Platform - Editor
End Quote

Unfortunately I haven’t been able to find the link to this post.


As always, feel free to comment, or ask.