Skip to content

A package that contains functionality that we believe is commonly used across all types of different projects, and probably should've been included in the standard library.

License

Notifications You must be signed in to change notification settings

Owl-Domain/Common

Repository files navigation

OwlDomain.Common

A status badge for the latest version of the main Nuget package for the project. A status badge of the Github action workflow for building the project. A status badge of the Github action workflow for testing the project. A status badge of the Github action workflow for testing the AOT compatibility of the project. A status badge of the Github action workflow for linting the project. A status badge of the Github action workflow for publishing the project.

Status badge for the OwlDomain discord server.


A package that contains functionality that we believe is commonly used across all types of different projects, and probably should've been included in the standard library.

Installation

To use this package simply reference it from your .NET project, which will download the specified version from the nuget.org source.

In a C# project (a .csproj file) that would look like this:

<ItemGroup>
	<PackageReference Include="OwlDomain.Common" Version="1.7.0" />
</ItemGroup>

Usage

The best way (in our opinion), to use this package is by using C#'s global usings for the parts of the package that you want, for example:

global using OwlDomain.Common.Locking;
global using OwlDomain.Common.Exceptions;
global using OwlDomain.Common.Guards;

DisposableBase

The OwlDomain.Common.DisposableBase class is an abstract class that lets you easily follow the disposable pattern.

ObservableBase

The OwlDomain.Common.Observable.ObservableBase class is an abstract class that lets you raise PropertyChanging and PropertyChanged events.

Enum extensions

The OwlDomain.Common.Enums.EnumExtensions class contains several extension methods for working with enums.

Locking extensions

The OwlDomain.Common.Locking namespace contains various types for making thread locking mechanisms easier to use, where instead of doing:

SemaphoreSlim semaphore = ...;

semaphore.Wait();
try
{
	// Code goes here.
}
finally
{
	semaphore.Release();
}

you can instead do:

SemaphoreSlim semaphore = ...;

using (semaphore.Lock())
{
	// Code goes here.
}

The same approach is also available for the System.Threading.ReaderWriterLockSlim class.

Throw helpers

The OwlDomain.Common.Exceptions.Throw class acts as an entry point for throwing new exceptions through the following patterns:

// Throws System.Exception.
Throw.New.Exception("Exception message");

// Throws System.Exception, pretends to return a string value.
return Throw.New.Exception<string>("Exception message");

Argument guards

The OwlDomain.Common.Guards namespace contains extension methods that act as argument guards, and are used in the following way:

static void Foo(int value)
{
	// Throws System.ArgumentOutOfRangeException for the value parameter if it's < 5.
	value.ThrowIfLessThan(5);
}

Development

Currently this project is being developed on the develop branch, changes will be merged to main (the default branch) whenever there is a package update.

Contributions

Code contributions will not be accepted, however feel free to provide feedback / suggestions by creating a new issue, or look at the existing issues to see if your concern / suggestion has already been raised.

License

This project (the source, the release files, e.t.c) is released under the OwlDomain License.

About

A package that contains functionality that we believe is commonly used across all types of different projects, and probably should've been included in the standard library.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 2

  •  
  •