|
| 1 | +/** Provides definitions related to the namespace `System.Diagnostics.Contracts`. */ |
| 2 | + |
| 3 | +import semmle.code.csharp.Type |
| 4 | +private import semmle.code.csharp.frameworks.system.Diagnostics |
| 5 | + |
| 6 | +/** The `System.Diagnostics.Contracts` namespace. */ |
| 7 | +class SystemDiagnosticsContractsNamespace extends Namespace { |
| 8 | + SystemDiagnosticsContractsNamespace() { |
| 9 | + this.getParentNamespace() instanceof SystemDiagnosticsNamespace and |
| 10 | + this.hasName("Contracts") |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +/** A class in the `System.Diagnostics.Contracts` namespace. */ |
| 15 | +class SystemDiagnosticsContractsClass extends Class { |
| 16 | + SystemDiagnosticsContractsClass() { this.getNamespace() instanceof SystemDiagnosticsContractsNamespace } |
| 17 | +} |
| 18 | + |
| 19 | +/** The `System.Diagnostics.Contracts.Contract` class. */ |
| 20 | +class SystemDiagnosticsContractsContractClass extends SystemDiagnosticsContractsClass { |
| 21 | + SystemDiagnosticsContractsContractClass() { |
| 22 | + this.hasName("Contract") and |
| 23 | + this.isStatic() |
| 24 | + } |
| 25 | + |
| 26 | + /** Gets an `Assert(bool, ...)` method. */ |
| 27 | + Method getAnAssertMethod() { |
| 28 | + result.getDeclaringType() = this and |
| 29 | + result.hasName("Assert") and |
| 30 | + result.getParameter(0).getType() instanceof BoolType and |
| 31 | + result.getReturnType() instanceof VoidType |
| 32 | + } |
| 33 | + |
| 34 | + /** Gets an `Assume(bool, ...)` method. */ |
| 35 | + Method getAnAssumeMethod() { |
| 36 | + result.getDeclaringType() = this and |
| 37 | + result.hasName("Assume") and |
| 38 | + result.getParameter(0).getType() instanceof BoolType and |
| 39 | + result.getReturnType() instanceof VoidType |
| 40 | + } |
| 41 | + |
| 42 | + /** Gets a `Requires(bool, ...)` method. */ |
| 43 | + Method getARequiresMethod() { |
| 44 | + result.getDeclaringType() = this and |
| 45 | + result.hasName("Requires") and |
| 46 | + result.getParameter(0).getType() instanceof BoolType and |
| 47 | + result.getReturnType() instanceof VoidType |
| 48 | + } |
| 49 | +} |
0 commit comments