Skip to content

Commit 5ba59fc

Browse files
committed
C#: Stub generator support for operators in interfaces and interface implementations.
1 parent b68e78d commit 5ba59fc

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

csharp/ql/src/Stubs/Stubs.qll

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -740,14 +740,16 @@ private string stubOperator(Operator o, Assembly assembly) {
740740
if o instanceof ConversionOperator
741741
then
742742
result =
743-
" " + stubModifiers(o) + stubExplicit(o) + "operator " + stubClassName(o.getReturnType()) +
744-
"(" + stubParameters(o) + ")" + stubImplementation(o) + ";\n"
743+
" " + stubModifiers(o) + stubExplicit(o) + "operator " + stubChecked(o) +
744+
stubClassName(o.getReturnType()) + "(" + stubParameters(o) + ")" + stubImplementation(o) +
745+
";\n"
745746
else
746747
if not o.getDeclaringType() instanceof Enum
747748
then
748749
result =
749-
" " + stubModifiers(o) + stubClassName(o.getReturnType()) + " operator " + o.getName() +
750-
"(" + stubParameters(o) + ")" + stubImplementation(o) + ";\n"
750+
" " + stubModifiers(o) + stubClassName(o.getReturnType()) + " " +
751+
stubExplicitImplementation(o) + "operator " + o.getName() + "(" + stubParameters(o) + ")" +
752+
stubImplementation(o) + ";\n"
751753
else result = " // Stub generator skipped operator: " + o.getName() + "\n"
752754
}
753755

@@ -888,7 +890,16 @@ private string stubConstructorInitializer(Constructor c) {
888890
private string stubExplicit(ConversionOperator op) {
889891
op instanceof ImplicitConversionOperator and result = "implicit "
890892
or
891-
op instanceof ExplicitConversionOperator and result = "explicit "
893+
(
894+
op instanceof ExplicitConversionOperator
895+
or
896+
op instanceof CheckedExplicitConversionOperator
897+
) and
898+
result = "explicit "
899+
}
900+
901+
private string stubChecked(Operator o) {
902+
if o instanceof CheckedExplicitConversionOperator then result = "checked " else result = ""
892903
}
893904

894905
private string stubGetter(DeclarationWithGetSetAccessors p) {

0 commit comments

Comments
 (0)