File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 4
4
using System . IO . Compression ;
5
5
using System . Xml ;
6
6
using System . Threading ;
7
+ using System . Threading . Tasks ;
7
8
8
9
class Test
9
10
{
@@ -86,6 +87,13 @@ public IDisposable Method()
86
87
using ( XmlReader . Create ( source ?? new StringReader ( "xml" ) , null ) )
87
88
;
88
89
90
+ // GOOD: Flagging these generates to much noise and there is a general
91
+ // acceptance that Tasks are not disposed.
92
+ // https://devblogs.microsoft.com/pfxteam/do-i-need-to-dispose-of-tasks/
93
+ Task t = new Task ( ( ) => { } ) ;
94
+ t . Start ( ) ;
95
+ t . Wait ( ) ;
96
+
89
97
return null ;
90
98
}
91
99
Original file line number Diff line number Diff line change 1
- | NoDisposeCallOnLocalIDisposable.cs:50:19:50:38 | object creation of type Timer | Disposable 'Timer' is created but not disposed. |
2
- | NoDisposeCallOnLocalIDisposable.cs:51:18:51:73 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
3
- | NoDisposeCallOnLocalIDisposable.cs:52:9:52:64 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
4
- | NoDisposeCallOnLocalIDisposable.cs:74:25:74:71 | call to method Create | Disposable 'XmlReader' is created but not disposed. |
5
- | NoDisposeCallOnLocalIDisposable.cs:74:42:74:64 | object creation of type StringReader | Disposable 'StringReader' is created but not disposed. |
6
- | NoDisposeCallOnLocalIDisposable.cs:79:38:79:67 | object creation of type StreamWriter | Disposable 'StreamWriter' is created but not disposed. |
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:80:38:80:67 | object creation of type StreamWriter | Disposable 'StreamWriter' is created but not disposed. |
7
+ | NoDisposeCallOnLocalIDisposable.cs:93:18:93:36 | object creation of type Task | Disposable 'Task' is created but not disposed. |
7
8
| NoDisposeCallOnLocalIDisposableBad.cs:8:22:8: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