Skip to content

Commit b496941

Browse files
Convert Not(x IsNot Nothing) to x is null - fixes #1113
1 parent e9b8470 commit b496941

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1111

1212
### VB -> C#
1313

14+
* Convert Not(x IsNot Nothing) to x is null [#1113](https://github.com/icsharpcode/CodeConverter/issues/1113)
1415
* Escape parameter names [#1092](https://github.com/icsharpcode/CodeConverter/issues/1092)
1516

1617
### C# -> VB

CodeConverter/CSharp/BuiltInVisualBasicOperatorSubstitutions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async Task<ExpressionSyntax> ConvertReferenceOrNothingComparisonOrNullAsy
4040
}
4141

4242
var notted =
43-
node.IsKind(VBasic.SyntaxKind.IsNotExpression, VBasic.SyntaxKind.NotEqualsExpression) ||
43+
node.IsKind(VBasic.SyntaxKind.IsNotExpression, VBasic.SyntaxKind.NotEqualsExpression) ^
4444
negateExpression;
4545
var isReferenceComparison = node.IsKind(VBasic.SyntaxKind.IsExpression, VBasic.SyntaxKind.IsNotExpression);
4646

Tests/CSharp/ExpressionTests/ExpressionTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Private Sub TestMethod(a as String)
1919
result = Nothing = a
2020
result = a Is Nothing
2121
result = a IsNot Nothing
22+
result = Not(a IsNot Nothing)
2223
result = a = a
2324
result = a = (""test"")
2425
result = ""test"" = a
@@ -36,6 +37,7 @@ private void TestMethod(string a)
3637
result = string.IsNullOrEmpty(a);
3738
result = a is null;
3839
result = a is not null;
40+
result = a is null;
3941
result = (a ?? """") == (a ?? """");
4042
result = a == ""test"";
4143
result = ""test"" == a;

0 commit comments

Comments
 (0)