Skip to content

A project that enables you to specify layers in your application explicitly.

License

Notifications You must be signed in to change notification settings

thestonehead/ExplicitLayers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


ExplicitLayers enables you to put in cross-layer dependency checks in your project.
· Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

Are you tired of having discussions with your team about how to structure your project structure? Are you sick of having layers conflated with projects just to stop "bad developers" from referencing wrong things? This is exactly what you need. This nuget will add two things to your project:

  • A Layer attribute for specifying to which layer a type (class, struct, interface) belongs to
  • Analyzers which will warn you about forbidden references between layers

(back to top)

Getting Started

The nuget is built for .Net Standard 2.0 so it should work for both .Net Framework and .Net (Core) projects.

Installation

  1. Add a nuget to your project: https://www.nuget.org/packages/ExplicitLayers/
  2. Add configuration to your .editorconfig file
dotnet_diagnostic.ExplicitLayers.comma_separated_layer_names = Domain,Infrastructure,Web
dotnet_diagnostic.ExplicitLayers.Infrastructure.comma_separated_allowed_dependencies = Domain
dotnet_diagnostic.ExplicitLayers.Web.comma_separated_allowed_dependencies = Domain,Infrastructure
dotnet_diagnostic.ExplicitLayers.Web.comma_separated_regex_paths = .*Web.*

(back to top)

Usage

Add [Layer("<layer-name>")] to your classes to specify to which layer they belong.

Add all layer names to .editorconfig config as a comma separated list dotnet_diagnostic.ExplicitLayers.comma_separated_layer_names .

Add rules for every layer to .editorconfig as a comma separated list dotnet_diagnostic.ExplicitLayers.<layer-name>.comma_separated_allowed_dependencies .

Optionally add rules to .editorconfig to specify all types on a certain path belonging to a certain layer as comma separated list of regex patterns dotnet_diagnostic.ExplicitLayers.<layer-name>.comma_separated_regex_paths.

Example of path resolution enter image description here

Example of warning for forbidden referencing enter image description here

(back to top)

Contributing

You're welcome to contribute if you think it needs something more.

(back to top)

License

Distributed under the GPL License. See LICENSE.txt for more information.

(back to top)

Contact

TheStonehead

Project Link: https://github.com/thestonehead/ExplicitLayers

(back to top)

About

A project that enables you to specify layers in your application explicitly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published