Skip to content

Commit aec7985

Browse files
committed
clear warnings
1 parent f44aca3 commit aec7985

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

test/DynamicQueryable.Tests/ExpressionTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ public void NullableTests() {
621621
}.AsQueryable();
622622
var parameters = new Dictionary<string, object?> { { "searchText", searchText } };
623623

624+
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
624625
var r1 = data.Where(i => i.Name != null && i.Name.Contains(searchText)).ToList();
625626
var d1 = data.Where("i => i.Name != null && i.Name.Contains(searchText)", parameters).ToList();
626627
Assert.Equal(r1, d1);
@@ -629,7 +630,9 @@ public void NullableTests() {
629630
var d2 = data.OrderByDescending("i => i.Name").ToList();
630631
Assert.Equal(r2, d2);
631632

633+
#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
632634
var r3 = data.Where(i => i.Age != null && i.Age.ToString().Contains(searchText)).ToList();
635+
#pragma warning restore CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
633636
var func = Evaluator.ToFunc<bool>(
634637
"i.Age != null && i.Age.ToString().Contains(searchText)",
635638
new Dictionary<string, object?> {{ "searchText", searchText }, { "i", data.First() }}
@@ -642,7 +645,9 @@ public void NullableTests() {
642645
var d4 = data.Where("i => i.Number != null && i.Number.ToString().Contains(searchText)", parameters).ToList();
643646
Assert.Equal(r4, d4);
644647

648+
#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
645649
var r5 = data.Where(i => i.Address != null! && i.Address.Zip != null && i.Address.Zip.ToString().Contains(searchText)).ToList();
650+
#pragma warning restore CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
646651
var d5 = data.Where("i => i.Address != null && i.Address.Zip != null && i.Address.Zip.ToString().Contains(searchText)", parameters).ToList();
647652
Assert.Equal(r5, d5);
648653

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace DynamicQueryable.Tests.Fixture;
22

33
public class Address {
4-
public string City { get; set; }
4+
public string City { get; set; } = "";
55
public int Zip { get; set; }
66
public int? Number { get; set; }
77
}

test/DynamicQueryable.Tests/Fixture/Person.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace DynamicQueryable.Tests.Fixture;
22

33
public class Person {
4-
public string Name { get; set; }
4+
public string Name { get; set; } = "";
55
public int Age { get; set; }
66
public int? Number { get; set; }
77
public Address Address { get; set; } = new();

0 commit comments

Comments
 (0)