mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Remove disposal test for library code as we are no longer doing CIL extraction or data flow.
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace DisposalTests
|
||||
{
|
||||
public class MyType : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class Class1 : IDisposable
|
||||
{
|
||||
public void DisposesParameter(IDisposable p1, IDisposable p2)
|
||||
{
|
||||
p1.Dispose();
|
||||
}
|
||||
|
||||
public void CapturesDisposable(MyType p1, MyType p2)
|
||||
{
|
||||
field1 = p1;
|
||||
field2 = p2;
|
||||
}
|
||||
|
||||
public void DisposesSelf()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
MyType field1, field2;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
field1.Dispose();
|
||||
}
|
||||
|
||||
public static void Dispose(IDisposable d)
|
||||
{
|
||||
d.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -76,9 +76,6 @@ class Test
|
||||
var xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(xmlReader);
|
||||
|
||||
// GOOD: Passed to a library (False positive as this is disposed in library code).
|
||||
DisposalTests.Class1.Dispose(new StreamWriter("output.txt"));
|
||||
|
||||
// GOOD: Disposed automatically.
|
||||
using var c2 = new Timer(TimerProc);
|
||||
|
||||
|
||||
@@ -3,5 +3,4 @@
|
||||
| NoDisposeCallOnLocalIDisposable.cs:53:9:53:64 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
|
||||
| NoDisposeCallOnLocalIDisposable.cs:75:25:75:71 | call to method Create | Disposable 'XmlReader' is created but not disposed. |
|
||||
| NoDisposeCallOnLocalIDisposable.cs:75:42:75:64 | object creation of type StringReader | Disposable 'StringReader' is created but not disposed. |
|
||||
| NoDisposeCallOnLocalIDisposable.cs:80:38:80:67 | object creation of type StreamWriter | Disposable 'StreamWriter' is created but not disposed. |
|
||||
| NoDisposeCallOnLocalIDisposableBad.cs:8:22:8:56 | object creation of type FileStream | Disposable 'FileStream' is created but not disposed. |
|
||||
|
||||
Reference in New Issue
Block a user