C#: Accept file sync mismatch for C# testfiles.#19199
Merged
michaelnebel merged 4 commits intogithub:mainfrom Apr 4, 2025
Merged
C#: Accept file sync mismatch for C# testfiles.#19199michaelnebel merged 4 commits intogithub:mainfrom
michaelnebel merged 4 commits intogithub:mainfrom
Conversation
506ed74 to
accee8b
Compare
6e49dbf to
2193bec
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates C# test file handling by allowing test file comparisons to ignore comment differences. Key changes include:
- Removing a duplicate (and buggy) method in ConstantIfCondition.cs while providing a similar test case in ConstantConditionBad.cs.
- Adding a test case for API abuse with missing Dispose calls in NoDisposeCallOnLocalIDisposableBad.cs.
- Enhancing the sync-files.py script to support file equivalence modulo comment differences by introducing new functions and modifying check_group logic.
Reviewed Changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| csharp/ql/test/query-tests/Bad Practices/Control-Flow/ConstantCondition/ConstantIfCondition.cs | Removed a redundant Max method containing a bug. |
| csharp/ql/test/query-tests/Bad Practices/Control-Flow/ConstantCondition/ConstantConditionBad.cs | Added a test file that intentionally uses a buggy Max method. |
| csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposableBad.cs | Introduced a test case highlighting missing Dispose call via an alert. |
| csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable.cs | Removed duplicate faulty implementation of Bad class. |
| config/sync-files.py | Modified file synchronization logic to consider files equivalent when differences are limited to comments. |
Files not reviewed (2)
- csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable/NoDisposeCallOnLocalIDisposable.expected: Language not supported
- csharp/ql/test/query-tests/Bad Practices/Control-Flow/ConstantCondition/ConstantCondition.expected: Language not supported
Comments suppressed due to low confidence (1)
config/sync-files.py:73
- The parameter name 'accept_prefix' in check_group shadows the global function 'accept_prefix', which may cause confusion. Consider renaming the parameter to something like 'use_comment_check' or 'ignore_comments' for improved clarity.
def check_group(group_name, files, master_file_picker, emit_error, accept_prefix):
Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more
hvitved
approved these changes
Apr 4, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
To better allow inline expectations testing, we consider test files to be identical (or equivalent), if they are "the same" modulo comments.