C#: Extract TestLibrary to separate module

This commit is contained in:
Koen Vlaswinkel
2023-09-18 13:33:49 +02:00
parent 585fb9db7e
commit 0cc74a2691
3 changed files with 19 additions and 28 deletions

View File

@@ -12,20 +12,7 @@ private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSumma
private import semmle.code.csharp.dataflow.internal.TaintTrackingPrivate
private import semmle.code.csharp.security.dataflow.flowsources.Remote
pragma[nomagic]
private predicate isTestNamespace(Namespace ns) {
ns.getFullName()
.matches([
"NUnit.Framework%", "Xunit%", "Microsoft.VisualStudio.TestTools.UnitTesting%", "Moq%"
])
}
/**
* A test library.
*/
class TestLibrary extends RefType {
TestLibrary() { isTestNamespace(this.getNamespace()) }
}
private import TestLibrary
/** Holds if the given callable is not worth supporting. */
private predicate isUninteresting(DotNet::Callable c) {

View File

@@ -0,0 +1,17 @@
private import csharp
private import dotnet
pragma[nomagic]
private predicate isTestNamespace(Namespace ns) {
ns.getFullName()
.matches([
"NUnit.Framework%", "Xunit%", "Microsoft.VisualStudio.TestTools.UnitTesting%", "Moq%"
])
}
/**
* A test library.
*/
class TestLibrary extends RefType {
TestLibrary() { isTestNamespace(this.getNamespace()) }
}

View File

@@ -13,20 +13,7 @@ private import semmle.code.csharp.dataflow.internal.TaintTrackingPrivate
private import semmle.code.csharp.frameworks.Test
private import semmle.code.csharp.security.dataflow.flowsources.Remote
pragma[nomagic]
private predicate isTestNamespace(Namespace ns) {
ns.getFullName()
.matches([
"NUnit.Framework%", "Xunit%", "Microsoft.VisualStudio.TestTools.UnitTesting%", "Moq%"
])
}
/**
* A test library.
*/
class TestLibrary extends RefType {
TestLibrary() { isTestNamespace(this.getNamespace()) }
}
private import Telemetry.TestLibrary
/** Holds if the given callable is not worth supporting. */
private predicate isUninteresting(DotNet::Declaration c) {