Show / Hide Table of Contents

    Custom Scan Rules

    Quantum Console uses a set of rules to determine which code it should scan for commands. The default ruleset is designed to scan all code (except for those marked with [QcIgnore]) while avoiding some assemblies such Unity and C# libraries to improve scanning efficiency.

    Depending on your project, you may want to instruct Quantum Console to skip certain code while scanning, or you may want to forcefully scan something that would have otherwise been ignored.

    Any class implementing IQcScanRule will automatically be injected into the QuantumScanRuleset and used when getting suggestions

    Warning

    Since scan rules are injected they may be stripped out when building with managed stripping. To avoid this use see bytecode stripping

    Examples

    The following example ignores all abstract classes when scanning for commands

    using QFSW.QC;
    using System;
    using System.Reflection;
    
    public class NoAbstractScanRule : IQcScanRule
    {
        public ScanRuleResult ShouldScan<T>(T entity) where T : ICustomAttributeProvider
        {
            if (entity is Type type)
            {
                if (type.IsAbstract)
                {
                    return ScanRuleResult.Reject;
                }
            }
    
            return ScanRuleResult.Accept;
        }
    }
    

    The following example disables the included scene commands

    Tip

    This example requires a dependency on the QFSW.QC.Extras assembly in addition to the QFSW.QC assembly

    using QFSW.QC;
    using System;
    using System.Reflection;
    
    public class NoSceneCommandsScanRule : IQcScanRule
    {
        public ScanRuleResult ShouldScan<T>(T entity) where T : ICustomAttributeProvider
        {
            return entity is Type type && type == typeof(SceneCommands)
                ? ScanRuleResult.Reject
                : ScanRuleResult.Accept;
        }
    }
    
    Quantum Console by QFSW
    Back to top