Search code examples
rule-enginebusiness-rulescodeeffects

Xml.IsRuleValid is failing after upgrade from CodeEffects 4.3.7.2 to 5


We are trying to upgrade from CodeEffects 4.3.7.2 to 5. However, our existing rule xml fail when executing CodeEffects.Rule.Common.Xml.IsRuleValid. We are just loading the Xml into an XmlDocument and calling Xml.IsRuleValid. This is all existing and working code in CodeEffects 4. Below is the exception thrown.

Value cannot be null. Parameter name: input

   at System.Xml.XmlReaderSettings.CreateReader(Stream input, Uri baseUri, String baseUriString, XmlParserContext inputContext)
   at System.Xml.XmlReader.Create(Stream input, XmlReaderSettings settings, String baseUri)
   at CodeEffects.Rule.Common.RuleXmlValidator.AddSchema(XmlSchemaSet schemas, String schemaName, Assembly assembly)
   at CodeEffects.Rule.Common.RuleXmlValidator..ctor()
   at CodeEffects.Rule.Common.Xml.IsRuleValid(XmlDocument ruleXml)

Here is a sample xml of a rule now failing in this check. "CustomerSince" and "SystemDate" are DateTime.

<?xml version="1.0" encoding="utf-8"?>
<codeeffects xmlns="http://codeeffects.com/schemas/rule/41" xmlns:ui="http://codeeffects.com/schemas/ui/4">
    <rule id="ab686e3c-e896-420c-9f8b-5fd09943c939" webrule="4.3.2.71" utc="2016-12-16T07:49:18.9753" type="CompanyABC.Domain.ICustomer, CompanyABC.Domain.State, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" eval="true">
        <definition>
            <or>
                <condition type="isNull">
                    <property name="CustomerSince" />
                </condition>
                <condition type="lessOrEqual">
                    <property name="CustomerSince" />
                    <property name="SystemDate" />
                </condition>
            </or>
        </definition>
        <format><lines /></format>
    </rule>
</codeeffects>

I tried using the CodeEffects 5 Classic MVC Rule Editor and generated the below Xml but I still see the same error.

<?xml version="1.0" encoding="utf-8"?>
<codeeffects xmlns="http://codeeffects.com/schemas/rule/41" xmlns:ui="http://codeeffects.com/schemas/ui/4">
<rule id="aecdeec9-9b06-4cb1-910d-8b62c311c72f" webrule="5.0.12.4" utc="2020-05-11T22:04:19.8510" type="CompanyABC.Domain.ICustomer, CompanyABC.Domain.State, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" eval="true">
<definition>
    <or ui:block="true">
        <condition type="isNull">
            <property name="CustomerSince" />
        </condition>
        <condition type="lessOrEqual">
            <property name="CustomerSince" />
            <property name="SystemDate" />
        </condition>
    </or>
</definition>
<format><lines /></format>
</rule>
</codeeffects>

We are using the following libraries from CodeEffects Downloader:

CodeEffects.Rule.Common.dll (5.0.4.2)

CodeEffects.Rule.Engine.Standard.dll (5.0.9.6)

And below from Nuget packages:

CodeEffects.Rule.Editor.Mvc.dll (5.0.12.4)

CodeEffects.Rule.Editor.Net.dll (5.0.12.4)

Any assistance would be appreciated.


Solution

  • This issue has been fixed in the latest minor version released earlier today.