Skip to content

Commit 16142a2

Browse files
committed
C#: Add NoDisposeCallOnLocalIDisposableBad file and update test expected output.
1 parent 2193bec commit 16142a2

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable/NoDisposeCallOnLocalIDisposable.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,6 @@ void TimerProc(object obj)
114114
public void Dispose() { }
115115
}
116116

117-
class Bad
118-
{
119-
long GetLength(string file)
120-
{
121-
var stream = new FileStream(file, FileMode.Open); // $ Alert
122-
return stream.Length;
123-
}
124-
}
125-
126117
static class Extensions
127118
{
128119
public static FileStream Fluent(this FileStream fs) => fs;

csharp/ql/test/query-tests/API Abuse/NoDisposeCallOnLocalIDisposable/NoDisposeCallOnLocalIDisposable.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
| NoDisposeCallOnLocalIDisposable.cs:76:25:76:71 | call to method Create | Disposable 'XmlReader' is created but not disposed. |
55
| NoDisposeCallOnLocalIDisposable.cs:76:42:76:64 | object creation of type StringReader | Disposable 'StringReader' is created but not disposed. |
66
| 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. |
7+
| NoDisposeCallOnLocalIDisposableBad.cs:8:22:8:56 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.IO;
3+
4+
class Bad
5+
{
6+
long GetLength(string file)
7+
{
8+
var stream = new FileStream(file, FileMode.Open); // $ Alert
9+
return stream.Length;
10+
}
11+
}

0 commit comments

Comments
 (0)