Skip to main content Link Search Menu Expand Document (external link)

Object mapping

Reference does not provide full listing, but only mentioned parts, for full listing visit LOGQ GitHub.

Marker attribute

Marker attribute LOGQ.FactAttribute marks classes that will be mapped to Fact, BoundFact, Rule, BoundRule via source generation. It has two parameters:

  • factName - suffix for generated fact classes (required)
  • mappingMode - which class members will be considered fact members (optional)

Backing fields won’t be mapped in any mode, MappingMode.MarkedData stands for members marked with LOGQ.FactMemberAttribute.

public enum MappingMode
{
    PublicProperties,
    AllProperties,
    PublicFields,
    AllFields,
    PublicPropertiesAndFields,
    AllPropertiesAndFields,
    MarkedData
}

[System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
public class FactMemberAttribute : System.Attribute {}

[System.AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
public class FactAttribute : System.Attribute
{
    public FactAttribute(string factName, MappingMode mappingMode = MappingMode.PublicProperties)
    {
        FactName = factName;
        MappingMode = mappingMode;

        if (!System.CodeDom.Compiler.CodeGenerator.IsValidLanguageIndependentIdentifier(factName))
        {
            throw new System.ArgumentException("Not a valid class name");
        }
    }

    public string FactName { get; }
    public MappingMode MappingMode { get; }
}

Indexing attributes

NoIndexingAttribute marks classes that are not suitable for fast fact-check with IIndexedFactsStorage on hashcodes.

[System.AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)]
public class NoIndexingAttribute: System.Attribute
{
    public NoIndexingAttribute() { }
}

NoHashComparableAttribute marks class members that can’t be used for indexing in IIndexedFactsStorage on hashcodes.

[System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
public class NotHashComparableAttribute: System.Attribute
{
    public NotHashComparableAttribute() { }
}

HighRuleCountDomainAttribute marks classes that are suitable for fast rule-check.

[System.AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)]
public class HighRuleCountDomainAttribute: System.Attribute
{
    public HighRuleCountDomainAttribute() { }
}

Generated data

Source generator will create classes FactFactName BoundFactFactName, RuleFactName, BoundRuleFactName, IndexedFactFactNameStorage, IndexedRuleFactNameStorage for each marked class in LOGQ.Generation namespace and functions BaseClass.AsFact, BaseClass.AsBoundFact, BaseClass.AsRule, BaseClass.AsBoundRule in static LOGQ.Generation.FactExtensions.