Skip to content

fix: case-insensitive boolean comparison in ConditionalEvaluator#73

Merged
vaceslav merged 4 commits into
mainfrom
fix/case-sensitive-boolean-comparison
Feb 9, 2026
Merged

fix: case-insensitive boolean comparison in ConditionalEvaluator#73
vaceslav merged 4 commits into
mainfrom
fix/case-sensitive-boolean-comparison

Conversation

@vaceslav

@vaceslav vaceslav commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Closes #72

Summary

  • Bug fix: ConditionalEvaluator.AreEqual used case-sensitive ToString() comparison, causing IsActive = true / IsActive = false expressions to silently fail (C#'s true.ToString() returns "True", not "true")
  • Fix: Narrow case-insensitive comparison to boolean values only — when either side is a bool or a boolean literal ("true"/"false"). String comparisons remain case-sensitive.
  • Tests: Add 9 unit tests for explicit boolean comparisons (=, !=, nested paths, case-sensitive string guard)
  • Docs: Add = true / = false examples to condition-evaluation.md and README.md

Test plan

  • All 964 tests pass (955 existing + 9 new)
  • dotnet format --verify-no-changes clean
  • String comparisons (Status = "Active") remain case-sensitive (guarded by test)
  • != operator works correctly with boolean literals

AreEqual used case-sensitive ToString() comparison, causing expressions
like `IsActive = true` to fail because C#'s true.ToString() returns
"True" (capital T) while the literal token is "true" (lowercase).

Use OrdinalIgnoreCase comparison. Add 6 unit tests for explicit boolean
comparisons and document `= true` / `= false` syntax in docs and README.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a bug in Templify’s conditional evaluation where explicit boolean comparisons (e.g., IsActive = true) could fail due to case-sensitive string comparison of boolean values.

Changes:

  • Update ConditionalEvaluator.AreEqual to use case-insensitive string comparison.
  • Add unit tests covering explicit boolean comparisons (including nested paths).
  • Update documentation and README examples to include = true / = false comparisons.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
docs/for-developers/condition-evaluation.md Adds examples for explicit boolean comparisons in standalone condition evaluation docs.
TriasDev.Templify/Conditionals/ConditionalEvaluator.cs Changes equality comparison behavior used by conditional operators.
TriasDev.Templify.Tests/ConditionalEvaluatorTests.cs Adds unit tests validating explicit boolean equality evaluation (true/false, nested paths).
README.md Updates usage example to demonstrate IsActive = true in batch evaluation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

return left.ToString() == right.ToString();
return string.Equals(left.ToString(), right.ToString(), StringComparison.OrdinalIgnoreCase);

Copilot AI Feb 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing AreEqual to use OrdinalIgnoreCase makes all equality comparisons case-insensitive, not just boolean ones. This is a behavioral change for string comparisons (e.g., Status = Active will now match "active"), which contradicts the PR description’s claim that existing equality comparisons are unaffected and could break templates that rely on case-sensitive matching. Consider narrowing the fix to boolean comparisons only (e.g., when either side is a bool or a bool-like string, parse/compare as bool), and otherwise keep the prior case-sensitive semantics for general string equality.

Copilot uses AI. Check for mistakes.
Address review feedback: only use case-insensitive comparison when
either side is a bool or a boolean literal ("true"/"false"). String
comparisons like Status = "Active" remain case-sensitive.

Add test asserting string comparison stays case-sensitive.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vaceslav vaceslav merged commit af35c50 into main Feb 9, 2026
20 checks passed
@vaceslav vaceslav deleted the fix/case-sensitive-boolean-comparison branch February 9, 2026 15:56
@vaceslav vaceslav mentioned this pull request Feb 9, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: case-sensitive boolean comparison in ConditionalEvaluator.AreEqual

2 participants