Skip to content

Commit a7ddfe2

Browse files
committed
C#: Address review comments.
1 parent 6cc3c82 commit a7ddfe2

File tree

1 file changed

+15
-19
lines changed
  • csharp/ql/lib/semmle/code/csharp/frameworks

1 file changed

+15
-19
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/Format.qll

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,28 @@ class InvalidFormatString extends StringLiteral {
233233
}
234234
}
235235

236+
/**
237+
* A method call to a method that parses a format string, for example a call
238+
* to `string.Format()`.
239+
*/
240+
abstract private class FormatStringParseCallImpl extends MethodCall {
241+
/**
242+
* Gets the expression used as the format string.
243+
*/
244+
abstract Expr getFormatExpr();
245+
}
246+
247+
final class FormatStringParseCall = FormatStringParseCallImpl;
248+
236249
/**
237250
* A method call to a method that formats a string, for example a call
238251
* to `string.Format()`.
239252
*/
240-
class FormatCall extends MethodCall {
253+
class FormatCall extends FormatStringParseCallImpl {
241254
FormatCall() { this.getTarget() instanceof FormatMethod }
242255

243256
/** Gets the expression used as the format string. */
244-
Expr getFormatExpr() { result = this.getArgument(this.getFormatArgument()) }
257+
override Expr getFormatExpr() { result = this.getArgument(this.getFormatArgument()) }
245258

246259
/** Gets the argument number containing the format string. */
247260
int getFormatArgument() { result = this.getTarget().(FormatMethod).getFormatArgument() }
@@ -290,23 +303,6 @@ class FormatCall extends MethodCall {
290303
}
291304
}
292305

293-
/**
294-
* A method call to a method that parses a format string, for example a call
295-
* to `string.Format()`.
296-
*/
297-
abstract private class FormatStringParseCallImpl extends MethodCall {
298-
/**
299-
* Gets the expression used as the format string.
300-
*/
301-
abstract Expr getFormatExpr();
302-
}
303-
304-
final class FormatStringParseCall = FormatStringParseCallImpl;
305-
306-
private class OrdinaryFormatCall extends FormatStringParseCallImpl instanceof FormatCall {
307-
override Expr getFormatExpr() { result = FormatCall.super.getFormatExpr() }
308-
}
309-
310306
/**
311307
* A method call to `System.Text.CompositeFormat.Parse`.
312308
*/

0 commit comments

Comments
 (0)