IntelliTect / CodingGuidelines

A repository to contain IntelliTect's tools for coding conventions
https://intellitect.github.io/CodingGuidelines/
MIT License
11 stars 17 forks source link

Non-Nullable Property Code Snippet Sharing? #114

Closed meghanmae closed 4 years ago

meghanmae commented 4 years ago

I created a snippet for non-nullable property declarations, is there a way to share this?

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>NonNullableProperty</Title>
            <Shortcut>NonNullProp</Shortcut>
            <Description>Code snippit for setting non nullable property</Description>
            <Author>IntelliTect - Meghan Woodford</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>DataType</ID>
                    <ToolTip>Property type</ToolTip>
                    <Default>int</Default>
                </Literal>
                <Literal>
                    <ID>PropertyName</ID>
                    <ToolTip>Property name</ToolTip>
                    <Default>MyProperty</Default>
                </Literal>
            </Declarations>
            <Code Language="csharp">
                <![CDATA[private $DataType$? _$PropertyName$;
        public $DataType$ $PropertyName$ { 
            get => _$PropertyName$!; 
            set => _$PropertyName$ = value ?? throw new ArgumentNullException(nameof(value)); 
        }]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>
adamskt commented 4 years ago

I don't think we have an IntelliTect snippet repo, but several of us share our dotfiles on GitHub (https://github.com/SteveByerly/dotfiles, https://github.com/adamskt/danja-zown, Kevin has his in OneDrive) Additionally, there are things that inherit from CodeFixProvider in https://github.com/IntelliTect/CodingGuidelines/tree/master/IntelliTect.Analyzer/IntelliTect.Analyzer/CodeFixes

Keboo commented 4 years ago

I think we should look at adding snippets to these repos. I have moved away from R# so have found myself wanting these more and more.

Keboo commented 4 years ago

As per discussion we need to do the following:

Keboo commented 4 years ago

This has been added to snippets. https://github.com/IntelliTect/IntelliTect.Snippets