Skip to content

Support for common configuration abstractions. Sponsored by endjin.

License

Notifications You must be signed in to change notification settings

corvus-dotnet/Corvus.Configuration

Repository files navigation

Corvus.Configuration

Build Status GitHub license IMM

This provides utilities for enabling an application to adapt to the constraints in which it will run.

It is built for netstandard2.0.

Features

INameProvider

The name provider allows you to generate a name for a given base, having applied some constraints. This is typically used to take a string from one service, and convert it into a form that is useful for a third party service that applies particular constraints (e.g. Azure blob container names)

The ProvideName() method will generate a name based on a stem, optionally specificing a maximum length and forcing to upper or lower case. Each time you call it, you will get a unique name.

e.g.

INameProvider provider;
string someName = provider.ProvideName("myBase", 64, NameCase.LowerInvariant); 
string someOtherName = provider.ProvideName("myBase", 64, NameCase.LowerInvariant);

There is also the ProvideRepeatableName() method, which will generate a name based on a stem with the same optional constraints, but will guarantee to provide the same name for the same stem.

e.g.

INameProvider provider;
string someName = provider.ProvideRepeatableName("myBase", 64, NameCase.LowerInvariant); 
string someSameName = provider.ProvideRepeatableName("myBase", 64, NameCase.LowerInvariant);

Debug.Assert(someName == someSameName);

ITestNameProvider

In addition to the standard INameProvider implementation, there is an ITestNameProvider interface.

You can begin a test by calling BeginTestSession(Guid.NewGuid()).

This sets the TestId for the name provider to the test session ID you passed in.

Once you have done this, it is expected that implementations will append the test session GUID to any names that you create (before constraints are applied).

CompleteTestSession() will clear the current TestId and Reset() the name provider cache.

This helps you create unique names for entities in your tests that are scoped to that test (and therefore easily identifiable), but will not clash with any concurrent test executions in shared test infrastructure.

Microsoft.Extensions.DependencyInjection

NameProvider

You can register the default INameProvider in the Microsoft.Extensions.DependencyInjection DI container using the serviceCollection.AddNameProvider() extension method.

TestNameProvider

You can register a standard implementation of the test INameProvider in the Microsoft.Extensions.DependencyInjection DI container using the serviceCollection.AddTestNameProvider() extension method. Once you have done this, you can access it as both the INameProvider service, and the ITestNameProvider service.

Custom implementations

You can easily create custom name provider implementations that add specific constraints for different use cases. It allows you to separate common naming concerns from the services that use them.

Licenses

GitHub license

Corvus.Configuration is available under the Apache 2.0 open source license.

For any licensing questions, please email licensing@endjin.com

Project Sponsor

This project is sponsored by endjin, a UK based Microsoft Gold Partner for Cloud Platform, Data Platform, Data Analytics, DevOps, and a Power BI Partner.

For more information about our products and services, or for commercial support of this project, please contact us.

We produce two free weekly newsletters; Azure Weekly for all things about the Microsoft Azure Platform, and Power BI Weekly.

Keep up with everything that's going on at endjin via our blog, follow us on Twitter, or LinkedIn.

Our other Open Source projects can be found on GitHub

Code of conduct

This project has adopted a code of conduct adapted from the Contributor Covenant to clarify expected behavior in our community. This code of conduct has been adopted by many other projects. For more information see the Code of Conduct FAQ or contact hello@endjin.com with any additional questions or comments.

IP Maturity Matrix (IMM)

The IMM is endjin's IP quality framework.

Shared Engineering Standards

Coding Standards

Executable Specifications

Code Coverage

Benchmarks

Reference Documentation

Design & Implementation Documentation

How-to Documentation

Date of Last IP Review

Framework Version

Associated Work Items

Source Code Availability

License

Production Use

Insights

Packaging

Deployment

OpenChain