Skip to main content

Declare Partial Class Part/Partial Record Part

Purpose

Creates a class part/record part in a new file and makes the current class/record partial.

You can use the Declare Partial Class Part/Declare Partial Record Part refactoring in C# projects that contain file-scoped namespace declarations.

Availability

Available when the cursor is in a class or partial class for the “Declare Partial Class Part” refactoring.

The “Declare Partial Record Part” refactoring is available when the cursor is in a record or partial record.

How to Use

  1. Place the caret in a class or partial class/record or partial record.

    using NUnit.Framework;
    
    namespace NunitTestProject {
        [TestFixture]
        public class Tests {
            [Test]
            public void Test() { }
        }
    }
    
  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

    RemoveVariable

  3. Select Declare Partial Class Part/Declare Partial Record Part from the menu.

After execution, this refactoring makes the current class/record partial and creates a file with the new part of this class/record.

RemoveVariable