Skip to content

C#: Convert qlref tests to inline expectations#22123

Merged
owen-mc merged 8 commits into
github:mainfrom
owen-mc:csharp/convert-qlref-tests-to-inline-expectations
Jul 8, 2026
Merged

C#: Convert qlref tests to inline expectations#22123
owen-mc merged 8 commits into
github:mainfrom
owen-mc:csharp/convert-qlref-tests-to-inline-expectations

Conversation

@owen-mc

@owen-mc owen-mc commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Convert suitable qlref tests to inline expectations. Done by Copilot (Opus 4.8).

@github-actions github-actions Bot added the C# label Jul 4, 2026
Comment thread csharp/ql/test/query-tests/Configuration/PasswordInConfigurationFile/config.xml Dismissed
Comment thread csharp/ql/test/query-tests/Configuration/PasswordInConfigurationFile/config.xml Dismissed
Comment thread csharp/ql/test/query-tests/Configuration/PasswordInConfigurationFile/config.xml Dismissed
Comment thread csharp/ql/test/query-tests/Configuration/PasswordInConfigurationFile/config.xml Dismissed
Comment thread csharp/ql/test/query-tests/Security Features/CWE-011/bad1/Web.config Dismissed
Comment thread csharp/ql/test/query-tests/Security Features/CWE-548/web.config Dismissed
Comment thread csharp/ql/test/query-tests/ASP/BlockCodeResponseWrite/BlockCodeResponseWriteBad.aspx Dismissed
Comment thread csharp/ql/test/query-tests/ASP/BlockCodeResponseWrite/test.aspx Dismissed
@owen-mc owen-mc force-pushed the csharp/convert-qlref-tests-to-inline-expectations branch 2 times, most recently from 800482d to c0273ba Compare July 4, 2026 22:35
@owen-mc owen-mc force-pushed the csharp/convert-qlref-tests-to-inline-expectations branch from 8579a93 to 69c4d4e Compare July 6, 2026 13:34
@owen-mc owen-mc force-pushed the csharp/convert-qlref-tests-to-inline-expectations branch from 31fb2e6 to f67b729 Compare July 7, 2026 13:10
@owen-mc owen-mc marked this pull request as ready for review July 8, 2026 10:19
Copilot AI review requested due to automatic review settings July 8, 2026 10:19
@owen-mc owen-mc requested a review from a team as a code owner July 8, 2026 10:19
@owen-mc owen-mc added the no-change-note-required This PR does not need a change note label Jul 8, 2026
@owen-mc

owen-mc commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

I've never had CodeQL alerts from editing test files in any other language I've interacted with. Is there perhaps some configuration change that could be made so that CodeQL doesn't scan the test folders?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@geoffw0 geoffw0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's going on with the last commit ("Revert inline expectations for blazor integration tests with BMN") - should these be marked as MISSING: results???

Comment thread csharp/ql/campaigns/Solorigate/test/Solorigate/test.cs Outdated
Comment thread csharp/ql/campaigns/Solorigate/test/Solorigate/test.cs Outdated
C1 Field2; // BAD

public virtual void Dispose()
public virtual void Dispose() // $ Alert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The alert locations in this file aren't super helpful, it's really the field (which is in the alert message) that's of interest. I'm not sure what to suggest. The .expected file should still contain the full alert message anyway.

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.

For this PR I think it's fine as it is. In an ideal world we could refactor the logic from the ql file into a .qll file (or use a postprocessing query) and make a more in-depth inline expectations test. But I think our time is better spent elsewhere.

Comment thread csharp/ql/test/query-tests/CSI/CompareIdenticalValues/CompareIdenticalValues.cs Outdated
Comment thread csharp/ql/test/query-tests/Language Abuse/UselessCastToSelf/UselessCastToSelf.cs Outdated
Comment thread csharp/ql/test/query-tests/Language Abuse/UselessCastToSelf/UselessCastToSelf.cs Outdated
Comment thread csharp/ql/test/query-tests/Security Features/CWE-807/ConditionalBypass.cs Outdated
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
@owen-mc

owen-mc commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

The last commit ("Revert inline expectations for blazor integration tests with BMN") is there because it turns out that in BMN mode, we don't extract razor comments. This is probably fixable, and I've given the suggestions from copilot about how to approach it to the relevant team, but I believe it is out of the scope of this PR. (And it may not be worth it at all, if this is the only use case.) To make this PR mergeable I have taken the decision to not use inline expectations for the two integration tests that this affects.

@owen-mc owen-mc requested a review from geoffw0 July 8, 2026 12:58

@geoffw0 geoffw0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for addressing / answering my comments.

@owen-mc owen-mc merged commit 25cd352 into github:main Jul 8, 2026
26 checks passed
@owen-mc owen-mc deleted the csharp/convert-qlref-tests-to-inline-expectations branch July 8, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants