Skip to content

Fix incorrect "NOT ... OR ..." pattern in LoadExclusions filter#16349

Merged
akoeplinger merged 5 commits intomainfrom
copilot/fix-incorrect-not-or-pattern
Dec 26, 2025
Merged

Fix incorrect "NOT ... OR ..." pattern in LoadExclusions filter#16349
akoeplinger merged 5 commits intomainfrom
copilot/fix-incorrect-not-or-pattern

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 24, 2025

The pattern x is not null or "" evaluates as (x is not null) OR (x is ""), incorrectly including empty strings in the filter result. Replaced with !string.IsNullOrEmpty(x) to properly exclude both null and empty strings.

Before:

FrozenSet<string> excludeFiles = files.Where(x => x is not null or "").ToFrozenSet();

After:

FrozenSet<string> excludeFiles = files.Where(x => !string.IsNullOrEmpty(x)).ToFrozenSet();

Related: dotnet/roslyn#75506

To double check:

Original prompt

This section details on the original issue you should resolve

<issue_title>Possible incorrect use of "NOT ... OR ..." pattern</issue_title>
<issue_description>Our internal tools are flagging these blocks of code as potentially improper use of the not ... or ... pattern matching syntax.

FrozenSet<string> excludeFiles = files.Where(x => x is not null or "").ToFrozenSet();

See dotnet/roslyn#75506 for more information on why this pattern is being flagged. If this logic is correct, consider restructuring it to use clarifying () parentheses.</issue_description>

Comments on the Issue (you are @copilot in this section)

@mmitche Yeah, this is solidly wrong. Would be `x is not null and x is not ""`. Better to use `!string.IsNullOrEmpty(x)`.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix possible incorrect use of NOT ... OR ... pattern Fix incorrect "NOT ... OR ..." pattern in LoadExclusions filter Nov 24, 2025
Copilot AI requested a review from mmitche November 24, 2025 19:38
Comment thread .gitignore Outdated

# vscode python env files
.env No newline at end of file
.env.nuget/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot remove this change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 4d768ca

@mmitche mmitche marked this pull request as ready for review November 24, 2025 19:57
Copilot AI requested a review from mmitche November 24, 2025 20:02
@akoeplinger akoeplinger merged commit 47888ab into main Dec 26, 2025
10 checks passed
@akoeplinger akoeplinger deleted the copilot/fix-incorrect-not-or-pattern branch December 26, 2025 15:53
@akoeplinger
Copy link
Copy Markdown
Member

/backport to release/10.0

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/10.0 (link to workflow run)

@akoeplinger
Copy link
Copy Markdown
Member

for some reason this showed up in 10.0 today

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.

Possible incorrect use of "NOT ... OR ..." pattern

3 participants