Skip to content

C#: Sync samples and qltest cases #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions csharp/ql/test/query-tests/Nullness/EqualityCheck.expected
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@
| NullAlwaysBad.cs:9:17:9:25 | ... != ... | false | NullAlwaysBad.cs:9:22:9:25 | null | NullAlwaysBad.cs:9:17:9:17 | access to parameter s |
| NullAlwaysGood.cs:9:17:9:25 | ... != ... | false | NullAlwaysGood.cs:9:17:9:17 | access to parameter s | NullAlwaysGood.cs:9:22:9:25 | null |
| NullAlwaysGood.cs:9:17:9:25 | ... != ... | false | NullAlwaysGood.cs:9:22:9:25 | null | NullAlwaysGood.cs:9:17:9:17 | access to parameter s |
| NullMaybeGood.cs:9:17:9:25 | ... != ... | false | NullMaybeGood.cs:9:17:9:17 | access to parameter o | NullMaybeGood.cs:9:22:9:25 | null |
| NullMaybeGood.cs:9:17:9:25 | ... != ... | false | NullMaybeGood.cs:9:22:9:25 | null | NullMaybeGood.cs:9:17:9:17 | access to parameter o |
| NullMaybeGood.cs:7:13:7:21 | ... != ... | false | NullMaybeGood.cs:7:13:7:13 | access to parameter o | NullMaybeGood.cs:7:18:7:21 | null |
| NullMaybeGood.cs:7:13:7:21 | ... != ... | false | NullMaybeGood.cs:7:18:7:21 | null | NullMaybeGood.cs:7:13:7:13 | access to parameter o |
| StringConcatenation.cs:15:16:15:22 | ... != ... | false | StringConcatenation.cs:15:16:15:16 | access to local variable s | StringConcatenation.cs:15:21:15:22 | "" |
| StringConcatenation.cs:15:16:15:22 | ... != ... | false | StringConcatenation.cs:15:21:15:22 | "" | StringConcatenation.cs:15:16:15:16 | access to local variable s |
| StringConcatenation.cs:22:16:22:22 | ... != ... | false | StringConcatenation.cs:22:16:22:16 | access to local variable s | StringConcatenation.cs:22:21:22:22 | "" |
Expand Down
4 changes: 2 additions & 2 deletions csharp/ql/test/query-tests/Nullness/Implications.expected
Original file line number Diff line number Diff line change
Expand Up @@ -1580,8 +1580,8 @@
| NullAlwaysGood.cs:9:17:9:25 | ... != ... | true | NullAlwaysGood.cs:9:17:9:17 | access to parameter s | non-null |
| NullAlwaysGood.cs:9:17:9:41 | ... && ... | true | NullAlwaysGood.cs:9:17:9:25 | ... != ... | true |
| NullAlwaysGood.cs:9:17:9:41 | ... && ... | true | NullAlwaysGood.cs:9:30:9:41 | ... > ... | true |
| NullMaybeGood.cs:9:17:9:25 | ... != ... | false | NullMaybeGood.cs:9:17:9:17 | access to parameter o | null |
| NullMaybeGood.cs:9:17:9:25 | ... != ... | true | NullMaybeGood.cs:9:17:9:17 | access to parameter o | non-null |
| NullMaybeGood.cs:7:13:7:21 | ... != ... | false | NullMaybeGood.cs:7:13:7:13 | access to parameter o | null |
| NullMaybeGood.cs:7:13:7:21 | ... != ... | true | NullMaybeGood.cs:7:13:7:13 | access to parameter o | non-null |
| StringConcatenation.cs:7:16:7:23 | String s = ... | non-null | StringConcatenation.cs:7:16:7:16 | access to local variable s | non-null |
| StringConcatenation.cs:7:16:7:23 | String s = ... | null | StringConcatenation.cs:7:16:7:16 | access to local variable s | null |
| StringConcatenation.cs:8:9:8:9 | access to local variable s | non-null | StringConcatenation.cs:7:20:7:23 | null | non-null |
Expand Down
4 changes: 2 additions & 2 deletions csharp/ql/test/query-tests/Nullness/NullCheck.expected
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
| NullAlwaysBad.cs:9:17:9:25 | ... != ... | NullAlwaysBad.cs:9:17:9:17 | access to parameter s | true | false |
| NullAlwaysGood.cs:9:17:9:25 | ... != ... | NullAlwaysGood.cs:9:17:9:17 | access to parameter s | false | true |
| NullAlwaysGood.cs:9:17:9:25 | ... != ... | NullAlwaysGood.cs:9:17:9:17 | access to parameter s | true | false |
| NullMaybeGood.cs:9:17:9:25 | ... != ... | NullMaybeGood.cs:9:17:9:17 | access to parameter o | false | true |
| NullMaybeGood.cs:9:17:9:25 | ... != ... | NullMaybeGood.cs:9:17:9:17 | access to parameter o | true | false |
| NullMaybeGood.cs:7:13:7:21 | ... != ... | NullMaybeGood.cs:7:13:7:13 | access to parameter o | false | true |
| NullMaybeGood.cs:7:13:7:21 | ... != ... | NullMaybeGood.cs:7:13:7:13 | access to parameter o | true | false |
| StringConcatenation.cs:15:16:15:22 | ... != ... | StringConcatenation.cs:15:16:15:16 | access to local variable s | false | false |
| StringConcatenation.cs:22:16:22:22 | ... != ... | StringConcatenation.cs:22:16:22:16 | access to local variable s | false | false |
2 changes: 1 addition & 1 deletion csharp/ql/test/query-tests/Nullness/NullMaybe.expected
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@
| E.cs:235:16:235:16 | access to parameter i | Variable $@ may be null here because it has a nullable type. | E.cs:233:26:233:26 | i | i | E.cs:233:26:233:26 | i | this |
| E.cs:240:21:240:21 | access to parameter i | Variable $@ may be null here because it has a nullable type. | E.cs:238:26:238:26 | i | i | E.cs:238:26:238:26 | i | this |
| GuardedString.cs:35:31:35:31 | access to local variable s | Variable $@ may be null here because of $@ assignment. | GuardedString.cs:7:16:7:16 | s | s | GuardedString.cs:7:16:7:32 | String s = ... | this |
| NullMaybeBad.cs:9:31:9:31 | access to parameter o | Variable $@ may be null here because of $@ null argument. | NullMaybeBad.cs:7:29:7:29 | o | o | NullMaybeBad.cs:15:21:15:24 | null | this |
| NullMaybeBad.cs:7:27:7:27 | access to parameter o | Variable $@ may be null here because of $@ null argument. | NullMaybeBad.cs:5:25:5:25 | o | o | NullMaybeBad.cs:13:17:13:20 | null | this |
| StringConcatenation.cs:16:17:16:17 | access to local variable s | Variable $@ may be null here because of $@ assignment. | StringConcatenation.cs:14:16:14:16 | s | s | StringConcatenation.cs:14:16:14:23 | String s = ... | this |
19 changes: 8 additions & 11 deletions csharp/ql/test/query-tests/Nullness/NullMaybeBad.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using System;

namespace NullMaybe
class Bad
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we actually want to sync the other way around, i.e., copy the files from the tests to the samples. That way the test files for NullMaybe and NullAlways will follow the same structure (having a namespace).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the samples I've been browsing don't have a namespace, which I would agree with because it's good to keep them as short as possible.

{
class Bad
void DoPrint(object o)
{
void DoPrint(object o)
{
Console.WriteLine(o.ToString());
}
Console.WriteLine(o.ToString());
}

void M()
{
DoPrint("Hello");
DoPrint(null);
}
void M()
{
DoPrint("Hello");
DoPrint(null);
}
}
21 changes: 9 additions & 12 deletions csharp/ql/test/query-tests/Nullness/NullMaybeGood.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
using System;

namespace NullMaybe
class Good
{
class Good
void DoPrint(object o)
{
void DoPrint(object o)
{
if (o != null)
Console.WriteLine(o.ToString());
}
if (o != null)
Console.WriteLine(o.ToString());
}

void M()
{
DoPrint("Hello");
DoPrint(null);
}
void M()
{
DoPrint("Hello");
DoPrint(null);
}
}