mirror of
https://github.com/github/codeql.git
synced 2026-04-24 00:05:14 +02:00
C#: Remove the CIL related parts of the Disposal tests.
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,11 @@ class Disposal : IDisposable
|
||||
Close();
|
||||
}
|
||||
|
||||
public Disposal(IDisposable p1, object p2, System.IO.TextWriter fs)
|
||||
public Disposal(IDisposable p1, object p2, System.IO.TextWriter fs, IDisposable p3)
|
||||
{
|
||||
field1 = p1;
|
||||
if(p2 is IDisposable d)
|
||||
if (p2 is IDisposable d)
|
||||
d.Dispose();
|
||||
DisposalTests.Class1.Dispose(fs);
|
||||
fs.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
| DisposalTests.Class1.field1 |
|
||||
@@ -1,10 +0,0 @@
|
||||
import cil
|
||||
import semmle.code.csharp.commons.Disposal
|
||||
import semmle.code.csharp.commons.QualifiedName
|
||||
|
||||
from CIL::Field field, string qualifier, string name
|
||||
where
|
||||
mayBeDisposed(field) and
|
||||
field.getDeclaringType().hasFullyQualifiedName("DisposalTests", "Class1") and
|
||||
field.hasFullyQualifiedName(qualifier, name)
|
||||
select getQualifiedName(qualifier, name)
|
||||
@@ -1,6 +1,3 @@
|
||||
| CapturesDisposable(MyType, MyType) | 0 |
|
||||
| Dispose(IDisposable) | 0 |
|
||||
| DisposesParameter(IDisposable, IDisposable) | 0 |
|
||||
| System.Void DisposalTests.Class1.CapturesDisposable(DisposalTests.MyType,DisposalTests.MyType) | 0 |
|
||||
| System.Void DisposalTests.Class1.Dispose(System.IDisposable) | 0 |
|
||||
| System.Void DisposalTests.Class1.DisposesParameter(System.IDisposable,System.IDisposable) | 0 |
|
||||
| Disposal(IDisposable, object, TextWriter, IDisposable) | 0 |
|
||||
| Disposal(IDisposable, object, TextWriter, IDisposable) | 1 |
|
||||
| Disposal(IDisposable, object, TextWriter, IDisposable) | 2 |
|
||||
|
||||
@@ -5,5 +5,5 @@ from DotNet::Callable c, DotNet::Parameter param, int p
|
||||
where
|
||||
mayBeDisposed(param) and
|
||||
param = c.getParameter(p) and
|
||||
c.getDeclaringType().hasFullyQualifiedName("DisposalTests", "Class1")
|
||||
c.getDeclaringType().hasFullyQualifiedName("", "Disposal")
|
||||
select c.toStringWithTypes(), p
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
| Disposal.cs:17:33:17:34 | p1 |
|
||||
| Disposal.cs:17:44:17:45 | p2 |
|
||||
| Disposal.cs:17:69:17:70 | fs |
|
||||
| Disposal.cs:20:30:20:30 | d |
|
||||
| Disposal.cs:20:31:20:31 | d |
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
| CapturesDisposable(MyType, MyType) | 1 |
|
||||
| DisposesParameter(IDisposable, IDisposable) | 1 |
|
||||
| System.Void DisposalTests.Class1.CapturesDisposable(DisposalTests.MyType,DisposalTests.MyType) | 1 |
|
||||
| System.Void DisposalTests.Class1.DisposesParameter(System.IDisposable,System.IDisposable) | 1 |
|
||||
| Disposal(IDisposable, object, TextWriter, IDisposable) | 3 |
|
||||
|
||||
@@ -6,5 +6,5 @@ from DotNet::Callable c, DotNet::Parameter param, int p
|
||||
where
|
||||
not mayBeDisposed(param) and
|
||||
param = c.getParameter(p) and
|
||||
c.getDeclaringType().hasFullyQualifiedName("DisposalTests", "Class1")
|
||||
c.getDeclaringType().hasFullyQualifiedName("", "Disposal")
|
||||
select c.toStringWithTypes(), p
|
||||
|
||||
@@ -1 +1 @@
|
||||
semmle-extractor-options: --cil /r:System.Net.Http.dll /r:System.Runtime.Extensions.dll /r:System.Private.Xml.dll
|
||||
semmle-extractor-options: /r:System.Net.Http.dll /r:System.Runtime.Extensions.dll /r:System.Private.Xml.dll
|
||||
|
||||
Reference in New Issue
Block a user