File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
- using System . Text ;
3
2
using System . IO ;
4
3
using System . IO . Compression ;
5
- using System . Xml ;
4
+ using System . Net . Http ;
5
+ using System . Text ;
6
6
using System . Threading ;
7
7
using System . Threading . Tasks ;
8
+ using System . Xml ;
8
9
9
10
class Test
10
11
{
@@ -94,6 +95,15 @@ public IDisposable Method()
94
95
return null ;
95
96
}
96
97
98
+ public void M ( IHttpClientFactory factory )
99
+ {
100
+ // GOOD: Factory tracks and disposes.
101
+ HttpClient client1 = factory . CreateClient ( ) ;
102
+
103
+ // BAD: No Dispose call
104
+ var client2 = new HttpClient ( ) ; // $ Alert
105
+ }
106
+
97
107
// GOOD: Escapes
98
108
IDisposable Create ( ) => new Timer ( TimerProc ) ;
99
109
Original file line number Diff line number Diff line change 1
- | NoDisposeCallOnLocalIDisposable.cs:51:19:51:38 | object creation of type Timer | Disposable 'Timer' is created but not disposed. |
2
- | NoDisposeCallOnLocalIDisposable.cs:52:18:52:73 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
3
- | NoDisposeCallOnLocalIDisposable.cs:53:9:53:64 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
4
- | NoDisposeCallOnLocalIDisposable.cs:75:25:75:71 | call to method Create | Disposable 'XmlReader' is created but not disposed. |
5
- | NoDisposeCallOnLocalIDisposable.cs:75:42:75:64 | object creation of type StringReader | Disposable 'StringReader' is created but not disposed. |
6
- | NoDisposeCallOnLocalIDisposable.cs:111:22:111:56 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
1
+ | NoDisposeCallOnLocalIDisposable.cs:52:19:52:38 | object creation of type Timer | Disposable 'Timer' is created but not disposed. |
2
+ | NoDisposeCallOnLocalIDisposable.cs:53:18:53:73 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
3
+ | NoDisposeCallOnLocalIDisposable.cs:54:9:54:64 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
4
+ | NoDisposeCallOnLocalIDisposable.cs:76:25:76:71 | call to method Create | Disposable 'XmlReader' is created but not disposed. |
5
+ | NoDisposeCallOnLocalIDisposable.cs:76:42:76:64 | object creation of type StringReader | Disposable 'StringReader' is created but not disposed. |
6
+ | NoDisposeCallOnLocalIDisposable.cs:104:23:104:38 | object creation of type HttpClient | Disposable 'HttpClient' is created but not disposed. |
7
+ | NoDisposeCallOnLocalIDisposable.cs:121:22:121:56 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
You can’t perform that action at this time.
0 commit comments