Skip to content

Conversation

@michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Mar 13, 2025

In this PR we make the following changes to the cs/local-not-disposed tests

  • They are converted to inline expectation.
  • They are now based on stubs
  • We remove the test that relied on CIL extraction.
  • We add examples for HttpClient and IHttpClientFactory.

cc @tamasvajk : It turns out that we handle the IHttpClientFactory.CreateClient correctly as we only perceive factory methods with the exact name Create to make objects where the user needs to handle disposal.

@github-actions github-actions bot added the C# label Mar 13, 2025
@michaelnebel michaelnebel marked this pull request as ready for review March 13, 2025 10:37
Copilot AI review requested due to automatic review settings March 13, 2025 10:37
@michaelnebel michaelnebel requested a review from a team as a code owner March 13, 2025 10:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

@michaelnebel michaelnebel merged commit 4681f28 into github:main Mar 13, 2025
15 checks passed
@michaelnebel michaelnebel deleted the csharp/local-not-disposed branch March 13, 2025 13:04
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.

2 participants