Skip to content

Auto-generate strings from rules #155

@mariusz96

Description

@mariusz96

I would like strings to be auto-generated in case I have not overridden them.

Currently to achieve this I need to copy this extension method:

https://github.com/BenMorris/NetArchTest/blob/v1.3.2/samples/NetArchTest.SampleRules/ExamplePolicies.cs#L78-L115

and write my own helper methods that generate strings like:

Types in current domain that reside in namespace 'NetArchTest.SampleLibrary.Presentation' should not have dependency on 'NetArchTest.SampleLibrary.Data'.

from code like:

var architecturePolicy = Policy.Define("Example Policy", "This is an example policy")
    .For(Types.InCurrentDomain)
    .Add(t =>
       t.That()
       .ResideInNamespace("NetArchTest.SampleLibrary.Presentation")
       .ShouldNot()
       .HaveDependencyOn("NetArchTest.SampleLibrary.Data"),
       "Enforcing layered architecture", "Controllers should not directly reference repositories"
    );

and use those as rule names / descriptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions