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 11using System ;
2- using System . Text ;
32using System . IO ;
43using System . IO . Compression ;
5- using System . Xml ;
4+ using System . Net . Http ;
5+ using System . Text ;
66using System . Threading ;
77using System . Threading . Tasks ;
8+ using System . Xml ;
89
910class Test
1011{
@@ -94,6 +95,15 @@ public IDisposable Method()
9495 return null ;
9596 }
9697
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+
97107 // GOOD: Escapes
98108 IDisposable Create ( ) => new Timer ( TimerProc ) ;
99109
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