You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add debug configuration for crontab rule triggering
Implement conditional rule execution in debug mode
Introduce DebugSetting class with AllowRuleTrigger property
Diagram Walkthrough
flowchart LR
A["CrontabSettings"] --> B["DebugSetting"]
B --> C["AllowRuleTrigger property"]
C --> D["CrontabWatcher debug logic"]
D --> E["Conditional rule execution"]
Accessing settings.Debug.AllowRuleTrigger assumes settings and settings.Debug are non-null; consider null checks or safe navigation to avoid potential NRE when debug config is missing.
In DEBUG builds, rules only execute when the title exactly equals AllowRuleTrigger; previously all matching rules executed. Confirm this intentional change and consider logging when filtered out to aid debugging.
Guard against a potential null Debug section to avoid a NullReferenceException if configuration binds it to null. Also use a case-insensitive, trimmed comparison to prevent accidental mismatches due to casing or whitespace.
#if DEBUG
- if (item.Title == settings.Debug.AllowRuleTrigger)+ var allowed = settings.Debug?.AllowRuleTrigger;+ if (!string.IsNullOrWhiteSpace(allowed) &&+ string.Equals(item.Title?.Trim(), allowed.Trim(), StringComparison.OrdinalIgnoreCase))
{
await HandleCrontabEvent(item);
- } + }
#else
Apply / Chat
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly points out that using == for string comparison is case-sensitive and can be brittle. Using a case-insensitive, null-safe comparison with trimming improves the robustness and reliability of this debug-only feature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement
Description
Add debug configuration for crontab rule triggering
Implement conditional rule execution in debug mode
Introduce
DebugSettingclass withAllowRuleTriggerpropertyDiagram Walkthrough
File Walkthrough
CrontabSettings.cs
Add debug settings configuration classsrc/Infrastructure/BotSharp.Abstraction/Crontab/Settings/CrontabSettings.cs
Debugproperty of typeDebugSettingtoCrontabSettingsDebugSettingclass withAllowRuleTriggerstring propertyCrontabWatcher.cs
Implement conditional debug rule executionsrc/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs
AllowRuleTriggersetting