McRule 4.3.1

dotnet add package McRule --version 4.3.1
                    
NuGet\Install-Package McRule -Version 4.3.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="McRule" Version="4.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="McRule" Version="4.3.1" />
                    
Directory.Packages.props
<PackageReference Include="McRule" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add McRule --version 4.3.1
                    
#r "nuget: McRule, 4.3.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package McRule@4.3.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=McRule&version=4.3.1
                    
Install as a Cake Addin
#tool nuget:?package=McRule&version=4.3.1
                    
Install as a Cake Tool

McRule

Rule based filtering using expression trees.

Predicate Grammar

Predicates are built using simple syntax to select comparison operators and methods for the specified properties on a supplied object of a specified type. That is the policy specifies the type by name, property to match against and the value the property must have. A simple equality comparison is used by default but operators can be prefixed to a policy operand for customized behavior, as shown below.

Property Type Operator Comparison Description
string * Astrisk can appear at the beginning, end or both denoting: StartsWith, EndsWith or Contains respectively.
string ~ Denotes case-insensitive comparison when used in .net, things that translate the resulting expression tree may not respect this. EF core for instance won't bind a Contains with case insensitive comparison from the string methods at all, results in a runtime error. Note: when used with wildcard, tilde operator must be first: '~*foo'.
string ! Negative expression. Must prefix all other operators.
IComparable > Greater-than comparison.
IComparable >= Greater-than or equal to comparison.
IComparable < Less-than comparison.
IComparable Less-than or equal to comparison.
IComparable <>, !=, ! Not-equal to comparison.

Note: the IComparable interface is mostly used for numerical types but custom types with comparison providers may work at runtime. Note: initial IDictionary support has been added but only for collections where the value types are strings. When missing keys are encountered, evaluation defaults to false.

Literal Values

Literal values, as needed, use handlbar syntax: {{ value }}. Null checks are implicitly added to most expressions but sometimes you need an expression that evaluates true for null values. In that case, a null literal is represented as {{null}}. Case sensitivity doesn't matter, nor does internal whitespace inside the braces. Values are interpretted like so:

var matched = handlebarPattern.Match(value);
if (matched.Success) {
    switch (matched.Groups.FirstOrDefault(x => x.Name == "literal")?.Value?.Trim()?.ToLower()) {
        case "null":
            return (true, new NullValue());
            break;
    }
}

Examples

Notes

Publish nuget package:

cd McRule/bin/Release
dotnet publish -c release ../../
dotnet nuget push --api-key $apiKey --source https://api.nuget.org/v3/index.json McRule.0.0.5.nupkg
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on McRule:

Package Downloads
McAuthz

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.3.1 253 9/8/2025
4.3.0 223 9/8/2025
4.2.0 232 9/4/2025
0.4.4 570 7/16/2024
0.4.3 216 7/15/2024
0.4.2 200 7/15/2024
0.3.1 238 3/13/2024
0.3.0 346 9/8/2023
0.2.1 273 9/2/2023 0.2.1 is deprecated because it has critical bugs.
0.1.0 310 7/11/2023 0.1.0 is deprecated because it has critical bugs.
0.0.5 314 7/7/2023 0.0.5 is deprecated because it has critical bugs.
0.0.4 364 4/3/2023 0.0.4 is deprecated because it has critical bugs.
Loading failed

Still baking. Maybe don't use this.