Getting Started with CodeLogic.Attributes
CodeLogic.Attributes is a lightweight .NET package that enhances your code documentation and traceability by providing custom attributes to establish clear relationships between your code, tests, owners, and reviewers. This package helps teams improve code quality and maintainability by making ownership and test coverage explicit in the codebase itself.
Installation and Setup
Getting started with CodeLogic.Attributes is straightforward. You can add it to your project using the .NET CLI:
dotnet add package CodeLogic.Attributes --version {version}
Alternatively, you can use the NuGet Package Manager in Visual Studio or add a PackageReference directly to your project file.
Using the Attributes in Your Code
Once installed, add the necessary using directive to your code files. CodeLogic.Attributes provides three main attributes to enhance your code documentation:
OwnersAttribute
: Tag classes and methods with their owners to clearly identify who is responsible for maintaining specific code components. This is particularly helpful in larger teams to quickly determine who to contact about specific parts of the codebase.TestsAttribute
: Link your implementation code directly to its associated tests. This creates a clear relationship between code and tests, making it easier to ensure test coverage and update tests when implementation changes.ReviewersAttribute
: Designate specific team members as reviewers for particular code sections. This is useful for establishing review protocols and ensuring the right expertise is applied to different parts of your application.
Each attribute can be applied to classes or methods using the following syntax:
[Owners("class-owner-1", "class-owner-2")]
public class MyClass
{
// ...
}
// ---------------------------------------
[Tests("MyFirstTest", "MySecondTest")]
public class MyClass
{
// ...
}
// ---------------------------------------
[Reviewers("reviewer-username-1", "reviewer-username-2")]
public class MyClass
{
// ...
}
Scan your codebase with the CodeLogic DotNet Agent
Once you have added desired Attributes to your codebase and built an artifact, you can scan your codebase using a docker container, GitHub Action or locally installed agent.