@@ -8,7 +8,7 @@ private import semmle.code.csharp.frameworks.System
8
8
private import semmle.code.csharp.frameworks.system.Text
9
9
10
10
/** A method that formats a string, for example `string.Format()`. */
11
- abstract class FormatMethod extends Method {
11
+ abstract private class FormatMethodImpl extends Method {
12
12
/**
13
13
* Gets the argument containing the format string. For example, the argument of
14
14
* `string.Format(IFormatProvider, String, Object)` is `1`.
@@ -21,6 +21,8 @@ abstract class FormatMethod extends Method {
21
21
int getFirstArgument ( ) { result = this .getFormatArgument ( ) + 1 }
22
22
}
23
23
24
+ final class FormatMethod = FormatMethodImpl ;
25
+
24
26
/** A class of types used for formatting. */
25
27
private class FormatType extends Type {
26
28
FormatType ( ) {
@@ -29,7 +31,7 @@ private class FormatType extends Type {
29
31
}
30
32
}
31
33
32
- private class StringAndStringBuilderFormatMethods extends FormatMethod {
34
+ private class StringAndStringBuilderFormatMethods extends FormatMethodImpl {
33
35
StringAndStringBuilderFormatMethods ( ) {
34
36
(
35
37
this .getParameter ( 0 ) .getType ( ) instanceof SystemIFormatProviderInterface and
@@ -51,7 +53,7 @@ private class StringAndStringBuilderFormatMethods extends FormatMethod {
51
53
}
52
54
}
53
55
54
- private class SystemMemoryExtensionsFormatMethods extends FormatMethod {
56
+ private class SystemMemoryExtensionsFormatMethods extends FormatMethodImpl {
55
57
SystemMemoryExtensionsFormatMethods ( ) {
56
58
this = any ( SystemMemoryExtensionsClass c ) .getTryWriteMethod ( ) and
57
59
this .getParameter ( 1 ) .getType ( ) instanceof SystemIFormatProviderInterface and
@@ -63,7 +65,7 @@ private class SystemMemoryExtensionsFormatMethods extends FormatMethod {
63
65
override int getFirstArgument ( ) { result = this .getFormatArgument ( ) + 2 }
64
66
}
65
67
66
- private class SystemConsoleAndSystemIoTextWriterFormatMethods extends FormatMethod {
68
+ private class SystemConsoleAndSystemIoTextWriterFormatMethods extends FormatMethodImpl {
67
69
SystemConsoleAndSystemIoTextWriterFormatMethods ( ) {
68
70
this .getParameter ( 0 ) .getType ( ) instanceof StringType and
69
71
this .getNumberOfParameters ( ) > 1 and
@@ -80,7 +82,7 @@ private class SystemConsoleAndSystemIoTextWriterFormatMethods extends FormatMeth
80
82
override int getFormatArgument ( ) { result = 0 }
81
83
}
82
84
83
- private class SystemDiagnosticsDebugAssert extends FormatMethod {
85
+ private class SystemDiagnosticsDebugAssert extends FormatMethodImpl {
84
86
SystemDiagnosticsDebugAssert ( ) {
85
87
this .hasName ( "Assert" ) and
86
88
this .getDeclaringType ( ) .hasFullyQualifiedName ( "System.Diagnostics" , "Debug" ) and
@@ -90,7 +92,7 @@ private class SystemDiagnosticsDebugAssert extends FormatMethod {
90
92
override int getFormatArgument ( ) { result = 2 }
91
93
}
92
94
93
- private class SystemDiagnosticsFormatMethods extends FormatMethod {
95
+ private class SystemDiagnosticsFormatMethods extends FormatMethodImpl {
94
96
SystemDiagnosticsFormatMethods ( ) {
95
97
this .getParameter ( 0 ) .getType ( ) instanceof StringType and
96
98
this .getNumberOfParameters ( ) > 1 and
0 commit comments