C#: Revisit cs/local-not-disposed tests. #19005
Merged
michaelnebel merged 4 commits intogithub:mainfrom Mar 13, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the C# tests for local not disposed objects by converting them to inline expectations, basing them on stubs, removing the CIL extraction–dependent test, and adding examples for HttpClient and IHttpClientFactory.
- Conversion of tests to inline expectation style.
- Adoption of stubs for testing disposal behavior.
- Removal of a test relying on CIL extraction and merging of bad-case tests into one file.
Reviewed Changes
Copilot reviewed 3 out of 7 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable/NoDisposeCallOnLocalIDisposable.cs | Updated test file with inline expectation alerts and additional examples using HttpClientFactory. |
| csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable/NoDisposeCallOnLocalIDisposableBad.cs | Removed file that relied on CIL extraction. |
Files not reviewed (4)
- csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable/Class1.cs_: Language not supported
- csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable/NoDisposeCallOnLocalIDisposable.expected: Language not supported
- csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable/NoDisposeCallOnLocalIDisposable.qlref: Language not supported
- csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable/options: Language not supported
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
hvitved
approved these changes
Mar 13, 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.
In this PR we make the following changes to the
cs/local-not-disposedtestsHttpClientandIHttpClientFactory.cc @tamasvajk : It turns out that we handle the
IHttpClientFactory.CreateClientcorrectly as we only perceive factory methods with the exact nameCreateto make objects where the user needs to handle disposal.