diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b5bdd18
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,333 @@
+### Git ###
+*.orig
+
+
+### JetBrains ###
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff:
+.idea/workspace.xml
+.idea/tasks.xml
+
+# Sensitive or high-churn files:
+.idea/dataSources/
+.idea/dataSources.ids
+.idea/dataSources.xml
+.idea/dataSources.local.xml
+.idea/sqlDataSources.xml
+.idea/dynamic.xml
+.idea/uiDesigner.xml
+
+# Gradle:
+.idea/gradle.xml
+.idea/libraries
+
+# Mongo Explorer plugin:
+.idea/mongoSettings.xml
+
+## File-based project format:
+*.iws
+
+## Plugin-specific files:
+
+# IntelliJ
+/out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+### JetBrains Patch ###
+# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
+
+# *.iml
+# modules.xml
+# .idea/misc.xml
+# *.ipr
+
+
+### Csharp ###
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+**/Properties/launchSettings.json
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..e89574e
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+language: csharp
+mono: none
+dotnet: 2.0.0
+script:
+ - dotnet test ./src/SolidStack.Core.Guards.Tests/SolidStack.Core.Guards.Tests.csproj
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..2079683
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2018 SoftFrame
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/README.md b/README.md
index 924046e..44d2d03 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,105 @@
-solidstack
+
+
+
+
+**Quick links**:
+[Docs][docs-url],
+[Changelog][changelog-url],
+[Nuget][nuget-packages-url]
+
+[![Build status][build-status-badge]][build-url]
+[![GitHub release][github-release-badge]][license-url]
+[![MIT license][license-badge]][license-url]
+
+
+
+# What is SolidStack?
+
+SolidStack is a .NET framework consisting of several well-divided NuGet packages that allow you to focus on business logic by providing an implementation of very general design patterns useful in every kind of applications such as the [*Option Pattern*][option-pattern-url], the [*Builder Pattern*][builder-pattern-url], the [*Repository Pattern*][repository-pattern-url], the [*Unit of Work Pattern*][unit-of-work-pattern-url] and so more. In short, if you're tired of duplicated and unreadable code, this framework is for you!
+
+## Available NuGet packages
+
+### SolidStack.Core
+
+The `SolidStack.Core` namespace is the central point of all SolidStack packages, providing very generic concepts that are useful in any type of program, such as object construction, object equality, code flow and more.
+
+Package | Description
+------- | -----------
+[SolidStack.Core.Guards][solidstack.core.guards-page] | `SolidStack.Core.Guards` is an extremely simple, unambiguous and lightweight [*guard clause*][guard-clauses-url] library.
+SolidStack.Core.Flow (in progress...) | `SolidStack.Core.Flow` focuses on encapsulating the branching logic of your code so you can write a linear and much more readable code flow without having to deal with exceptions, null checks and unnecessary conditions.
+SolidStack.Core.Equality (coming soon...) | `SolidStack.Core.Equality` is primarily useful when you have to tweak the equality of an object to implement the [*Value Object Pattern*][value-object-pattern-url]. All you have to do is use one of the provided abstract classes and the complex equality logic will be done for you.
+SolidStack.Core.Construction (coming soon...) | `SolidStack.Core.Construction`'s only responsibility is to help you construct objects. You can use the [*Builder Pattern*][builder-pattern-url] provided implementation to build complex objects in a fluent way.
+
+### SolidStack.Domain (coming soon...)
+
+The `SolidStack.Domain` namespace make it easier when it's time to implement business logic by providing a strong basic implementation of the [*domain-driven design*][ddd-url] philosophy.
+
+### SolidStack.Infrastructure (coming soon...)
+
+The `SolidStack.Infrastructure` namespace provides a general implementation of many features that are not releated to business logic like memory deallocation, time, encryption, serialization and so on.
+
+### SolidStack.Persistence (coming soon...)
+
+The `SolidStack.Testing` namespace abstracts how the data is stored so that you can simply switch the way your application stores your data to almost everything such as a SQL database, a NoSQL database, local files, in memory and many more without affecting the rest of your application.
+
+### SolidStack.Testing (coming soon...)
+
+The `SolidStack.Testing` namespace provide classes to help you build highly reusable and readable tests so you can simply write tests on a given interface once and then validate each concrete type of that interface with those same tests.
+
+# How do I get started?
+
+Check out our [wiki][docs-url] to explore the documentation provided for the packages you want. There is documentation on each package available!
+
+# Where can I get it?
+
+First, [install NuGet][nuget-install-url]. Then, install the required NuGet packages avalaible on [nuget.org][nuget-idmobiles-url] using the package manager console:
+
+```
+PM> Install-Package
+```
+
+# I have an issue...
+
+First, you can check if your issue has already been tracked [here][issues-url].
+
+Otherwise, you can check if it's already fixed by pulling the [develop branch][develop-branch-url], building the solution and then using the generated DLL files direcly in your project.
+
+If you still hit a problem, please document it and post it [here][new-issue-url].
+
+# How can I contribute?
+
+Contributors are greatly appreciated, just follow the following steps:
+
+1. **Fork** the repository
+2. **Clone** the project to your own machine
+3. **Commit** changes to your own branch
+4. **Push** your work back up to your fork
+5. **Create a pull request** containing a description and your work and what is the motivation behind it
+6. **Submit your pull request** so that we can review your changes
+
+# License
+
+SolidStack is Copyright © 2018 SoftFrame under the [MIT license][license-url].
+
+
+[builder-pattern-url]: http://www.codinghelmet.com/?path=howto/advances-in-applying-the-builder-design-pattern
+[build-status-badge]: https://img.shields.io/travis/softframe/solidstack.svg?style=flat-square
+[build-url]: https://idmobiles.visualstudio.com/solidstack/_build/index?definitionId=10
+[changelog-url]: https://github.com/idmobiles/solidstack/releases
+[develop-branch-url]: https://github.com/idmobiles/solidstack/tree/develop
+[docs-url]: https://github.com/idmobiles/solidstack/wiki
+[ddd-url]: https://en.wikipedia.org/wiki/Domain-driven_design
+[github-release-badge]: https://img.shields.io/github/release/idmobiles/solidstack.svg?style=flat-square
+[issues-url]: https://github.com/idmobiles/solidstack/issues
+[github-release-url]: https://github.com/idmobiles/solidstack/releases
+[guard-clauses-url]: https://medium.com/softframe/what-are-guard-clauses-and-how-to-use-them-350c8f1b6fd2
+[license-badge]: https://img.shields.io/badge/license-MIT-orange.svg?style=flat-square
+[license-url]: https://github.com/idmobiles/solidstack/blob/master/LICENSE
+[new-issue-url]: https://github.com/idmobiles/solidstack/issues/new
+[nuget-packages-url]: https://www.nuget.org/profiles/softframe
+[nuget-install-url]: http://docs.nuget.org/docs/start-here/installing-nuget
+[option-pattern-url]: http://www.codinghelmet.com/?path=howto/understanding-the-option-maybe-functional-type
+[repository-pattern-url]: https://martinfowler.com/eaaCatalog/repository.html
+[solidstack.core.guards-page]: https://www.nuget.org/packages/SolidStack.Core
+[unit-of-work-pattern-url]: https://martinfowler.com/eaaCatalog/unitOfWork.html
+[value-object-pattern-url]: https://martinfowler.com/bliki/ValueObject.html
diff --git a/src/SolidStack.Core.Guards.Tests/GuardTests.cs b/src/SolidStack.Core.Guards.Tests/GuardTests.cs
new file mode 100644
index 0000000..0d21547
--- /dev/null
+++ b/src/SolidStack.Core.Guards.Tests/GuardTests.cs
@@ -0,0 +1,197 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using FluentAssertions;
+using SolidStack.Core.Guards.Internal;
+using SolidStack.Testing.Xunit;
+using Xunit;
+
+namespace SolidStack.Core.Guards.Tests
+{
+ public class GuardTests
+ {
+ [Fact]
+ public void Ensures_WithMatchedPredicate_DoesntThrows()
+ {
+ Action act = () => Guard.Ensures(() => true, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [DebugOnlyFact]
+ public void Ensures_WithUnmatchedPredicateInDebug_Throws()
+ {
+ Action act = () => Guard.Ensures(() => false, "error");
+
+ act.Should().Throw();
+ }
+
+ [Theory]
+ [InlineData(new[] { 0, 4, 6, 10 })]
+ public void EnsuresAll_WithMatchedPredicates_DoesntThrows(IEnumerable sequence)
+ {
+ Action act = () => Guard.EnsuresAll(sequence, n => n >= 0, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [DebugOnlyTheory]
+ [InlineData(new[] { -4, 0, 6, 10 })]
+ [InlineData(new[] { -2, -3, -5, -3 })]
+ public void EnsuresAll_WithUnmatchedPredicatesInDebug_Throws(IEnumerable sequence)
+ {
+ Action act = () => Guard.EnsuresAll(sequence, n => n >= 0, "error");
+
+ act.Should().Throw();
+ }
+
+ [Theory]
+ [InlineData(new[] { 0, 4, 6, 10 })]
+ [InlineData(new[] { -2, -3, 5, -3 })]
+ [InlineData(new[] { -2, 0, -7, -5 })]
+ public void EnsuresAny_WithMatchedPredicates_DoesntThrows(IEnumerable sequence)
+ {
+ Action act = () => Guard.EnsuresAny(sequence, n => n >= 0, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [DebugOnlyTheory]
+ [InlineData(new[] { -2, -3, -5, -3 })]
+ public void EnsuresAny_WithUnmatchedPredicatesInDebug_Throws(IEnumerable sequence)
+ {
+ Action act = () => Guard.EnsuresAny(sequence, n => n >= 0, "error");
+
+ act.Should().Throw();
+ }
+
+ [Fact]
+ public void EnsuresNonNull_WithNonNull_DoesntThrows()
+ {
+ const string nonNull = "";
+ Action act = () => Guard.EnsuresNonNull(nonNull, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [DebugOnlyFact]
+ [SuppressMessage("ReSharper", "ExpressionIsAlwaysNull")]
+ public void EnsuresNonNull_WithNullInDebug_Throws()
+ {
+ string @null = null;
+ Action act = () => Guard.EnsuresNonNull(@null, "error");
+
+ act.Should().Throw();
+ }
+
+ [Fact]
+ public void EnsuresNoNullIn_WithNoNull_DoesntThrows()
+ {
+ var sequence = new[] { "foo", "bar", "baz" };
+ Action act = () => Guard.EnsuresNoNullIn(sequence, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [DebugOnlyFact]
+ public void EnsuresNoNullIn_WithNullsInDebug_Throws()
+ {
+ var sequence = new[] { "foo", null, "baz" };
+ Action act = () => Guard.EnsuresNoNullIn(sequence, "error");
+
+ act.Should().Throw();
+ }
+
+ [Fact]
+ public void Requires_WithMatchedPredicate_DoesntThrows()
+ {
+ Action act = () => Guard.Requires(() => true, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [Fact]
+ public void Requires_WithUnmatchedPredicate_Throws()
+ {
+ Action act = () => Guard.Requires(() => false, "error");
+
+ act.Should().Throw();
+ }
+
+ [Theory]
+ [InlineData(new[] { 0, 4, 6, 10 })]
+ public void RequiresAll_WithMatchedPredicates_DoesntThrows(IEnumerable sequence)
+ {
+ Action act = () => Guard.RequiresAll(sequence, n => n >= 0, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [DebugOnlyTheory]
+ [InlineData(new[] { -4, 0, 6, 10 })]
+ [InlineData(new[] { -2, -3, -5, -3 })]
+ public void RequiresAll_WithUnmatchedPredicates_Throws(IEnumerable sequence)
+ {
+ Action act = () => Guard.RequiresAll(sequence, n => n >= 0, "error");
+
+ act.Should().Throw();
+ }
+
+ [Theory]
+ [InlineData(new[] { 0, 4, 6, 10 })]
+ [InlineData(new[] { -2, -3, 5, -3 })]
+ [InlineData(new[] { -2, 0, -7, -5 })]
+ public void RequiresAny_WithMatchedPredicates_DoesntThrows(IEnumerable sequence)
+ {
+ Action act = () => Guard.RequiresAny(sequence, n => n >= 0, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [DebugOnlyTheory]
+ [InlineData(new[] { -2, -3, -5, -3 })]
+ public void RequiresAny_WithUnmatchedPredicates_Throws(IEnumerable sequence)
+ {
+ Action act = () => Guard.RequiresAny(sequence, n => n >= 0, "error");
+
+ act.Should().Throw();
+ }
+
+ [Fact]
+ public void RequiresNonNull_WithNonNull_DoesntThrows()
+ {
+ const string nonNull = "";
+ Action act = () => Guard.RequiresNonNull(nonNull, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [Fact]
+ [SuppressMessage("ReSharper", "ExpressionIsAlwaysNull")]
+ public void RequiresNonNull_WithNull_Throws()
+ {
+ string @null = null;
+ Action act = () => Guard.RequiresNonNull(@null, "error");
+
+ act.Should().Throw();
+ }
+
+ [Fact]
+ public void RequiresNoNullIn_WithNoNull_DoesntThrows()
+ {
+ var sequence = new[] { "foo", "bar", "baz" };
+ Action act = () => Guard.RequiresNoNullIn(sequence, "error");
+
+ act.Should().NotThrow();
+ }
+
+ [DebugOnlyFact]
+ public void RequiresNoNullIn_WithNulls_Throws()
+ {
+ var sequence = new[] { "foo", null, "baz" };
+ Action act = () => Guard.RequiresNoNullIn(sequence, "error");
+
+ act.Should().Throw();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/SolidStack.Core.Guards.Tests/SolidStack.Core.Guards.Tests.csproj b/src/SolidStack.Core.Guards.Tests/SolidStack.Core.Guards.Tests.csproj
new file mode 100644
index 0000000..003e166
--- /dev/null
+++ b/src/SolidStack.Core.Guards.Tests/SolidStack.Core.Guards.Tests.csproj
@@ -0,0 +1,25 @@
+
+
+
+ netcoreapp2.0
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/SolidStack.Core.Guards/Guard.cs b/src/SolidStack.Core.Guards/Guard.cs
new file mode 100644
index 0000000..310d811
--- /dev/null
+++ b/src/SolidStack.Core.Guards/Guard.cs
@@ -0,0 +1,170 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using SolidStack.Core.Guards.Internal;
+
+namespace SolidStack.Core.Guards
+{
+ ///
+ ///
+ /// Provides guard clauses that allow you to write pre-conditions and post-conditions for your methods in a
+ /// readable way.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static class Guard
+ {
+ ///
+ /// Checks for a method post-condition; if the condition is false, displays an error message.
+ ///
+ ///
+ /// The check will be performed in trigger mode only to avoid affecting performance.
+ ///
+ /// The condition to validate.
+ /// The error message to display.
+ [Conditional("DEBUG")]
+ public static void Ensures(Func predicate, string message) =>
+ Assert(predicate, message);
+
+ ///
+ /// Checks for a method post-condition against all items in a sequence; if any condition is false, displays an error
+ /// message.
+ ///
+ ///
+ /// The check will be performed in "release" mode only to avoid affecting performance.
+ ///
+ /// The type of the sequence items.
+ /// The sequence to check.
+ /// The condition to validate.
+ /// The error message to display.
+ [Conditional("DEBUG")]
+ public static void EnsuresAll(
+ IEnumerable sequence,
+ Func predicate, string message) =>
+ Assert(() => sequence.All(predicate), message);
+
+ ///
+ /// Checks for a method post-condition against all items in a sequence; if all conditions are false, displays an error
+ /// message.
+ ///
+ ///
+ /// The check will be performed in "release" mode only to avoid affecting performance.
+ ///
+ /// The type of the sequence items.
+ /// The sequence to check.
+ /// The condition to validate.
+ /// The error message to display.
+ [Conditional("DEBUG")]
+ public static void EnsuresAny(
+ IEnumerable sequence,
+ Func predicate, string message) =>
+ Ensures(() => sequence.Any(predicate), message);
+
+ ///
+ /// Checks if a value is null as a method post-condition; if the value is null, displays an error message.
+ ///
+ ///
+ /// The check will be performed in "release" mode only to avoid affecting performance.
+ ///
+ /// The type of the value to check.
+ /// The value to check.
+ /// The error message to display.
+ [Conditional("DEBUG")]
+ public static void EnsuresNonNull(T value, string message) =>
+ Ensures(() => value != null, message);
+
+ ///
+ /// Checks if a sequence contains null items as a method post-condition; if any item is null, displays an error
+ /// message.
+ ///
+ ///
+ /// The check will be performed in "release" mode only to avoid affecting performance.
+ ///
+ /// The type of the sequence items.
+ /// The sequence to check.
+ /// The error message to display.
+ [Conditional("DEBUG")]
+ public static void EnsuresNoNullIn(IEnumerable sequence, string message) =>
+ EnsuresAll(sequence, item => item != null, message);
+
+ ///
+ /// Checks for a method pre-condition; if the condition is false, displays an error message.
+ ///
+ ///
+ /// The check will be performed in trigger mode only to avoid affecting performance.
+ ///
+ /// The condition to validate.
+ /// The error message to display.
+ ///
+ public static void Requires(Func predicate, string message) =>
+ Assert(predicate, message);
+
+ ///
+ /// Checks for a method pre-condition against all items in a sequence; if any condition is false, displays an error
+ /// message.
+ ///
+ ///
+ /// The check will be performed in "release" mode only to avoid affecting performance.
+ ///
+ /// The type of the sequence items.
+ /// The sequence to check.
+ /// The condition to validate.
+ /// The error message to display.
+ [Conditional("DEBUG")]
+ public static void RequiresAll(
+ IEnumerable sequence,
+ Func predicate, string message) =>
+ Assert(() => sequence.All(predicate), message);
+
+ ///
+ /// Checks for a method pre-condition against all items in a sequence; if all conditions are false, displays an error
+ /// message.
+ ///
+ ///
+ /// The check will be performed in "release" mode only to avoid affecting performance.
+ ///
+ /// The type of the sequence items.
+ /// The sequence to check.
+ /// The condition to validate.
+ /// The error message to display.
+ [Conditional("DEBUG")]
+ public static void RequiresAny(
+ IEnumerable sequence,
+ Func predicate, string message) =>
+ Requires(() => sequence.Any(predicate), message);
+
+ ///
+ /// Checks if a value is null as a method post-condition; if the value is null, displays an error message.
+ ///
+ /// The type of the value to check.
+ /// The value to check.
+ /// The variable name of the value to check.
+ public static void RequiresNonNull(T value, string variableName) =>
+ Requires(() => value != null, $"Receiving null {variableName}.");
+
+ ///
+ /// Checks if a sequence contains null items as a method pre-condition; if any item is null, displays an error message.
+ ///
+ ///
+ /// The check will be performed in "release" mode only to avoid affecting performance.
+ ///
+ /// The type of the sequence items.
+ /// The sequence to check.
+ /// The variable of the sequence to check.
+ [Conditional("DEBUG")]
+ public static void RequiresNoNullIn(IEnumerable sequence, string variableName) =>
+ RequiresAll(sequence, item => item != null, $"Receiving {variableName} containing one or more null items.");
+
+ private static void Assert(Func predicate, string message)
+ {
+ if (predicate())
+ return;
+
+ throw new GuardClauseException(message);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/SolidStack.Core.Guards/Internal/GuardClauseException.cs b/src/SolidStack.Core.Guards/Internal/GuardClauseException.cs
new file mode 100644
index 0000000..791a04a
--- /dev/null
+++ b/src/SolidStack.Core.Guards/Internal/GuardClauseException.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace SolidStack.Core.Guards.Internal
+{
+ ///
+ ///
+ /// The exception that is thrown when the guard clause (i.e. pre-condition / post-condition) of a method isn't respected.
+ ///
+ ///
+ /// That kind of exception should never be catch.
+ ///
+ public class GuardClauseException : Exception
+ {
+ public GuardClauseException(string message) :
+ base(message)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/SolidStack.Core.Guards/SolidStack.Core.Guards.csproj b/src/SolidStack.Core.Guards/SolidStack.Core.Guards.csproj
new file mode 100644
index 0000000..35ac886
--- /dev/null
+++ b/src/SolidStack.Core.Guards/SolidStack.Core.Guards.csproj
@@ -0,0 +1,11 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
diff --git a/src/SolidStack.Core.Guards/SolidStack.Core.Guards.nuspec b/src/SolidStack.Core.Guards/SolidStack.Core.Guards.nuspec
new file mode 100644
index 0000000..25690cf
--- /dev/null
+++ b/src/SolidStack.Core.Guards/SolidStack.Core.Guards.nuspec
@@ -0,0 +1,20 @@
+
+
+
+ SolidStack.Core.Guards
+ $version$
+ SolidStack.Core.Guards is an extremely simple, unambiguous and lightweight guard clause library.
+ $authors$
+ SolidStack
+ $projectUrl$
+ $licenseUrl$
+ $iconUrl$
+ $requireLicenseAcceptance$
+
+ $copyright$
+ SolidStack Core Guard Clause
+
+
+
+
+
\ No newline at end of file
diff --git a/src/SolidStack.Testing.Xunit/DebugOnlyFactAttribute.cs b/src/SolidStack.Testing.Xunit/DebugOnlyFactAttribute.cs
new file mode 100644
index 0000000..4d7e55a
--- /dev/null
+++ b/src/SolidStack.Testing.Xunit/DebugOnlyFactAttribute.cs
@@ -0,0 +1,11 @@
+using SolidStack.Testing.Xunit.Internal;
+using Xunit;
+
+namespace SolidStack.Testing.Xunit
+{
+ public class DebugOnlyFactAttribute : FactAttribute
+ {
+ public DebugOnlyFactAttribute() =>
+ FactSkipper.SkipInRelease(this);
+ }
+}
diff --git a/src/SolidStack.Testing.Xunit/DebugOnlyTheoryAttribute.cs b/src/SolidStack.Testing.Xunit/DebugOnlyTheoryAttribute.cs
new file mode 100644
index 0000000..f571495
--- /dev/null
+++ b/src/SolidStack.Testing.Xunit/DebugOnlyTheoryAttribute.cs
@@ -0,0 +1,11 @@
+using SolidStack.Testing.Xunit.Internal;
+using Xunit;
+
+namespace SolidStack.Testing.Xunit
+{
+ public class DebugOnlyTheoryAttribute : TheoryAttribute
+ {
+ public DebugOnlyTheoryAttribute() =>
+ FactSkipper.SkipInRelease(this);
+ }
+}
diff --git a/src/SolidStack.Testing.Xunit/Internal/FactSkipper.cs b/src/SolidStack.Testing.Xunit/Internal/FactSkipper.cs
new file mode 100644
index 0000000..858f6ea
--- /dev/null
+++ b/src/SolidStack.Testing.Xunit/Internal/FactSkipper.cs
@@ -0,0 +1,17 @@
+using Xunit;
+
+namespace SolidStack.Testing.Xunit.Internal
+{
+ internal static class FactSkipper
+ {
+ public static void SkipInRelease(FactAttribute fact) =>
+ SkipInRelease(fact, "Only running in debug mode.");
+
+ public static void SkipInRelease(FactAttribute fact, string message)
+ {
+ #if !DEBUG
+ fact.Skip = message;
+ #endif
+ }
+ }
+}
diff --git a/src/SolidStack.Testing.Xunit/SolidStack.Testing.Xunit.csproj b/src/SolidStack.Testing.Xunit/SolidStack.Testing.Xunit.csproj
new file mode 100644
index 0000000..c9d7e58
--- /dev/null
+++ b/src/SolidStack.Testing.Xunit/SolidStack.Testing.Xunit.csproj
@@ -0,0 +1,11 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
diff --git a/src/SolidStack.sln b/src/SolidStack.sln
new file mode 100644
index 0000000..ca323ae
--- /dev/null
+++ b/src/SolidStack.sln
@@ -0,0 +1,37 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27130.2024
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SolidStack.Core.Guards", "SolidStack.Core.Guards\SolidStack.Core.Guards.csproj", "{0C7E071B-021D-48F3-9306-A10B38A034D8}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SolidStack.Core.Guards.Tests", "SolidStack.Core.Guards.Tests\SolidStack.Core.Guards.Tests.csproj", "{3F4308F7-20C6-4E5E-BB94-8681BEEF3E3A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SolidStack.Testing.Xunit", "SolidStack.Testing.Xunit\SolidStack.Testing.Xunit.csproj", "{5AE73D94-930C-4AA3-AA1D-704B9B28FB5C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0C7E071B-021D-48F3-9306-A10B38A034D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0C7E071B-021D-48F3-9306-A10B38A034D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0C7E071B-021D-48F3-9306-A10B38A034D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0C7E071B-021D-48F3-9306-A10B38A034D8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3F4308F7-20C6-4E5E-BB94-8681BEEF3E3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3F4308F7-20C6-4E5E-BB94-8681BEEF3E3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3F4308F7-20C6-4E5E-BB94-8681BEEF3E3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3F4308F7-20C6-4E5E-BB94-8681BEEF3E3A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5AE73D94-930C-4AA3-AA1D-704B9B28FB5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5AE73D94-930C-4AA3-AA1D-704B9B28FB5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5AE73D94-930C-4AA3-AA1D-704B9B28FB5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5AE73D94-930C-4AA3-AA1D-704B9B28FB5C}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {A31C7CBE-244A-4FA0-9D34-B202D205602E}
+ EndGlobalSection
+EndGlobal