什么是ReSharper 4+;C#的实时模板您使用吗?

什么是ReSharper 4+;C#的实时模板您使用吗?,c#,templates,refactoring,resharper,C#,Templates,Refactoring,Resharper,您使用什么ReSharper 4.0模板来制作C 让我们以以下格式共享这些内容: [标题] 可选描述 快捷方式:快捷方式 在以下位置可用:[可用性设置] // Resharper template code snippet // comes here 宏属性(如果存在): 宏1-值-可编辑发生 宏2-值-可编辑发生 请给每个答案一个宏 以下是和的一些示例,它们以建议的格式描述了活动模板 为某些类型创建新的单元测试夹具 快捷方式:ntf 可在以下文件中找到:C#2.0+文件,其中允许类

您使用什么ReSharper 4.0模板来制作C

让我们以以下格式共享这些内容:


[标题] 可选描述

快捷方式:快捷方式
在以下位置可用:[可用性设置]

// Resharper template code snippet
// comes here
宏属性(如果存在):

  • 宏1-值-可编辑发生
  • 宏2-值-可编辑发生

  • 请给每个答案一个宏
  • 以下是和的一些示例,它们以建议的格式描述了活动模板
为某些类型创建新的单元测试夹具 快捷方式:ntf
可在以下文件中找到:C#2.0+文件,其中允许类型成员声明或命名空间声明

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
宏:

  • 类型测试-无-#2
  • 测试-无-V
创建新的独立单元测试用例 快捷方式:ntc
可在以下文件中找到:C#2.0+文件,其中允许类型成员声明

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
宏:

  • 测试-无-V
实施“处置(bool)”方法 实施

快捷方式:处置

可在以下文件中找到:C#2.0+文件,其中允许类型成员声明

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
宏属性

  • 成员-建议System.IDisposable的变量-可编辑事件#1
  • -包含类型名称
为NUnit创建测试用例存根 这一个可以作为单元测试运行程序中显示的(要实现或测试的功能)提醒(与任何其他被忽略的测试一样)

快捷方式:nts
可在以下文件中找到:C#2.0+文件,其中允许类型成员声明

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
创建健全性检查以确保参数从不为空 快捷方式:eann
可在以下文件中找到:C#2.0+文件,其中允许使用类型语句

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
宏:

  • 内部-建议参数-#1
备注: 尽管此代码段的目标是开源.NET库,但它可以轻松地适应任何其他类型的参数检查。

Trace-Writeline,格式为 添加带有格式化字符串的跟踪的非常简单的模板(如Debug.WriteLine已经支持)

快捷方式:twlf
可在以下文件中找到:C#2.0+文件,其中允许使用语句

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
宏属性:

  • 参数-
    -可编辑发生
  • 掩码-
    “{0}”
    -可编辑发生

断言。AreEqual

向单元测试添加断言的简单模板

快捷方式:ae
中提供:在允许使用语句的C#2.0+文件中

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
流畅版本:

Assert.That($expected$, Is.EqualTo($actual$));$END$
新COM类 快捷方式:comclass

在允许类型成员声明或命名空间声明的:C#2.0+文件中提供

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$

  • GUID-新GUID
  • 名称-可编辑
  • 界面-可编辑
不需要断言调用 在开发WinForms应用程序时非常有用,您需要确保代码在给定项的正确线程上执行。请注意,
Control
实现
ISynchronizeInvoke

快捷方式:ani

中提供:允许使用C#2.0+文件语句

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$

  • SYNC\u INVOKE-建议
    System.ComponentModel.ISynchronizeInvoke的变量
必要时调用 在开发WinForms应用程序时非常有用,在WinForms应用程序中,方法应该可以从非UI线程调用,然后该方法应该将调用打包到UI线程上

快捷方式:inv

中提供:允许使用C#3.0+文件语句

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$

  • 方法\u名称-包含类型成员名称

您通常会将此模板用作给定方法中的第一条语句,其结果类似于:

void DoSomething(Type1 arg1)
{
    if (InvokeRequired)
    {
        Invoke((Action)delegate { DoSomething(arg1); });
        return;
    }

    // Rest of method will only execute on the correct thread
    // ...
}
MST试验方法 这有点蹩脚,但很有用。希望有人能从中得到一些有用的东西

快捷方式:testMethod

提供版本:C#2.0

快速预期异常快捷方式 只是一个快速添加到我的单元测试属性的快捷方式

快捷方式:ee

中可用:在允许类型成员声明的:C#2.0+文件中可用

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$

为当前类型声明log4net记录器

快捷方式:日志

可在以下文件中找到:C#2.0+文件,其中允许类型成员声明

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
宏属性

  • 类型-包含类型名称
NUnit设置方法 快捷方式:设置
在以下文件中可用:在允许类型成员声明的:C#2.0+文件中可用

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
努尼特拆卸法 快捷方式:拆卸
在以下文件中可用:在允许类型成员声明的:C#2.0+文件中可用

[NUnit.Framework.TestFixtureAttribute]
public sealed class $TypeToTest$Tests
{
    [NUnit.Framework.TestAttribute]
    public void $Test$()
    {
        var t = new $TypeToTest$()
        $END$
    }
}
[NUnit.Framework.TestAttribute]
public void $Test$()
{
    $END$
}
public void Dispose()
{
    Dispose(true);
    System.GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (disposing)
        {
            if ($MEMBER$ != null)
            {
                $MEMBER$.Dispose();
                $MEMBER$ = null;
            }
        }

        disposed = true;
    }
}

~$CLASS$()
{
    Dispose(false);
}

private bool disposed;
[Test, Ignore]
public void $TestName$()
{
    throw new NotImplementedException();
}
$END$
Enforce.ArgumentNotNull($inner$, "$inner$");
Trace.WriteLine(string.Format("$MASK$",$ARGUMENT$));
Assert.AreEqual($expected$, $actual$);$END$
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("$GUID$")]
public class $NAME$ : $INTERFACE$
{
    $END$
}
Debug.Assert(!$SYNC_INVOKE$.InvokeRequired, "InvokeRequired");
if (InvokeRequired)
{
    Invoke((System.Action)delegate { $METHOD_NAME$($END$); });
    return;
}
[ExpectedException(typeof($TYPE$))]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof($TYPE$));
[NUnit.Framework.SetUp]
public void SetUp()
{
    $END$
}
[NUnit.Framework.TearDown]
public void TearDown()
{
    $END$
}
[TestMethod]
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$()
{
    // Arrange
    $END$

    // Act


    // Assert

}
System.Console.WriteLine("Press <ENTER> to exit...");
System.Console.ReadLine();$END$
virtual $END$
public static readonly System.Windows.DependencyProperty $PropertyName$Property =
        System.Windows.DependencyProperty.Register("$PropertyName$",
                                                   typeof ($PropertyType$),
                                                   typeof ($OwnerType$));

    public $PropertyType$ $PropertyName$
    {
        get { return ($PropertyType$) GetValue($PropertyName$Property); }
        set { SetValue($PropertyName$Property, value); }
    }

$END$
检查变量是否为空 快捷方式:ifn
可在以下文件中找到:C#2.0+文件

if (null == $var$)
{
    $END$
}
if (null != $var$)
{
    $END$
}
new System.Guid("$GUID$")
检查变量是否不为空 快捷方式:ifnn
可在以下文件中找到:C#2.0+文件

if (null == $var$)
{
    $END$
}
if (null != $var$)
{
    $END$
}
new System.Guid("$GUID$")
新型模拟隔离器 快捷方式:假
可在以下文件中找到:[在允许使用语句的c#2.0文件中]

$TYPE$$Name$Fake=Isolate.Fake.Instance()
孤立.当调用(()=>$Name$false)

宏属性: