Version 5.5.0.3

5.5.0.3 is a free minor 1 release. With this version, we end our old practice of maintaining multiple separate .NET assemblies, each targeting a different .NET framework and defining a version of the Editor for each .NET web platform currently supported by Microsoft.

This version addresses those issues by simplifying namespaces and reducing the number of assemblies required to reference Code Effects in your .NET project. Upgrading requires minor code changes if you are coming from an older version of Code Effects. See the How to Upgrade section below for details.

Code Effects now ships as only three .NET Standard 2.0 assemblies available in NuGet:

  • CodeEffects.Rule.Engine.Enterprise.dll – contains all types related to the engine (CodeEffects.Rule.Engine.dll for the Engine Free edition).
  • CodeEffects.Rule.Editor.dll – contains all types related to the editor.
  • CodeEffects.Rule.Common.dll – contains all types shared by both the engine and the editor

We also renamed the Engine Unlimited edition to Engine Enterprise.

The Editor’s client side is provided in the following files available as an npm package:

  • CodeEffects.Editor.js – the main JavaScript file that defines all client-side editor functionality.
  • CodeEffects.Common.css – the core CSS file of the editor.
  • CodeEffects.Light.css – the Light (default) theme. A new Dark theme will be introduced soon.

The main script has been modularized in order to support hundreds of existing installations of all kinds, both as a module or as a plain script, without the need to develop and maintain multiple npm packages.

  • Import the main script as a module (React, Angular, Vue, etc):

    
      // If using the npm package
      import { $rule, $ce } from "codeeffects";
    
      // If referencing the main script as a file
      import { $rule, $ce } from "../YourScriptsFolder/CodeEffects.Editor.js";
    
  • Use the main script as a plain JS file (notice the use of the module value as the script's type):

      <script type="module" src="/YourScriptsFolder/CodeEffects.Editor.js"></script>
    

Referencing or re-referencing the main script in one of these ways should allow your existing editor code to work with no issues.

Why did we choose .NET Standard 2.0 (hereafter “NS2”) for all our assemblies instead of .NET 8+? The short answer: to unify both the editor and the engine under a single standard that supports all current .NET frameworks, eliminating the need to maintain ten separate libraries (one per web framework) and four separate instances of the RuleEditor class.

From this version forward, we will no longer follow Microsoft’s official recommendations for component development on .NET web platforms. Instead, we have defined our own Code Effects implementation approach, designed to work with any legacy, current, or future .NET web platform offered by Microsoft.

According to Microsoft, .NET Standard specifies the set of .NET APIs that must be available across all .NET implementations, and it will continue to do so for the foreseeable future. NS2 includes everything required by both the Editor and the Engine, at least in the current and upcoming versions. Because NS2 can be referenced in all current .NET frameworks, both the engine and the editor now support the full spectrum:

  • .NET Standard 2.0+
  • .NET Framework 4.6.2+
  • .NET 5.0, 6.0, 7.0, 8.0, 9.0+
  • … as well as Mono 5.4+, Xamarin, UWP, Unity, and MAUI.

What's New in 5.5.0.3?

Version 5.5.0.3 does not introduce new features, but it does include important changes, bug fixes, and improvements:

The editor’s library CodeEffects.Rule.Editor:

  • Fixed a bug that, in some cases, prevented the editor from using all public in-rule and action methods when the source object inherited from an interface.
  • Fixed a bug that, in certain scenarios, caused math calculations to fail when using an in-rule method with no parameters.

The editor’s main script CodeEffects.Editor.js:

  • Removed dependency on the eval function.
  • Replaced references to the deprecated pageXOffset and pageYOffset properties with scrollX and scrollY.
  • Improved the performance of the built-in JSON parser.
  • Simplified the HTML of the optional toolbar.
  • Simplified the HTML of the built-in date picker control.
  • Simplified the HTML of the built-in time picker control.
  • Fixed minor issues with copy, cut, and paste operations on rule elements using keyboard shortcuts.
  • Improved the functionality of the $rule.Control.dispose() method.

How to Upgrade

To upgrade from any older version of Code Effects to version 5.5.0.3, do the following:

  • Remove references to all Code Effects assemblies, scripts, and CSS files from your project.

  • Get the Editor Free edition from NuGet. Contact us if you use a paid edition. Note that the Code Effects Downloader is no longer supported.

  • Update your existing using directives and code references according to the following mappings:

    In the CodeEffects.Rule.Common assembly:

    • CodeEffects.Rule.AttributesCodeEffects.Rule.Common.Attributes
    • CodeEffects.Rule.CommonCodeEffects.Rule.Common.Models
    • CodeEffects.Rule.ModelsCodeEffects.Rule.Common.Models
    • CodeEffects.Rule.CoreCodeEffects.Rule.Common.Models

    In the CodeEffects.Rule.Engine assembly:

    • CodeEffects.Rule.CommonCodeEffects.Rule.Engine
    • CodeEffects.Rule.CoreCodeEffects.Rule.Engine

    In the CodeEffects.Rule.Editor assembly:

    • CodeEffects.Rule.CoreCodeEffects.Rule.Editor.Utils
    • CodeEffects.Rule.ClientCodeEffects.Rule.Editor.Client
    • CodeEffects.Rule.ModelsCodeEffects.Rule.Editor.Models
    • CodeEffects.Rule.CommonCodeEffects.Rule.Editor
    • CodeEffects.Rule.Mvcdeprecated
    • CodeEffects.Rule.Aspdeprecated

    IMPORTANT: All declarations and functionality of the RuleEditor class have been moved into a new class CodeEffects.Rule.Editor.Control.

  • Install new Code Effects npm package and reference new files from that package in your client-side code. Follow directions in the Editor Implementation article to update your client implementation of the new editor.

Here is a C# sample of a basic rule evaluation in version 5.5.0.3:

using System;

namespace MyProject
{
	public class Result
	{
		public bool IsRuleEmpty { get; set; } = false;
		public bool IsRuleValid { get; set; } = true;

		public string Output { get; set; }
		public string ClientInvalidData { get; set; }
	}

	public class Test
	{
		private CodeEffects.Rule.Editor.Control GetControl()
		{
			var editor = new CodeEffects.Rule.Editor.Control("clientIdOfTheEditorDivElement");
			editor.SourceType = typeof(MyDataSomewhere.MySourceObject);

			editor.Mode = CodeEffects.Rule.Common.Models.RuleType.Execution;

			editor.ShowHelpString =
				editor.ShowToolBar =
				editor.ShowLineDots = false;

			return editor;
		}

		public MyProject.Result Evaluate(string ruleData)
		{
			// ruleData - JSON returned by the client method $rule.Control.extract()
			// See demo projects for client code samples

			var editor = this.GetControl();
			editor.RuleNameIsRequired = false;

			// Load the rule received from the client into the editor
			editor.LoadClientData(ruleData);

			var result = new MyProject.Result();

			if (editor.IsEmpty)
			{
				result.IsRuleEmpty = true;
				result.Output = "The rule is empty";
			}
			else if (!editor.IsValid)
			{
				result.IsRuleValid = false;
				result.Output = "The rule is invalid";
				result.ClientInvalidData = editor.GetClientInvalidData();
			}
			else
			{
				// Get XML of the rule from the editor
				var ruleXml = editor.GetRuleXml();

				// Get your data to be evaluated against that rule
				var mySourceObject = new MyDataSomewhere.MySourceObject
				{
					// Some test data
					ID = 555,
					DOB = DateTime.Now,
					FirstName = "James",
					LastName = "Smith"
				};

				// Compile the rule into IL by instantiating the Evaluator
				var ev = new CodeEffects.Rule.Engine
					.Evaluator<MyDataSomewhere.MySourceObject>(ruleXml);

				// Evaluate that compiled rule against your data
				bool success = ev.Evaluate(mySourceObject);

				// Return result to the caller
				result.Output = success ?
					"Rule evaluated to TRUE" : "Rule evaluated to FALSE";
			}

			return result;
		}
	}
}

As you can see, everything looks pretty much the same in version 5.5.0.3 except for namespaces and the new name of the old RuleEditor class.

Please read the main Code Effects Implementation article for details on how to implements Code Effects business rules engine in your project(s). Contact us if you have any questions or require technical support.


1 - Well, this version obviously includes some drastic changes compared to any of the previous versions of Code Effects, but we wanted to give it to every existing customer for free, so we had to call it "minor".

p101

p102

l097 --

l102

p101

×