With the CodeQL CLI, the handling of toString() methods in QL changes. The default compilation mode in Odasa was that entity classes that don't declare a toString() inherit the default implicit none() behavior. In contrast, the new CodeQL CLI compiles with --default-to-string by default, which corresponds to a default behavior that could be expressed as
String toString() { result = "" }
These differences also apply between odasa qltest and (the yet-to-be-released) codeql test run. There are a few existing tests where this difference matters -- namely where a missing toString() definition in the library and/or test code previously made some row disappear from the output due to not having any string representation. Thus the existing .expected file will not contain these rows, but codeql test run will produce them, making the test fail.
It has been decided that this ought to be fixed by making sure that tests always declare all relevant toString() methods, such that their output is independent of the compilation mode.
For C#, the tests affected are:
Please fix these -- ideally by making sure the relevant entity classes have toString() methods, but in a pinch just by injecting some and a.toString() != "" conditions in the select clauses.
To test that your fix works:
- check out branch
pr/test-extract of git.semmle.com/henning/code
- if this branch doesn't exist, it might be that #35764 has been merged, in which case you can just use
Semmle/code/master.
- build
target/intree/codeql.
- try running your test both with
codeql test run path/to/test.ql and with codeql test run --no-default-to-string path/to/test.ql.
(Once all the tests have been updated, we will modify the behavior of odasa qltest appropriately, so a new divergence between the tools won't arise).
With the CodeQL CLI, the handling of
toString()methods in QL changes. The default compilation mode in Odasa was that entity classes that don't declare atoString()inherit the default implicitnone()behavior. In contrast, the new CodeQL CLI compiles with--default-to-stringby default, which corresponds to a default behavior that could be expressed asThese differences also apply between
odasa qltestand (the yet-to-be-released)codeql test run. There are a few existing tests where this difference matters -- namely where a missingtoString()definition in the library and/or test code previously made some row disappear from the output due to not having any string representation. Thus the existing.expectedfile will not contain these rows, butcodeql test runwill produce them, making the test fail.It has been decided that this ought to be fixed by making sure that tests always declare all relevant
toString()methods, such that their output is independent of the compilation mode.For C#, the tests affected are:
ql/csharp/ql/test/library-tests/linq/Linq1.qlql/csharp/ql/test/library-tests/controlflow/guards/AbstractValue.qlql/csharp/ql/test/library-tests/dataflow/global/TaintTrackingEdges.qlql/csharp/ql/test/library-tests/dataflow/global/DataFlowEdges.qlPlease fix these -- ideally by making sure the relevant entity classes have
toString()methods, but in a pinch just by injecting someand a.toString() != ""conditions in theselectclauses.To test that your fix works:
pr/test-extractofgit.semmle.com/henning/codeSemmle/code/master.target/intree/codeql.codeql test run path/to/test.qland withcodeql test run --no-default-to-string path/to/test.ql.(Once all the tests have been updated, we will modify the behavior of
odasa qltestappropriately, so a new divergence between the tools won't arise).