Skip to content

VeyronSakai/VContainerAnalyzer

Repository files navigation

VContainerAnalyzer

Test NuGet

Roslyn Analyzer for detecting coding errors in Unity projects using VContainer.

Warning

This is in a very early stage of development. Please use with caution.

Setup

Unity Package Manager

VContainerAnalyzer can be set up via Unity Package Manager by following the steps below.

  1. Open the Package Manager in the UnityEditor.
  2. Select the + button in the upper left corner.
  3. Select Add package from git URL.
  4. Enter https://github.com/VeyronSakai/VContainerAnalyzer.git?path=VContainerAnalyzer.Unity/Assets/Plugins/VContainerAnalyzer#0.5.8 and Select Add button.
  5. Add VContainer.Analyzer to the Assembly Definition References of the asmdef to which you want to apply Analyzer.

.unitypackage

VContainerAnalyzer can be set up by using the .unitypackage available at Releases.

Rules

VContainer0001

Topic Value
Id VContainer0001
Severity Error
Enabled True
Category Usage

An error occurs if the constructor of a class registered by the Register() or RegisterEntryPoint() or UseEntryPoints() methods in the Lifetime class does not have an Attribute that extends PreserveAttribute such as InjectAttribute.

See the VContainer documentation for more information.

Caution

Analysis is not supported for System class inheriting from Unity.Entities.SystemBase. This is because VContainer's ECS support is beta. Also, currently the analysis is performed without considering link.xml.

VContainer0002

Topic Value
Id VContainer0002
Severity Warning
Enabled True
Category Usage

Warning occurs when using Property/Field Injection.

public class FieldInjectionSandbox
{
    [Inject] private IService _field;
}

public class PropertyInjectionSandbox
{
    [Inject] private IService Property { get; set; }
}

See the VContainer documentation for more information.

Contribution

Bugs and new feature suggestions are welcome in issues and Pull Requests.


Analyzer based on the Roslyn Analyzer Template.

About

Roslyn Analyzer for Unity Project with VContainer.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •