Skip to content

C#: Simplify the ConstantCondition query.#21599

Draft
aschackmull wants to merge 1 commit intogithub:mainfrom
aschackmull:csharp/constantcondition-simplify
Draft

C#: Simplify the ConstantCondition query.#21599
aschackmull wants to merge 1 commit intogithub:mainfrom
aschackmull:csharp/constantcondition-simplify

Conversation

@aschackmull
Copy link
Copy Markdown
Contributor

Several simplifications are made (motivated by the upcoming CFG switch):

  • Constant boolean conditions are restricted to comparisons - literal true/false are seldom interesting alerts and the special-casing for isNullOrEmpty called on constants that happens inside the CFG construction seems a bit too narrow to warrant attention, and it's not something that'll be preserved in the new CFG. This allows us to get rid of all the allow-listing that was due to the the CFG round-trip.
  • The constant nullness implementation is short-circuited instead of relying on the CFG round-trip.
  • Constant matching seemed to silly to keep - switching on constants or obviously disjoint types is the kind of thing that only really happens in silly synthetic test cases. And any real occurrences are better handled by an LLM anyway.

@github-actions github-actions bot added the C# label Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant