Skip to content

Common utilities and helpers I use in my code published as source-only NuGet packages

License

Notifications You must be signed in to change notification settings

adamecr/Commons

Repository files navigation

RAD Commmons Library

It's the library of the most common utilities and helpers I use in my code published as source-only NuGet packages.

Source-only NuGet packages contain just the source code that is added to the project the package is added to. I use the source-only NuGet packages for the libraries containing the miscelaneous common code (utilities, helpers, extensions, etc.) where the individual pieces are too small that it doesn't make sense to build an assembly (regular package) for them and the whole stuff is a mixup of different functionalities that the consumers will use just a small part of the functionality but the dependency will be everywhere. For this case I create source-only packages that can have very small granularity (even the method) without polluting the consumer with huge amount of referenced assemblies that would need to be managed and distributed. When a source-only package is added to the project, it adds the source code to the compilation so the "binary" will be a part of project's assembly. It also makes easier to "read" the sources, debug and extend the libraries. Long story short: source-only NuGet packages are the libraries providing the source code to be included in consumer, not the binary.

Build

The Commons library use the customized MS Build process allowing to create and publish the source-only packages. Details about the build process are described in build documentation.

RadCommons.core Package

Based on the experience and problems I faced in real-life use, I created nuget package RadCommons.core containing BaseDisposable class, Configuration class and logging. These parts are no longer available as source-only packages mainly due to a public members and/or limitations of having them as internal (problems with inheritance in consuming code). This nuget package is needed by some of the source-only packages.

Name Summary
Configuration Simple configuration container in case DI with more sophisticated containers is not used. Supports the JSON config files, command line arguments and environment variables as sources and their hierarchy/overrides. The configuration can be used as key-value pairs or bound to objects.
CommonLogging RadCommons logging wrapper around NLog with some extended functionality.
BaseDisposable Helper class for implementation of IDisposable types.

Packages

The brief of the packages is described here, for more details see the code documentation generated by MarkupDoc.

Name Summary
RadCommons.async.AsyncManager Helpers for running the async tasks in sync mode and executing sync actions in async mode.
RadCommons.async.FileAsync Helpers for reading text files in async mode.
RadCommons.di.Component RadCommons DI Component - allows to mark and inject the component using the class attributes.
RadCommons.di.Config RadCommons DI helpers for application configuration.
RadCommons.di.PostInit RadCommons DI PostInit - allows to run post init method of component.
RadCommons.extensions.ArrayExtensions.ConcatenateBytes Adds the byte array to the current one and returns resulting array (concatenates two byte arrays into a new one).
RadCommons.extensions.ArrayExtensions.Fill Fills the array with given value.
RadCommons.extensions.EnumeratorExtensions.ToEnumerable Transforms the IEnumerator or IEnumerator to IEnumerable.
RadCommons.extensions.IEnumerableExtensions.ForEach Invokes the action for each item if IEnumerable.
RadCommons.extensions.StringExtensions.Case String case manipulation helpers.
RadCommons.extensions.StringExtensions.Html HTML related string manipulation helpers.
RadCommons.extensions.StringExtensions.Parts String splitting and parts manipulation helpers.
RadCommons.extensions.StringExtensions.Paths Path manipulation helpers for strings.
RadCommons.extensions.StringExtensions.Whitespace Whitespace manipulation helpers for strings.
RadCommons.extensions.TypeExtensions.DefaultValue Provides default value for types.
RadCommons.utils.BackgroundWorkerWithSyncCancel Executes an operation on a separate thread with possibility of sync cancel.
RadCommons.utils.ConsoleUtils Console output utilities.
RadCommons.utils.Context The runtime "container" for context operations. The context can be both state-less and state-full and it's valid until it's disposed. The current context is accessible via static property Current. The contexts are chained, when a new context is created using static method BeginContext(), the Current context became the Parent of the new one and the newly created context will be set as the Current one. When the context is disposed, the Current context is set to Parent of disposing context. The base implementation just manages the life time, context chain and keeps the state (when provided). Inherit from the Context to add the context related operations (inherited classes have the access to state). Based on the implementation of Guard Scopes by https://github.com/safakgur.
RadCommons.utils.Disposer Keeps the stack of disposable objects, and disposes them when the disposer is being disposed.
RadCommons.utils.FileUtils.Copy File copy utilities.
RadCommons.utils.MarshalExt Marshaling helpers.
RadCommons.utils.PeriodicTask Periodic (or scheduled) async task runner.
RadCommons.utils.ProcessUtils Process related utilities.
RadCommons.utils.ProcessWrapper A class the wraps a process, allowing programmatic input and output.
RadCommons.utils.Scope The runtime "container" for scoped operations. The scope can be both state-less and state-full and it's valid until it's disposed. The scopes can be nested (when the scope is disposed, the children are disposed as well) and there can be multiple child scopes (siblings) living in parallel. The base implementation just manages the life time, child scopes and keeps the state (when provided). Inherit from the Scope (and IScope) to add the scope related operations (inherited classes have the access to state)..
RadCommons.utils.Txt Text builder allowing to build strings from parts, supporting conditions, enumerations, etc.

About

Common utilities and helpers I use in my code published as source-only NuGet packages

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages