Skip to content

Commit f7235f7

Browse files
committed
Refactor to use C#7 'is null' operator
1 parent d50cc34 commit f7235f7

File tree

75 files changed

+195
-216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+195
-216
lines changed

Extensions/Xtensive.Orm.BulkOperations/Internals/QueryOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ private void JoinViaIn(SqlStatement statement, SqlSelect select)
142142
var s = (SqlSelect) select.Clone();
143143
foreach (var column in columns) {
144144
var ex = SqlDml.Equals(s.From.Columns[column.Name], table.Columns[column.Name]);
145-
s.Where = s.Where.IsNullReference() ? ex : SqlDml.And(s.Where, ex);
145+
s.Where = s.Where is null ? ex : SqlDml.And(s.Where, ex);
146146
}
147147
var existingColumns = s.Columns.ToChainedBuffer();
148148
s.Columns.Clear();
149149
var columnToAdd = existingColumns.First(c => c.Name.Equals(columnInfo.Name, StringComparison.Ordinal));
150150
s.Columns.Add(columnToAdd);
151151
var @in = SqlDml.In(SqlDml.TableColumn(table, columnInfo.Name), s);
152-
where = where.IsNullReference() ? @in : SqlDml.And(where, @in);
152+
where = where is null ? @in : SqlDml.And(where, @in);
153153
columns.Add(columnInfo);
154154
}
155155

Extensions/Xtensive.Orm.Security/Permission.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2011 Xtensive LLC.
1+
// Copyright (C) 2011 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Dmitri Maximov
@@ -41,15 +41,15 @@ public abstract class Permission
4141
/// <inheritdoc/>
4242
public bool Equals(Permission other)
4343
{
44-
if (ReferenceEquals(null, other)) return false;
44+
if (other is null) return false;
4545
if (ReferenceEquals(this, other)) return true;
4646
return Equals(other.Type, Type) && other.CanRead.Equals(CanRead) && other.CanWrite.Equals(CanWrite) && Equals(other.Query, Query);
4747
}
4848

4949
/// <inheritdoc/>
5050
public override bool Equals(object obj)
5151
{
52-
if (ReferenceEquals(null, obj)) return false;
52+
if (obj is null) return false;
5353
if (ReferenceEquals(this, obj)) return true;
5454
if (obj.GetType() != typeof (Permission)) return false;
5555
return Equals((Permission) obj);

Orm/Xtensive.Orm.MySql/Sql.Drivers.MySql/v5_0/Compiler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ public override void Visit(SqlFunctionCall node)
190190
/// <inheritdoc/>
191191
protected override void VisitSelectLimitOffset(SqlSelect node)
192192
{
193-
if (!node.Limit.IsNullReference()) {
193+
if (node.Limit is not null) {
194194
AppendTranslated(node, SelectSection.Limit);
195195
node.Limit.AcceptVisitor(this);
196196
}
197-
if (!node.Offset.IsNullReference()) {
198-
if (node.Limit.IsNullReference()) {
197+
if (node.Offset is not null) {
198+
if (node.Limit is null) {
199199
AppendTranslated(node, SelectSection.Limit);
200200
_ = context.Output.Append(" 18446744073709551615 "); // magic number from http://dev.mysql.com/doc/refman/5.0/en/select.html
201201
}

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Compiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override void Visit(SqlDeclareCursor node)
3131
public override void Visit(SqlBinary node)
3232
{
3333
var right = node.Right as SqlArray;
34-
if (!right.IsNullReference() && (node.NodeType is SqlNodeType.In or SqlNodeType.NotIn)) {
34+
if (right is not null && (node.NodeType is SqlNodeType.In or SqlNodeType.NotIn)) {
3535
var row = SqlDml.Row(right.GetValues().Select(value => SqlDml.Literal(value)).ToArray());
3636
base.Visit(node.NodeType == SqlNodeType.In ? SqlDml.In(node.Left, row) : SqlDml.NotIn(node.Left, row));
3737
}

Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v09/Compiler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public override void Visit(SqlUpdate node)
7575
/// <inheritdoc/>
7676
protected override void VisitUpdateLimit(SqlUpdate node)
7777
{
78-
if (!node.Limit.IsNullReference()) {
78+
if (node.Limit is not null) {
7979
if (!Driver.ServerInfo.Query.Features.Supports(QueryFeatures.UpdateLimit)) {
8080
throw new NotSupportedException(Strings.ExStorageDoesNotSupportLimitationOfRowCountToUpdate);
8181
}
@@ -104,7 +104,7 @@ public override void Visit(SqlDelete node)
104104
/// <inheritdoc/>
105105
protected override void VisitDeleteLimit(SqlDelete node)
106106
{
107-
if (!node.Limit.IsNullReference()) {
107+
if (node.Limit is not null) {
108108
if (!Driver.ServerInfo.Query.Features.Supports(QueryFeatures.DeleteLimit)) {
109109
throw new NotSupportedException(Strings.ExStorageDoesNotSupportLimitationOfRowCountToDelete);
110110
}
@@ -287,12 +287,12 @@ public override void Visit(SqlRound node)
287287
var shouldCastToDecimal = node.Type==TypeCode.Decimal;
288288
switch (node.Mode) {
289289
case MidpointRounding.ToEven:
290-
result = node.Length.IsNullReference()
290+
result = node.Length is null
291291
? BankersRound(node.Argument, shouldCastToDecimal)
292292
: BankersRound(node.Argument, node.Length, shouldCastToDecimal);
293293
break;
294294
case MidpointRounding.AwayFromZero:
295-
result = node.Length.IsNullReference()
295+
result = node.Length is null
296296
? RegularRound(node.Argument, shouldCastToDecimal)
297297
: RegularRound(node.Argument, node.Length, shouldCastToDecimal);
298298
break;

Orm/Xtensive.Orm.Tests.Core/Modelling/IndexingModel/TypeInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public object Clone()
7575

7676
public bool Equals(TypeInfo other)
7777
{
78-
if (ReferenceEquals(null, other))
78+
if (other is null)
7979
return false;
8080
if (ReferenceEquals(this, other))
8181
return true;
@@ -90,7 +90,7 @@ public bool Equals(TypeInfo other)
9090
/// <inheritdoc/>
9191
public override bool Equals(object obj)
9292
{
93-
if (ReferenceEquals(null, obj))
93+
if (obj is null)
9494
return false;
9595
if (ReferenceEquals(this, obj))
9696
return true;

Orm/Xtensive.Orm.Tests.Sql/CloneTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public void SqlSelectCloneTest()
378378
Assert.AreNotEqual(s.From, sClone.From);
379379
Assert.AreEqual(s.From.NodeType, sClone.From.NodeType);
380380
}
381-
if (!s.Having.IsNullReference()) {
381+
if (s.Having is not null) {
382382
Assert.AreNotEqual(s.Having, sClone.Having);
383383
Assert.AreEqual(s.Having.NodeType, sClone.Having.NodeType);
384384
}
@@ -431,7 +431,7 @@ public void SqlSelectCloneTest()
431431
for (int i = 0, l = s.OrderBy.Count; i < l; i++) {
432432
Assert.AreNotEqual(s.OrderBy[i], sClone.OrderBy[i]);
433433
Assert.AreEqual(s.OrderBy[i].Ascending, sClone.OrderBy[i].Ascending);
434-
if (s.OrderBy[i].Expression.IsNullReference())
434+
if (s.OrderBy[i].Expression is null)
435435
Assert.AreEqual(s.OrderBy[i].Expression, sClone.OrderBy[i].Expression);
436436
else
437437
Assert.AreNotEqual(s.OrderBy[i].Expression, sClone.OrderBy[i].Expression);
@@ -550,7 +550,7 @@ public void SqlDeleteCloneTest()
550550
Assert.AreNotEqual(d.Delete, dClone.Delete);
551551
Assert.AreEqual(d.NodeType, dClone.NodeType);
552552
Assert.AreEqual(d.Hints.Count, dClone.Hints.Count);
553-
if (!d.Where.IsNullReference()) {
553+
if (d.Where is not null) {
554554
Assert.AreNotEqual(d.Where, dClone.Where);
555555
Assert.AreEqual(d.Where.NodeType, dClone.Where.NodeType);
556556
}

Orm/Xtensive.Orm.Tests.Sql/Firebird/IndexTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
1+
// Copyright (C) 2003-2010 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Csaba Beer
@@ -61,7 +61,7 @@ public override void CreateExpressionIndexTest()
6161
Assert.IsNotNull(i2);
6262
Assert.AreEqual(1, i2.Columns.Count);
6363

64-
Assert.IsTrue(!i2.Columns[0].Expression.IsNullReference());
64+
Assert.IsTrue(i2.Columns[0].Expression is not null);
6565
}
6666

6767
[Test, Ignore("Test is not implemented")]

Orm/Xtensive.Orm.Tests.Sql/IndexTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public virtual void CreateFilteredIndexTest()
7070
var i2 = t2.Indexes[FilteredIndexName];
7171
Assert.IsNotNull(i2);
7272
Assert.AreEqual(2, i2.Columns.Count);
73-
Assert.IsTrue(!i2.Where.IsNullReference());
73+
Assert.IsTrue(i2.Where is not null);
7474
}
7575
}
7676
}

Orm/Xtensive.Orm.Tests.Sql/MySQL/MiscTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
1+
// Copyright (C) 2003-2010 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Malisa Ncube
@@ -42,10 +42,10 @@ public void BinaryExpressionTest()
4242
{
4343
SqlLiteral<int> l = SqlDml.Literal(1);
4444
bool passed = false;
45-
if (!l.IsNullReference())
45+
if (l is not null)
4646
passed = true;
4747
Assert.IsTrue(passed);
48-
if (l.IsNullReference())
48+
if (l is null)
4949
passed = false;
5050
Assert.IsTrue(passed);
5151
}

0 commit comments

Comments
 (0)