Skip to content

Create script folders (Editor, Runtime, and each Tests) containing assembly definition file (.asmdef)

License

Notifications You must be signed in to change notification settings

nowsprinting/create-script-folders-with-tests

Repository files navigation

Create Script Folders and Assemblies with Tests

Meta file check Test openupm Ask DeepWiki

This Unity editor extension creates script folders (Editor, Runtime, and each Tests) containing assembly definition files (.asmdef).

Features

When opening the context menu and selecting Create > C# Script Folders and Assemblies with Tests The root folder (e.g., named YourFeature) and all folders below it will be created as follows:

Creating folders and asmdefs

Using under Assets folder

Assets
└── YourFeature
   ├── Scripts
   │   ├── Editor
   │   │   └── YourFeature.Editor.asmdef
   │   └── Runtime
   │       └── YourFeature.asmdef
   └── Tests
       ├── Editor
       │   └── YourFeature.Editor.Tests.asmdef
       └── Runtime
           └── YourFeature.Tests.asmdef

Using under Packages folder

Packages
└── your.package.name
   └── YourFeature
      ├── Editor
      │   └── YourFeature.Editor.asmdef
      ├── Runtime
      │   └── YourFeature.asmdef
      └── Tests
          ├── Editor
          │   └── YourFeature.Editor.Tests.asmdef
          └── Runtime
              └── YourFeature.Tests.asmdef

Important

Package folder (e.g., named your.package.name) and package.json must be created before. Because you can not open the context menu directly under the Packages folder.

After creating folders, move the Editor, Runtime, and Tests folders directly under the your.package.name folder. And remove the YourFeature folder. Then it will be the same as the official package layout.

Packages
└── your.package.name
   ├── Editor
   │   └── YourFeature.Editor.asmdef
   ├── Runtime
   │   └── YourFeature.asmdef
   └── Tests
       ├── Editor
       │   └── YourFeature.Editor.Tests.asmdef
       └── Runtime
           └── YourFeature.Tests.asmdef

Warning

Move folders using JetBrains Rider. Because to update DotSettings files (see below).

Assembly Definition References in asmdefs

Assembly Definition References in each asmdef are set as follows:

graph RL
    Runtime
    Editor --> Runtime
    Runtime.Tests --> Runtime
    Editor.Tests --> Runtime
    Editor.Tests --> Editor
    Editor.Tests --> Runtime.Tests
Loading

Creating AssemblyInfo.cs files for friend assemblies

Creates an AssemblyInfo.cs file for each assembly to mark Assembly Definition References as Friend assemblies. This allows access to internal types and members.

Creating DotSettings files

Creates .csproj.DotSettings file for each assembly. This file is set up to make the Namespace does not correspond to file location inspection work as expected in JetBrains Rider.

This will result in the expected namespace per folder as follows:

  • Scripts/Editor: YourFeature.Editor
  • Scripts/Runtime: YourFeature
  • Tests/Editor: YourFeature.Editor
  • Tests/Runtime: YourFeature

Tip

Tests is not included in the namespace. When the same namespaces as the production code and test code are used, using directives are not required.

Specifically, disabled the Namespace provider for the following folders:

  • Scripts
  • Scripts/Runtime
  • Tests
  • Tests/Runtime

Warning

Under Packages namespace resolution works with Unity 2020.2 or later. Because to use the Root Namespace property of asmdef.

See also: Code Inspections in C# | JetBrains Rider Documentation

Installation

  1. Open the Project Settings window (Editor > Project Settings) and select Package Manager tab (figure 1.)
  2. Click + button under the Scoped Registries and enter the following settings:
    1. Name: package.openupm.com
    2. URL: https://package.openupm.com
    3. Scope(s): com.nowsprinting
  3. Open the Package Manager window (Window > Package Manager) and select My Registries tab (figure 2.)
  4. Select Create Script Folders and Assemblies with Tests and click the Install button

Figure 1. Scoped Registries setting in Project Settings window

Figure 2. My Registries in Package Manager window

License

MIT License

How to contribute

Open an issue or create a pull request.

Be grateful if you could label the pull request as enhancement, bug, chore, and documentation. See PR Labeler settings for automatically labeling from the branch name.

How to development

Clone repo as a embedded package

Add this repository as a submodule to the Packages/ directory in your project.

Run the command below:

git submodule add [email protected]:nowsprinting/create-script-folders-with-tests.git Packages/com.nowsprinting.create-script-folders-with-tests

Run tests

Generate a temporary project and run tests on each Unity version from the command line.

make create_project
UNITY_VERSION=2019.4.40f1 make -k test

Release workflow

The release process is as follows:

  1. Run Actions > Create release pull request > Run workflow
  2. Merge created pull request

Then, will do the release process automatically by Release workflow. After tagging, OpenUPM retrieves the tag and updates it.

Caution

Do NOT manually operation the following operations:

  • Create a release tag
  • Publish draft releases

Caution

You must modify the package name to publish a forked package.

About

Create script folders (Editor, Runtime, and each Tests) containing assembly definition file (.asmdef)

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 3

  •  
  •  
  •