C#: Add NoDisposeCallOnLocalIDisposableBad file and update test expected output.

This commit is contained in:
Michael Nebel
2025-04-02 15:43:34 +02:00
parent 2193bece90
commit 16142a287a
3 changed files with 12 additions and 10 deletions

View File

@@ -114,15 +114,6 @@ class Test
public void Dispose() { }
}
class Bad
{
long GetLength(string file)
{
var stream = new FileStream(file, FileMode.Open); // $ Alert
return stream.Length;
}
}
static class Extensions
{
public static FileStream Fluent(this FileStream fs) => fs;

View File

@@ -4,4 +4,4 @@
| NoDisposeCallOnLocalIDisposable.cs:76:25:76:71 | call to method Create | Disposable 'XmlReader' is created but not disposed. |
| NoDisposeCallOnLocalIDisposable.cs:76:42:76:64 | object creation of type StringReader | Disposable 'StringReader' is created but not disposed. |
| NoDisposeCallOnLocalIDisposable.cs:104:23:104:38 | object creation of type HttpClient | Disposable 'HttpClient' is created but not disposed. |
| NoDisposeCallOnLocalIDisposable.cs:121:22:121:56 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
| NoDisposeCallOnLocalIDisposableBad.cs:8:22:8:56 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |

View File

@@ -0,0 +1,11 @@
using System;
using System.IO;
class Bad
{
long GetLength(string file)
{
var stream = new FileStream(file, FileMode.Open); // $ Alert
return stream.Length;
}
}