diff --git a/.azure-pipelines/build.yml b/.azure-pipelines/build.yml
index 4a03580..59f52a7 100644
--- a/.azure-pipelines/build.yml
+++ b/.azure-pipelines/build.yml
@@ -4,14 +4,14 @@ pool:
vmImage: vs2017-win2016
variables:
BuildConfiguration: 'Release'
+ GitVersion.SemVer: ''
steps:
-- task: gittools.gitversion.gitversion-task.GitVersion@5
+- task: GitVersion@5
displayName: GitVersion
inputs:
runtime: full
updateAssemblyInfo: true
- gitVersionPath: 'C:\ProgramData\chocolatey\bin\GitVersion.exe'
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
@@ -24,21 +24,26 @@ steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
+ command: build
projects: '**/*.sln'
arguments: '--configuration $(BuildConfiguration) --no-restore'
+ versioningScheme: byEnvVar
+ versionEnvVar: 'GitVersion.SemVer'
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: test
projects: 'test/**/*.UnitTests/*.csproj'
- arguments: '--configuration $(BuildConfiguration) --no-build'
+ arguments: '--configuration $(BuildConfiguration)'
+ nobuild: true
- task: DotNetCoreCLI@2
displayName: 'dotnet pack release'
inputs:
command: pack
packagesToPack: 'src/**/*.csproj'
+ configurationToPack: '$(BuildConfiguration)'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: GitVersion.NuGetVersion
diff --git a/.issuetracker b/.issuetracker
new file mode 100644
index 0000000..fecde74
--- /dev/null
+++ b/.issuetracker
@@ -0,0 +1,7 @@
+# Integration with Issue Tracker
+#
+# (note that '\' need to be escaped).
+
+[issuetracker "GitHub Rule"]
+ regex = "#(\\d+)"
+ url = "https://github.com/alecsg77/ExpressionTreeToolkit/issues/$1"
diff --git a/ExpressionTreeToolkit.sln b/ExpressionTreeToolkit.sln
index 2031a2e..801589a 100644
--- a/ExpressionTreeToolkit.sln
+++ b/ExpressionTreeToolkit.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26124.0
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionTreeToolkit.Core", "src\ExpressionTreeToolkit.Core\ExpressionTreeToolkit.Core.csproj", "{425CF5CA-C402-4863-B808-BF6FC39F3260}"
EndProject
@@ -8,6 +8,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionTreeToolkit.UnitT
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E878ADD7-C825-4E9E-9153-E58CDD6FC750}"
ProjectSection(SolutionItems) = preProject
+ src\Annotations.cs = src\Annotations.cs
src\Directory.Build.props = src\Directory.Build.props
src\SolutionInfo.cs = src\SolutionInfo.cs
EndProjectSection
diff --git a/global.json b/global.json
index 057fc0c..144ebc5 100644
--- a/global.json
+++ b/global.json
@@ -1,5 +1,5 @@
{
"sdk": {
- "version": "2.1.200"
+ "version": "3.1.202"
}
}
\ No newline at end of file
diff --git a/src/Annotations.cs b/src/Annotations.cs
new file mode 100644
index 0000000..03aac43
--- /dev/null
+++ b/src/Annotations.cs
@@ -0,0 +1,12 @@
+#if JETBRAINS_ANNOTATIONS
+
+#else
+namespace System.Diagnostics.CodeAnalysis
+{
+ [Conditional("JETBRAINS_ANNOTATIONS")]
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property)]
+ internal sealed class AllowItemNullAttribute : Attribute
+ {
+ }
+}
+#endif
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 1d2a4d3..a8c2f06 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -1,7 +1,7 @@
- netstandard2.0;net45;netcoreapp2.0
+ netstandard2.0;net45;netstandard2.1;
true
false
$(MSBuildThisFileDirectory)ExpressionTreeToolkit.snk
@@ -24,4 +24,14 @@
true
true
+
+
+ 8.0
+ enable
+ JETBRAINS_ANNOTATIONS
+
+
+
+
+
\ No newline at end of file
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Binary.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Binary.cs
index ac6d6dc..6547750 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Binary.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Binary.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,20 +20,23 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first BinaryExpression to compare.
/// The second BinaryExpression to compare.
/// true if the specified BinaryExpression are equal; otherwise, false.
- protected virtual bool EqualsBinary([NotNull] BinaryExpression x, [NotNull] BinaryExpression y)
+ protected virtual bool EqualsBinary([DisallowNull] BinaryExpression x, [DisallowNull] BinaryExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
- && Equals(x.Method, y.Method)
- && Equals(x.Left, y.Left)
- && Equals(x.Right, y.Right)
- && Equals(x.Conversion, y.Conversion);
+ && Equals(x.Method, y.Method)
+ && Equals(x.Left, y.Left)
+ && Equals(x.Right, y.Right)
+ && Equals(x.Conversion, y.Conversion);
}
/// Gets the hash code for the specified BinaryExpression.
/// The BinaryExpression for which to get a hash code.
/// A hash code for the specified BinaryExpression.
- protected virtual int GetHashCodeBinary([NotNull] BinaryExpression node)
+ protected virtual int GetHashCodeBinary([DisallowNull] BinaryExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetDefaultHashCode(node.Method),
@@ -40,7 +49,7 @@ protected virtual int GetHashCodeBinary([NotNull] BinaryExpression node)
/// The first BinaryExpression to compare.
/// The second BinaryExpression to compare.
/// true if the specified BinaryExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(BinaryExpression x, BinaryExpression y)
+ bool IEqualityComparer.Equals([AllowNull] BinaryExpression? x, [AllowNull] BinaryExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -55,7 +64,7 @@ bool IEqualityComparer.Equals(BinaryExpression x, BinaryExpres
/// The for which a hash code is to be returned.
/// A hash code for the specified BinaryExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(BinaryExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] BinaryExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Block.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Block.cs
index 7902385..93a65be 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Block.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Block.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first BlockExpression to compare.
/// The second BlockExpression to compare.
/// true if the specified BlockExpression are equal; otherwise, false.
- protected virtual bool EqualsBlock([NotNull] BlockExpression x, [NotNull] BlockExpression y)
+ protected virtual bool EqualsBlock([DisallowNull] BlockExpression x, [DisallowNull] BlockExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Expressions, y.Expressions)
&& Equals(x.Variables, y.Variables, EqualsParameter)
@@ -25,8 +33,9 @@ protected virtual bool EqualsBlock([NotNull] BlockExpression x, [NotNull] BlockE
/// Gets the hash code for the specified BlockExpression.
/// The BlockExpression for which to get a hash code.
/// A hash code for the specified BlockExpression.
- protected virtual int GetHashCodeBlock([NotNull] BlockExpression node)
+ protected virtual int GetHashCodeBlock([DisallowNull] BlockExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.Expressions),
@@ -38,7 +47,7 @@ protected virtual int GetHashCodeBlock([NotNull] BlockExpression node)
/// The first BlockExpression to compare.
/// The second BlockExpression to compare.
/// true if the specified BlockExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(BlockExpression x, BlockExpression y)
+ bool IEqualityComparer.Equals([AllowNull] BlockExpression? x, [AllowNull] BlockExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -53,7 +62,7 @@ bool IEqualityComparer.Equals(BlockExpression x, BlockExpressio
/// The for which a hash code is to be returned.
/// A hash code for the specified BlockExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(BlockExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] BlockExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Conditional.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Conditional.cs
index 881d628..5fbb24f 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Conditional.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Conditional.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparerThe first ConditionalExpression to compare.
/// The second ConditionalExpression to compare.
/// true if the specified ConditionalExpression are equal; otherwise, false.
- protected virtual bool EqualsConditional([NotNull] ConditionalExpression x, [NotNull] ConditionalExpression y)
+ protected virtual bool EqualsConditional([DisallowNull] ConditionalExpression x, [DisallowNull] ConditionalExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Test, y.Test)
&& Equals(x.IfTrue, y.IfTrue)
@@ -25,8 +33,9 @@ protected virtual bool EqualsConditional([NotNull] ConditionalExpression x, [Not
/// Gets the hash code for the specified ConditionalExpression.
/// The ConditionalExpression for which to get a hash code.
/// A hash code for the specified ConditionalExpression.
- protected virtual int GetHashCodeConditional([NotNull] ConditionalExpression node)
+ protected virtual int GetHashCodeConditional([DisallowNull] ConditionalExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.Test),
@@ -38,7 +47,7 @@ protected virtual int GetHashCodeConditional([NotNull] ConditionalExpression nod
/// The first ConditionalExpression to compare.
/// The second ConditionalExpression to compare.
/// true if the specified ConditionalExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(ConditionalExpression x, ConditionalExpression y)
+ bool IEqualityComparer.Equals([AllowNull] ConditionalExpression? x, [AllowNull] ConditionalExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -53,7 +62,7 @@ bool IEqualityComparer.Equals(ConditionalExpression x, Co
/// The for which a hash code is to be returned.
/// A hash code for the specified ConditionalExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(ConditionalExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] ConditionalExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Constant.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Constant.cs
index 6af8e10..89789eb 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Constant.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Constant.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first ConstantExpression to compare.
/// The second ConstantExpression to compare.
/// true if the specified ConstantExpression are equal; otherwise, false.
- protected virtual bool EqualsConstant([NotNull] ConstantExpression x, [NotNull] ConstantExpression y)
+ protected virtual bool EqualsConstant([DisallowNull] ConstantExpression x, [DisallowNull] ConstantExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Value, y.Value);
}
@@ -23,8 +31,9 @@ protected virtual bool EqualsConstant([NotNull] ConstantExpression x, [NotNull]
/// Gets the hash code for the specified ConstantExpression.
/// The ConstantExpression for which to get a hash code.
/// A hash code for the specified ConstantExpression.
- protected virtual int GetHashCodeConstant([NotNull] ConstantExpression node)
+ protected virtual int GetHashCodeConstant([DisallowNull] ConstantExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetDefaultHashCode(node.Value));
@@ -34,7 +43,7 @@ protected virtual int GetHashCodeConstant([NotNull] ConstantExpression node)
/// The first ConstantExpression to compare.
/// The second ConstantExpression to compare.
/// true if the specified ConstantExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(ConstantExpression x, ConstantExpression y)
+ bool IEqualityComparer.Equals([AllowNull] ConstantExpression? x, [AllowNull] ConstantExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -49,7 +58,7 @@ bool IEqualityComparer.Equals(ConstantExpression x, Constant
/// The for which a hash code is to be returned.
/// A hash code for the specified ConstantExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(ConstantExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] ConstantExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.DebugInfo.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.DebugInfo.cs
index cd9daf1..548c0bd 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.DebugInfo.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.DebugInfo.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparerThe first DebugInfoExpression to compare.
/// The second DebugInfoExpression to compare.
/// true if the specified DebugInfoExpression are equal; otherwise, false.
- protected virtual bool EqualsDebugInfo([NotNull] DebugInfoExpression x, [NotNull] DebugInfoExpression y)
+ protected virtual bool EqualsDebugInfo([DisallowNull] DebugInfoExpression x, [DisallowNull] DebugInfoExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& x.IsClear == y.IsClear
&& EqualsSymbolDocumentInfo(x.Document, y.Document)
@@ -46,8 +54,9 @@ private bool EqualsSymbolDocumentInfo(SymbolDocumentInfo x, SymbolDocumentInfo y
/// Gets the hash code for the specified DebugInfoExpression.
/// The DebugInfoExpression for which to get a hash code.
/// A hash code for the specified DebugInfoExpression.
- protected virtual int GetHashCodeDebugInfo([NotNull] DebugInfoExpression node)
+ protected virtual int GetHashCodeDebugInfo([DisallowNull] DebugInfoExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
node.IsClear.GetHashCode(),
@@ -76,7 +85,7 @@ private int GetHashSymbolDocumentInfo(SymbolDocumentInfo symbolDocumentInfo)
/// The first DebugInfoExpression to compare.
/// The second DebugInfoExpression to compare.
/// true if the specified DebugInfoExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(DebugInfoExpression x, DebugInfoExpression y)
+ bool IEqualityComparer.Equals([AllowNull] DebugInfoExpression? x, [AllowNull] DebugInfoExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -91,7 +100,7 @@ bool IEqualityComparer.Equals(DebugInfoExpression x, DebugI
/// The for which a hash code is to be returned.
/// A hash code for the specified DebugInfoExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(DebugInfoExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] DebugInfoExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Default.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Default.cs
index 46fd762..f627527 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Default.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Default.cs
@@ -1,7 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -11,16 +17,19 @@ public partial class ExpressionEqualityComparer : IEqualityComparerThe first DefaultExpression to compare.
/// The second DefaultExpression to compare.
/// true if the specified DefaultExpression are equal; otherwise, false.
- protected virtual bool EqualsDefault([NotNull] DefaultExpression x, [NotNull] DefaultExpression y)
+ protected virtual bool EqualsDefault([DisallowNull] DefaultExpression x, [DisallowNull] DefaultExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type;
}
/// Gets the hash code for the specified DefaultExpression.
/// The DefaultExpression for which to get a hash code.
/// A hash code for the specified DefaultExpression.
- protected virtual int GetHashCodeDefault([NotNull] DefaultExpression node)
+ protected virtual int GetHashCodeDefault([DisallowNull] DefaultExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetDefaultHashCode(node.Type);
}
@@ -28,7 +37,7 @@ protected virtual int GetHashCodeDefault([NotNull] DefaultExpression node)
/// The first DefaultExpression to compare.
/// The second DefaultExpression to compare.
/// true if the specified DefaultExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(DefaultExpression x, DefaultExpression y)
+ bool IEqualityComparer.Equals([AllowNull] DefaultExpression? x, [AllowNull] DefaultExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -43,7 +52,7 @@ bool IEqualityComparer.Equals(DefaultExpression x, DefaultExp
/// The for which a hash code is to be returned.
/// A hash code for the specified DefaultExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(DefaultExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] DefaultExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Dynamic.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Dynamic.cs
index 919715d..5c6daad 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Dynamic.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Dynamic.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first DynamicExpression to compare.
/// The second DynamicExpression to compare.
/// true if the specified DynamicExpression are equal; otherwise, false.
- protected virtual bool EqualsDynamic([NotNull] DynamicExpression x, [NotNull] DynamicExpression y)
+ protected virtual bool EqualsDynamic([DisallowNull] DynamicExpression x, [DisallowNull] DynamicExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& x.DelegateType == y.DelegateType
&& Equals(x.Arguments, y.Arguments)
@@ -25,8 +33,9 @@ protected virtual bool EqualsDynamic([NotNull] DynamicExpression x, [NotNull] Dy
/// Gets the hash code for the specified DynamicExpression.
/// The DynamicExpression for which to get a hash code.
/// A hash code for the specified DynamicExpression.
- protected virtual int GetHashCodeDynamic([NotNull] DynamicExpression node)
+ protected virtual int GetHashCodeDynamic([DisallowNull] DynamicExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetDefaultHashCode(node.DelegateType),
@@ -38,7 +47,7 @@ protected virtual int GetHashCodeDynamic([NotNull] DynamicExpression node)
/// The first DynamicExpression to compare.
/// The second DynamicExpression to compare.
/// true if the specified DynamicExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(DynamicExpression x, DynamicExpression y)
+ bool IEqualityComparer.Equals([AllowNull] DynamicExpression? x, [AllowNull] DynamicExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -53,7 +62,7 @@ bool IEqualityComparer.Equals(DynamicExpression x, DynamicExp
/// The for which a hash code is to be returned.
/// A hash code for the specified DynamicExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(DynamicExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] DynamicExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Extension.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Extension.cs
index 1beafdd..ac19110 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Extension.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Extension.cs
@@ -1,8 +1,15 @@
// Copyright (c) 2018 Alessio Gogna
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
+using System;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -12,16 +19,19 @@ public partial class ExpressionEqualityComparer
/// The first extension Expression to compare.
/// The second extension Expression to compare.
/// true if the specified extension Expression are equal; otherwise, false.
- protected virtual bool EqualsExtension([NotNull] Expression x, [NotNull] Expression y)
+ protected virtual bool EqualsExtension([DisallowNull] Expression x, [DisallowNull] Expression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return Equals(x.ReduceExtensions(), y.ReduceExtensions());
}
/// Gets the hash code for the specified extension Expression.
/// The extension Expression for which to get a hash code.
/// A hash code for the specified extension Expression.
- protected virtual int GetHashCodeExtension([NotNull] Expression obj)
+ protected virtual int GetHashCodeExtension([DisallowNull] Expression obj)
{
+ if (obj == null) throw new ArgumentNullException(nameof(obj));
return GetHashCode(obj.ReduceExtensions());
}
}
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Goto.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Goto.cs
index c6cca20..41db251 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Goto.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Goto.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first GotoExpression to compare.
/// The second GotoExpression to compare.
/// true if the specified GotoExpression are equal; otherwise, false.
- protected virtual bool EqualsGoto([NotNull] GotoExpression x, [NotNull] GotoExpression y)
+ protected virtual bool EqualsGoto([DisallowNull] GotoExpression x, [DisallowNull] GotoExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& x.Kind == y.Kind
&& EqualsLabelTarget(x.Target, y.Target)
@@ -25,8 +33,9 @@ protected virtual bool EqualsGoto([NotNull] GotoExpression x, [NotNull] GotoExpr
/// Gets the hash code for the specified GotoExpression.
/// The GotoExpression for which to get a hash code.
/// A hash code for the specified GotoExpression.
- protected virtual int GetHashCodeGoto([NotNull] GotoExpression node)
+ protected virtual int GetHashCodeGoto([DisallowNull] GotoExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
node.Kind.GetHashCode(),
@@ -38,7 +47,7 @@ protected virtual int GetHashCodeGoto([NotNull] GotoExpression node)
/// The first GotoExpression to compare.
/// The second GotoExpression to compare.
/// true if the specified GotoExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(GotoExpression x, GotoExpression y)
+ bool IEqualityComparer.Equals([AllowNull] GotoExpression? x, [AllowNull] GotoExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -53,7 +62,7 @@ bool IEqualityComparer.Equals(GotoExpression x, GotoExpression y
/// The for which a hash code is to be returned.
/// A hash code for the specified GotoExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(GotoExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] GotoExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Helpers.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Helpers.cs
index f94e2fe..0cba820 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Helpers.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Helpers.cs
@@ -6,7 +6,13 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -16,7 +22,7 @@ partial class ExpressionEqualityComparer
/// A collection of Expression to compare.
/// A collection of Expression to compare to the first sequence.
/// true if the two nodes sequences are of equal length and their corresponding elements are equal; otherwise, false.
- protected bool Equals([CanBeNull] [ItemCanBeNull] ReadOnlyCollection first, [CanBeNull] [ItemCanBeNull] ReadOnlyCollection second)
+ protected bool Equals([AllowNull, AllowItemNull] ReadOnlyCollection? first, [AllowNull, AllowItemNull] ReadOnlyCollection? second)
{
if (ReferenceEquals(first, second))
{
@@ -58,7 +64,8 @@ protected bool Equals([CanBeNull] [ItemCanBeNull] ReadOnlyCollection
/// An to compare to the first sequence.
/// The type of the elements of the input sequences.
/// true if the two source sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type; otherwise, false.
- protected bool Equals([CanBeNull] [ItemCanBeNull] ReadOnlyCollection first, [CanBeNull] [ItemCanBeNull] ReadOnlyCollection second)
+ protected bool Equals([AllowNull, AllowItemNull] ReadOnlyCollection? first, [AllowNull, AllowItemNull] ReadOnlyCollection? second)
+ where T : class
{
if (ReferenceEquals(first, second))
{
@@ -79,7 +86,7 @@ protected bool Equals([CanBeNull] [ItemCanBeNull] ReadOnlyCollection first
/// An to use to compare elements.
/// The type of the elements of the input sequences.
/// true if the two source sequences are of equal length and their corresponding elements compare equal according to equality comparer; otherwise, false.
- protected bool Equals([CanBeNull] [ItemCanBeNull] ReadOnlyCollection first, [CanBeNull] [ItemCanBeNull] ReadOnlyCollection second, [CanBeNull] Func equalityComparer)
+ protected bool Equals([AllowNull, AllowItemNull] ReadOnlyCollection? first, [AllowNull, AllowItemNull] ReadOnlyCollection? second, Func? equalityComparer)
where T : class
{
if (equalityComparer == null) throw new ArgumentNullException(nameof(equalityComparer));
@@ -136,7 +143,7 @@ protected bool Equals([CanBeNull] [ItemCanBeNull] ReadOnlyCollection first
/// The first ElementInit to compare.
/// The second ElementInit to compare.
/// true if the specified ElementInit are equal; otherwise, false.
- protected virtual bool EqualsElementInit([CanBeNull] ElementInit x, [CanBeNull] ElementInit y)
+ protected virtual bool EqualsElementInit([AllowNull] ElementInit? x, [AllowNull] ElementInit? y)
{
if (ReferenceEquals(x, y))
{
@@ -156,7 +163,7 @@ protected virtual bool EqualsElementInit([CanBeNull] ElementInit x, [CanBeNull]
/// The first MemberBinding to compare.
/// The second MemberBinding to compare.
/// true if the specified MemberBinding are equal; otherwise, false.
- protected virtual bool EqualsMemberBinding([CanBeNull] MemberBinding x, [CanBeNull] MemberBinding y)
+ protected virtual bool EqualsMemberBinding([AllowNull] MemberBinding? x, [AllowNull] MemberBinding? y)
{
if (ReferenceEquals(x, y))
{
@@ -190,8 +197,10 @@ protected virtual bool EqualsMemberBinding([CanBeNull] MemberBinding x, [CanBeNu
/// The first MemberAssignment to compare.
/// The second MemberAssignment to compare.
/// true if the specified MemberAssignment are equal; otherwise, false.
- protected virtual bool EqualsMemberAssignment([NotNull] MemberAssignment x, [NotNull] MemberAssignment y)
+ protected virtual bool EqualsMemberAssignment([DisallowNull] MemberAssignment x, [DisallowNull] MemberAssignment y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return Equals(x.Member, y.Member)
&& Equals(x.Expression, y.Expression);
}
@@ -200,8 +209,10 @@ protected virtual bool EqualsMemberAssignment([NotNull] MemberAssignment x, [Not
/// The first MemberMemberBinding to compare.
/// The second MemberMemberBinding to compare.
/// true if the specified MemberMemberBinding are equal; otherwise, false.
- protected virtual bool EqualsMemberMemberBinding([NotNull] MemberMemberBinding x, [NotNull] MemberMemberBinding y)
+ protected virtual bool EqualsMemberMemberBinding([DisallowNull] MemberMemberBinding x, [DisallowNull] MemberMemberBinding y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return Equals(x.Member, y.Member)
&& Equals(x.Bindings, y.Bindings, EqualsMemberBinding);
}
@@ -210,8 +221,10 @@ protected virtual bool EqualsMemberMemberBinding([NotNull] MemberMemberBinding x
/// The first MemberListBinding to compare.
/// The second MemberListBinding to compare.
/// true if the specified MemberListBinding are equal; otherwise, false.
- protected virtual bool EqualsMemberListBinding([NotNull] MemberListBinding x, [NotNull] MemberListBinding y)
+ protected virtual bool EqualsMemberListBinding([DisallowNull] MemberListBinding x, [DisallowNull] MemberListBinding y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return Equals(x.Member, y.Member)
&& Equals(x.Initializers, y.Initializers, EqualsElementInit);
}
@@ -220,7 +233,7 @@ protected virtual bool EqualsMemberListBinding([NotNull] MemberListBinding x, [N
/// The first LabelTarget to compare.
/// The second LabelTarget to compare.
/// true if the specified LabelTarget are equal; otherwise, false.
- protected virtual bool EqualsLabelTarget([CanBeNull] LabelTarget x, [CanBeNull] LabelTarget y)
+ protected virtual bool EqualsLabelTarget([AllowNull] LabelTarget? x, [AllowNull] LabelTarget? y)
{
if (ReferenceEquals(x, y))
{
@@ -236,9 +249,10 @@ protected virtual bool EqualsLabelTarget([CanBeNull] LabelTarget x, [CanBeNull]
&& Equals(x.Name, y.Name);
}
- private static int GetDefaultHashCode([CanBeNull] T obj)
+ private static int GetDefaultHashCode([AllowNull] T? obj)
+ where T : class
{
- return EqualityComparer.Default.GetHashCode(obj);
+ return obj != null ? EqualityComparer.Default.GetHashCode(obj) : 0;
}
private static int GetHashCode(int h1, int h2)
@@ -267,7 +281,7 @@ private static int GetHashCode(int h1, params int[] args)
/// Computes the hash of a sequence of nodes.
/// A sequence of nodes to calculate the hash of.
/// The hash of the sequence of nodes.
- protected int GetHashCode([CanBeNull] [ItemCanBeNull] ReadOnlyCollection nodes)
+ protected int GetHashCode([AllowNull, AllowItemNull] ReadOnlyCollection? nodes)
{
if (nodes == null)
return 0;
@@ -282,7 +296,8 @@ protected int GetHashCode([CanBeNull] [ItemCanBeNull] ReadOnlyCollectionA sequence of values to calculate the hash of.
/// The type of the elements of values.
/// The hash of the sequence of values.
- protected int GetHashCode([CanBeNull] [ItemCanBeNull] ReadOnlyCollection values)
+ protected int GetHashCode([AllowNull, AllowItemNull] ReadOnlyCollection? values)
+ where T : class
{
if (values == null)
return 0;
@@ -298,8 +313,8 @@ protected int GetHashCode([CanBeNull] [ItemCanBeNull] ReadOnlyCollection v
/// An to use to computes the hash of elements.
/// The type of the elements of values.
/// The hash of the sequence of values.
- protected int GetHashCode([ItemCanBeNull] [CanBeNull] ReadOnlyCollection values, [CanBeNull] Func getHashCode)
- where T: class
+ protected int GetHashCode([AllowNull, AllowItemNull] ReadOnlyCollection? values, Func? getHashCode)
+ where T : class
{
if (values == null)
return 0;
@@ -318,7 +333,7 @@ protected int GetHashCode([ItemCanBeNull] [CanBeNull] ReadOnlyCollection v
/// Gets the hash code for the specified ElementInit.
/// The ElementInit for which to get a hash code.
/// A hash code for the specified ElementInit.
- protected virtual int GetHashCodeElementInit([CanBeNull] ElementInit elementInit)
+ protected virtual int GetHashCodeElementInit([AllowNull] ElementInit? elementInit)
{
if (elementInit == null)
{
@@ -333,7 +348,7 @@ protected virtual int GetHashCodeElementInit([CanBeNull] ElementInit elementInit
/// Gets the hash code for the specified MemberBinding.
/// The MemberBinding for which to get a hash code.
/// A hash code for the specified MemberBinding.
- protected virtual int GetHashCodeMemberBinding([CanBeNull] MemberBinding memberBinding)
+ protected virtual int GetHashCodeMemberBinding([AllowNull] MemberBinding? memberBinding)
{
if (memberBinding == null)
{
@@ -356,8 +371,9 @@ protected virtual int GetHashCodeMemberBinding([CanBeNull] MemberBinding memberB
/// Gets the hash code for the specified MemberAssignment.
/// The MemberAssignment for which to get a hash code.
/// A hash code for the specified MemberAssignment.
- protected virtual int GetHashCodeMemberAssignment([NotNull] MemberAssignment memberAssignment)
+ protected virtual int GetHashCodeMemberAssignment([DisallowNull] MemberAssignment memberAssignment)
{
+ if (memberAssignment == null) throw new ArgumentNullException(nameof(memberAssignment));
return GetHashCode(
GetDefaultHashCode(memberAssignment.Member),
GetHashCode(memberAssignment.Expression));
@@ -366,8 +382,9 @@ protected virtual int GetHashCodeMemberAssignment([NotNull] MemberAssignment mem
/// Gets the hash code for the specified MemberMemberBinding.
/// The MemberMemberBinding for which to get a hash code.
/// A hash code for the specified MemberMemberBinding.
- protected virtual int GetHashCodeMemberMemberBinding([NotNull] MemberMemberBinding memberMemberBinding)
+ protected virtual int GetHashCodeMemberMemberBinding([DisallowNull] MemberMemberBinding memberMemberBinding)
{
+ if (memberMemberBinding == null) throw new ArgumentNullException(nameof(memberMemberBinding));
return GetHashCode(
GetDefaultHashCode(memberMemberBinding.Member),
GetHashCode(memberMemberBinding.Bindings, GetHashCodeMemberBinding));
@@ -376,8 +393,9 @@ protected virtual int GetHashCodeMemberMemberBinding([NotNull] MemberMemberBindi
/// Gets the hash code for the specified MemberListBinding.
/// The MemberListBinding for which to get a hash code.
/// A hash code for the specified MemberListBinding.
- protected virtual int GetHashCodeMemberListBinding([NotNull] MemberListBinding memberListBinding)
+ protected virtual int GetHashCodeMemberListBinding([DisallowNull] MemberListBinding memberListBinding)
{
+ if (memberListBinding == null) throw new ArgumentNullException(nameof(memberListBinding));
return GetHashCode(
GetDefaultHashCode(memberListBinding.Member),
GetHashCode(memberListBinding.Initializers, GetHashCodeElementInit));
@@ -386,7 +404,7 @@ protected virtual int GetHashCodeMemberListBinding([NotNull] MemberListBinding m
/// Gets the hash code for the specified LabelTarget.
/// The LabelTarget for which to get a hash code.
/// A hash code for the specified LabelTarget.
- protected virtual int GetHashCodeLabelTarget([CanBeNull] LabelTarget labelTarget)
+ protected virtual int GetHashCodeLabelTarget([AllowNull] LabelTarget? labelTarget)
{
if (labelTarget == null)
{
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Index.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Index.cs
index bc85c92..b05ca9c 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Index.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Index.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first IndexExpression to compare.
/// The second IndexExpression to compare.
/// true if the specified IndexExpression are equal; otherwise, false.
- protected virtual bool EqualsIndex([NotNull] IndexExpression x, [NotNull] IndexExpression y)
+ protected virtual bool EqualsIndex([DisallowNull] IndexExpression x, [DisallowNull] IndexExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Object, y.Object)
&& Equals(x.Indexer, y.Indexer)
@@ -25,8 +33,9 @@ protected virtual bool EqualsIndex([NotNull] IndexExpression x, [NotNull] IndexE
/// Gets the hash code for the specified IndexExpression.
/// The IndexExpression for which to get a hash code.
/// A hash code for the specified IndexExpression.
- protected virtual int GetHashCodeIndex([NotNull] IndexExpression node)
+ protected virtual int GetHashCodeIndex([DisallowNull] IndexExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.Object),
@@ -38,7 +47,7 @@ protected virtual int GetHashCodeIndex([NotNull] IndexExpression node)
/// The first IndexExpression to compare.
/// The second IndexExpression to compare.
/// true if the specified IndexExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(IndexExpression x, IndexExpression y)
+ bool IEqualityComparer.Equals([AllowNull] IndexExpression? x, [AllowNull] IndexExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -53,7 +62,7 @@ bool IEqualityComparer.Equals(IndexExpression x, IndexExpressio
/// The for which a hash code is to be returned.
/// A hash code for the specified IndexExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(IndexExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] IndexExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Invocation.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Invocation.cs
index df53926..8cb20a7 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Invocation.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Invocation.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparerThe first InvocationExpression to compare.
/// The second InvocationExpression to compare.
/// true if the specified InvocationExpression are equal; otherwise, false.
- protected virtual bool EqualsInvocation([NotNull] InvocationExpression x, [NotNull] InvocationExpression y)
+ protected virtual bool EqualsInvocation([DisallowNull] InvocationExpression x, [DisallowNull] InvocationExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Expression, y.Expression)
&& Equals(x.Arguments, y.Arguments);
@@ -24,8 +32,9 @@ protected virtual bool EqualsInvocation([NotNull] InvocationExpression x, [NotNu
/// Gets the hash code for the specified InvocationExpression.
/// The InvocationExpression for which to get a hash code.
/// A hash code for the specified InvocationExpression.
- protected virtual int GetHashCodeInvocation([NotNull] InvocationExpression node)
+ protected virtual int GetHashCodeInvocation([DisallowNull] InvocationExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.Expression),
@@ -36,7 +45,7 @@ protected virtual int GetHashCodeInvocation([NotNull] InvocationExpression node)
/// The first InvocationExpression to compare.
/// The second InvocationExpression to compare.
/// true if the specified InvocationExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(InvocationExpression x, InvocationExpression y)
+ bool IEqualityComparer.Equals([AllowNull] InvocationExpression? x, [AllowNull] InvocationExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -51,7 +60,7 @@ bool IEqualityComparer.Equals(InvocationExpression x, Invo
/// The for which a hash code is to be returned.
/// A hash code for the specified InvocationExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(InvocationExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] InvocationExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Label.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Label.cs
index c7cd50f..ce15699 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Label.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Label.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first LabelExpression to compare.
/// The second LabelExpression to compare.
/// true if the specified LabelExpression are equal; otherwise, false.
- protected virtual bool EqualsLabel([NotNull] LabelExpression x, [NotNull] LabelExpression y)
+ protected virtual bool EqualsLabel([DisallowNull] LabelExpression x, [DisallowNull] LabelExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& EqualsLabelTarget(x.Target, y.Target)
&& Equals(x.DefaultValue, y.DefaultValue);
@@ -24,8 +32,9 @@ protected virtual bool EqualsLabel([NotNull] LabelExpression x, [NotNull] LabelE
/// Gets the hash code for the specified LabelExpression.
/// The LabelExpression for which to get a hash code.
/// A hash code for the specified LabelExpression.
- protected virtual int GetHashCodeLabel([NotNull] LabelExpression node)
+ protected virtual int GetHashCodeLabel([DisallowNull] LabelExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCodeLabelTarget(node.Target),
@@ -36,7 +45,7 @@ protected virtual int GetHashCodeLabel([NotNull] LabelExpression node)
/// The first LabelExpression to compare.
/// The second LabelExpression to compare.
/// true if the specified LabelExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(LabelExpression x, LabelExpression y)
+ bool IEqualityComparer.Equals([AllowNull] LabelExpression? x, [AllowNull] LabelExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -51,7 +60,7 @@ bool IEqualityComparer.Equals(LabelExpression x, LabelExpressio
/// The for which a hash code is to be returned.
/// A hash code for the specified LabelExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(LabelExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] LabelExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Lambda.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Lambda.cs
index 4ff3591..051584c 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Lambda.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Lambda.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,18 +20,21 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first LambdaExpression to compare.
/// The second LambdaExpression to compare.
/// true if the specified LambdaExpression are equal; otherwise, false.
- protected virtual bool EqualsLambda([NotNull] LambdaExpression x, LambdaExpression y)
+ protected virtual bool EqualsLambda([DisallowNull] LambdaExpression x, [DisallowNull] LambdaExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
- && Equals(x.Parameters, y.Parameters, EqualsParameter)
- && new ExpressionEqualityComparer(x.Parameters, y.Parameters).Equals(x.Body, y.Body);
+ && Equals(x.Parameters, y.Parameters, EqualsParameter)
+ && new ExpressionEqualityComparer(x.Parameters, y.Parameters).Equals(x.Body, y.Body);
}
/// Gets the hash code for the specified LambdaExpression.
/// The LambdaExpression for which to get a hash code.
/// A hash code for the specified LambdaExpression.
- protected virtual int GetHashCodeLambda([NotNull] LambdaExpression node)
+ protected virtual int GetHashCodeLambda([DisallowNull] LambdaExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.Parameters, GetHashCodeParameter),
@@ -36,7 +45,7 @@ protected virtual int GetHashCodeLambda([NotNull] LambdaExpression node)
/// The first LambdaExpression to compare.
/// The second LambdaExpression to compare.
/// true if the specified LambdaExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(LambdaExpression x, LambdaExpression y)
+ bool IEqualityComparer.Equals([AllowNull] LambdaExpression? x, [AllowNull] LambdaExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -51,7 +60,7 @@ bool IEqualityComparer.Equals(LambdaExpression x, LambdaExpres
/// The for which a hash code is to be returned.
/// A hash code for the specified LambdaExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(LambdaExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] LambdaExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.ListInit.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.ListInit.cs
index 97768e6..347d7d8 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.ListInit.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.ListInit.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first ListInitExpression to compare.
/// The second ListInitExpression to compare.
/// true if the specified ListInitExpression are equal; otherwise, false.
- protected virtual bool EqualsListInit([NotNull] ListInitExpression x, [NotNull] ListInitExpression y)
+ protected virtual bool EqualsListInit([DisallowNull] ListInitExpression x, [DisallowNull] ListInitExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.NewExpression, y.NewExpression)
&& Equals(x.Initializers, y.Initializers, EqualsElementInit);
@@ -24,8 +32,9 @@ protected virtual bool EqualsListInit([NotNull] ListInitExpression x, [NotNull]
/// Gets the hash code for the specified ListInitExpression.
/// The ListInitExpression for which to get a hash code.
/// A hash code for the specified ListInitExpression.
- protected virtual int GetHashCodeListInit([NotNull] ListInitExpression node)
+ protected virtual int GetHashCodeListInit([DisallowNull] ListInitExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.NewExpression),
@@ -36,7 +45,7 @@ protected virtual int GetHashCodeListInit([NotNull] ListInitExpression node)
/// The first ListInitExpression to compare.
/// The second ListInitExpression to compare.
/// true if the specified ListInitExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(ListInitExpression x, ListInitExpression y)
+ bool IEqualityComparer.Equals([AllowNull] ListInitExpression? x, [AllowNull] ListInitExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -51,7 +60,7 @@ bool IEqualityComparer.Equals(ListInitExpression x, ListInit
/// The for which a hash code is to be returned.
/// A hash code for the specified ListInitExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(ListInitExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] ListInitExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Loop.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Loop.cs
index 8247c74..714963d 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Loop.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Loop.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first LoopExpression to compare.
/// The second LoopExpression to compare.
/// true if the specified LoopExpression are equal; otherwise, false.
- protected virtual bool EqualsLoop([NotNull] LoopExpression x, [NotNull] LoopExpression y)
+ protected virtual bool EqualsLoop([DisallowNull] LoopExpression x, [DisallowNull] LoopExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Body, y.Body)
&& EqualsLabelTarget(x.ContinueLabel, y.ContinueLabel)
@@ -25,8 +33,9 @@ protected virtual bool EqualsLoop([NotNull] LoopExpression x, [NotNull] LoopExpr
/// Gets the hash code for the specified LoopExpression.
/// The LoopExpression for which to get a hash code.
/// A hash code for the specified LoopExpression.
- protected virtual int GetHashCodeLoop([NotNull] LoopExpression node)
+ protected virtual int GetHashCodeLoop([DisallowNull] LoopExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.Body),
@@ -38,7 +47,7 @@ protected virtual int GetHashCodeLoop([NotNull] LoopExpression node)
/// The first LoopExpression to compare.
/// The second LoopExpression to compare.
/// true if the specified LoopExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(LoopExpression x, LoopExpression y)
+ bool IEqualityComparer.Equals([AllowNull] LoopExpression? x, [AllowNull] LoopExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -53,7 +62,7 @@ bool IEqualityComparer.Equals(LoopExpression x, LoopExpression y
/// The for which a hash code is to be returned.
/// A hash code for the specified LoopExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(LoopExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] LoopExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Member.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Member.cs
index 77e940d..c3c12fe 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Member.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Member.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first MemberExpression to compare.
/// The second MemberExpression to compare.
/// true if the specified MemberExpression are equal; otherwise, false.
- protected virtual bool EqualsMember([NotNull] MemberExpression x, [NotNull] MemberExpression y)
+ protected virtual bool EqualsMember([DisallowNull] MemberExpression x, [DisallowNull] MemberExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Member, y.Member)
&& Equals(x.Expression, y.Expression);
@@ -24,8 +32,9 @@ protected virtual bool EqualsMember([NotNull] MemberExpression x, [NotNull] Memb
/// Gets the hash code for the specified MemberExpression.
/// The MemberExpression for which to get a hash code.
/// A hash code for the specified MemberExpression.
- protected virtual int GetHashCodeMember([NotNull] MemberExpression node)
+ protected virtual int GetHashCodeMember([DisallowNull] MemberExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetDefaultHashCode(node.Member),
@@ -36,7 +45,7 @@ protected virtual int GetHashCodeMember([NotNull] MemberExpression node)
/// The first MemberExpression to compare.
/// The second MemberExpression to compare.
/// true if the specified MemberExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(MemberExpression x, MemberExpression y)
+ bool IEqualityComparer.Equals([AllowNull] MemberExpression? x, [AllowNull] MemberExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -51,7 +60,7 @@ bool IEqualityComparer.Equals(MemberExpression x, MemberExpres
/// The for which a hash code is to be returned.
/// A hash code for the specified MemberExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(MemberExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] MemberExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.MemberInit.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.MemberInit.cs
index eebe956..f4454ae 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.MemberInit.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.MemberInit.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparerThe first MemberInitExpression to compare.
/// The second MemberInitExpression to compare.
/// true if the specified MemberInitExpression are equal; otherwise, false.
- protected virtual bool EqualsMemberInit([NotNull] MemberInitExpression x, [NotNull] MemberInitExpression y)
+ protected virtual bool EqualsMemberInit([DisallowNull] MemberInitExpression x, [DisallowNull] MemberInitExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.NewExpression, y.NewExpression)
&& Equals(x.Bindings, y.Bindings, EqualsMemberBinding);
@@ -24,8 +32,9 @@ protected virtual bool EqualsMemberInit([NotNull] MemberInitExpression x, [NotNu
/// Gets the hash code for the specified MemberInitExpression.
/// The MemberInitExpression for which to get a hash code.
/// A hash code for the specified MemberInitExpression.
- protected virtual int GetHashCodeMemberInit([NotNull] MemberInitExpression node)
+ protected virtual int GetHashCodeMemberInit([DisallowNull] MemberInitExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.NewExpression),
@@ -36,7 +45,7 @@ protected virtual int GetHashCodeMemberInit([NotNull] MemberInitExpression node)
/// The first MemberInitExpression to compare.
/// The second MemberInitExpression to compare.
/// true if the specified MemberInitExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(MemberInitExpression x, MemberInitExpression y)
+ bool IEqualityComparer.Equals([AllowNull] MemberInitExpression? x, [AllowNull] MemberInitExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -51,7 +60,7 @@ bool IEqualityComparer.Equals(MemberInitExpression x, Memb
/// The for which a hash code is to be returned.
/// A hash code for the specified MemberInitExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(MemberInitExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] MemberInitExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.MethodCall.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.MethodCall.cs
index b98ba6b..5e140d0 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.MethodCall.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.MethodCall.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparerThe first MethodCallExpression to compare.
/// The second MethodCallExpression to compare.
/// true if the specified MethodCallExpression are equal; otherwise, false.
- protected virtual bool EqualsMethodCall([NotNull] MethodCallExpression x, [NotNull] MethodCallExpression y)
+ protected virtual bool EqualsMethodCall([DisallowNull] MethodCallExpression x, [DisallowNull] MethodCallExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Method, y.Method)
&& Equals(x.Object, y.Object)
@@ -25,8 +33,9 @@ protected virtual bool EqualsMethodCall([NotNull] MethodCallExpression x, [NotNu
/// Gets the hash code for the specified MethodCallExpression.
/// The MethodCallExpression for which to get a hash code.
/// A hash code for the specified MethodCallExpression.
- protected virtual int GetHashCodeMethodCall([NotNull] MethodCallExpression node)
+ protected virtual int GetHashCodeMethodCall([DisallowNull] MethodCallExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetDefaultHashCode(node.Method),
@@ -38,7 +47,7 @@ protected virtual int GetHashCodeMethodCall([NotNull] MethodCallExpression node)
/// The first MethodCallExpression to compare.
/// The second MethodCallExpression to compare.
/// true if the specified MethodCallExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(MethodCallExpression x, MethodCallExpression y)
+ bool IEqualityComparer.Equals([AllowNull] MethodCallExpression? x, [AllowNull] MethodCallExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -53,7 +62,7 @@ bool IEqualityComparer.Equals(MethodCallExpression x, Meth
/// The for which a hash code is to be returned.
/// A hash code for the specified MethodCallExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(MethodCallExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] MethodCallExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.New.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.New.cs
index a2b3049..6f48393 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.New.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.New.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first NewExpression to compare.
/// The second NewExpression to compare.
/// true if the specified NewExpression are equal; otherwise, false.
- protected virtual bool EqualsNew([NotNull] NewExpression x, [NotNull] NewExpression y)
+ protected virtual bool EqualsNew([DisallowNull] NewExpression x, [DisallowNull] NewExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Constructor, y.Constructor)
&& Equals(x.Members, y.Members)
@@ -25,8 +33,9 @@ protected virtual bool EqualsNew([NotNull] NewExpression x, [NotNull] NewExpress
/// Gets the hash code for the specified NewExpression.
/// The NewExpression for which to get a hash code.
/// A hash code for the specified NewExpression.
- protected virtual int GetHashCodeNew([NotNull] NewExpression node)
+ protected virtual int GetHashCodeNew([DisallowNull] NewExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetDefaultHashCode(node.Constructor),
@@ -38,7 +47,7 @@ protected virtual int GetHashCodeNew([NotNull] NewExpression node)
/// The first NewExpression to compare.
/// The second NewExpression to compare.
/// true if the specified NewExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(NewExpression x, NewExpression y)
+ bool IEqualityComparer.Equals([AllowNull] NewExpression? x, [AllowNull] NewExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -53,7 +62,7 @@ bool IEqualityComparer.Equals(NewExpression x, NewExpression y)
/// The for which a hash code is to be returned.
/// A hash code for the specified NewExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(NewExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] NewExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.NewArray.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.NewArray.cs
index c429242..212ec38 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.NewArray.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.NewArray.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first NewArrayExpression to compare.
/// The second NewArrayExpression to compare.
/// true if the specified NewArrayExpression are equal; otherwise, false.
- protected virtual bool EqualsNewArray([NotNull] NewArrayExpression x, [NotNull] NewArrayExpression y)
+ protected virtual bool EqualsNewArray([DisallowNull] NewArrayExpression x, [DisallowNull] NewArrayExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Expressions, y.Expressions);
}
@@ -23,8 +31,9 @@ protected virtual bool EqualsNewArray([NotNull] NewArrayExpression x, [NotNull]
/// Gets the hash code for the specified NewArrayExpression.
/// The NewArrayExpression for which to get a hash code.
/// A hash code for the specified NewArrayExpression.
- protected virtual int GetHashCodeNewArray([NotNull] NewArrayExpression node)
+ protected virtual int GetHashCodeNewArray([DisallowNull] NewArrayExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.Expressions));
@@ -34,7 +43,7 @@ protected virtual int GetHashCodeNewArray([NotNull] NewArrayExpression node)
/// The first NewArrayExpression to compare.
/// The second NewArrayExpression to compare.
/// true if the specified NewArrayExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(NewArrayExpression x, NewArrayExpression y)
+ bool IEqualityComparer.Equals([AllowNull] NewArrayExpression? x, [AllowNull] NewArrayExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -49,7 +58,7 @@ bool IEqualityComparer.Equals(NewArrayExpression x, NewArray
/// The for which a hash code is to be returned.
/// A hash code for the specified NewArrayExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(NewArrayExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] NewArrayExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Parameter.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Parameter.cs
index 1a44ed8..e5c37b3 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Parameter.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Parameter.cs
@@ -5,18 +5,25 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
partial class ExpressionEqualityComparer : IEqualityComparer
{
- private readonly ReadOnlyCollection _xParameters;
- private readonly ReadOnlyCollection _yParameters;
+ private readonly ReadOnlyCollection? _xParameters;
+ private readonly ReadOnlyCollection? _yParameters;
private ExpressionEqualityComparer(
ReadOnlyCollection xParameters,
ReadOnlyCollection yParameters)
+ : this()
{
_xParameters = xParameters;
_yParameters = yParameters;
@@ -26,8 +33,10 @@ private ExpressionEqualityComparer(
/// The first ParameterExpression to compare.
/// The second ParameterExpression to compare.
/// true if the specified ParameterExpression are equal; otherwise, false.
- protected virtual bool EqualsParameter([NotNull] ParameterExpression x, [NotNull] ParameterExpression y)
+ protected virtual bool EqualsParameter([DisallowNull] ParameterExpression x, [DisallowNull] ParameterExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& (_xParameters?.IndexOf(x) ?? 0) == (_yParameters?.IndexOf(y) ?? 0)
&& x.IsByRef == y.IsByRef;
@@ -36,8 +45,9 @@ protected virtual bool EqualsParameter([NotNull] ParameterExpression x, [NotNull
/// Gets the hash code for the specified ParameterExpression.
/// The ParameterExpression for which to get a hash code.
/// A hash code for the specified ParameterExpression.
- protected virtual int GetHashCodeParameter([NotNull] ParameterExpression node)
+ protected virtual int GetHashCodeParameter([DisallowNull] ParameterExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
node.IsByRef.GetHashCode());
@@ -47,7 +57,7 @@ protected virtual int GetHashCodeParameter([NotNull] ParameterExpression node)
/// The first ParameterExpression to compare.
/// The second ParameterExpression to compare.
/// true if the specified ParameterExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(ParameterExpression x, ParameterExpression y)
+ bool IEqualityComparer.Equals([AllowNull] ParameterExpression? x, [AllowNull] ParameterExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -62,7 +72,7 @@ bool IEqualityComparer.Equals(ParameterExpression x, Parame
/// The for which a hash code is to be returned.
/// A hash code for the specified ParameterExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(ParameterExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] ParameterExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.RuntimeVariables.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.RuntimeVariables.cs
index bb1c612..6959473 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.RuntimeVariables.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.RuntimeVariables.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparerThe first RuntimeVariablesExpression to compare.
/// The second RuntimeVariablesExpression to compare.
/// true if the specified RuntimeVariablesExpression are equal; otherwise, false.
- protected virtual bool EqualsRuntimeVariables([NotNull] RuntimeVariablesExpression x, [NotNull] RuntimeVariablesExpression y)
+ protected virtual bool EqualsRuntimeVariables([DisallowNull] RuntimeVariablesExpression x, [DisallowNull] RuntimeVariablesExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Variables, y.Variables, EqualsParameter);
}
@@ -23,8 +31,9 @@ protected virtual bool EqualsRuntimeVariables([NotNull] RuntimeVariablesExpressi
/// Gets the hash code for the specified RuntimeVariablesExpression.
/// The RuntimeVariablesExpression for which to get a hash code.
/// A hash code for the specified RuntimeVariablesExpression.
- protected virtual int GetHashCodeRuntimeVariables([NotNull] RuntimeVariablesExpression node)
+ protected virtual int GetHashCodeRuntimeVariables([DisallowNull] RuntimeVariablesExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.Variables, GetHashCodeParameter));
@@ -34,7 +43,7 @@ protected virtual int GetHashCodeRuntimeVariables([NotNull] RuntimeVariablesExpr
/// The first RuntimeVariablesExpression to compare.
/// The second RuntimeVariablesExpression to compare.
/// true if the specified RuntimeVariablesExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(RuntimeVariablesExpression x, RuntimeVariablesExpression y)
+ bool IEqualityComparer.Equals([AllowNull] RuntimeVariablesExpression? x, [AllowNull] RuntimeVariablesExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -49,7 +58,7 @@ bool IEqualityComparer.Equals(RuntimeVariablesExpres
/// The for which a hash code is to be returned.
/// A hash code for the specified RuntimeVariablesExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(RuntimeVariablesExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] RuntimeVariablesExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Switch.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Switch.cs
index 87eca8a..328664f 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Switch.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Switch.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first SwitchExpression to compare.
/// The second SwitchExpression to compare.
/// true if the specified SwitchExpression are equal; otherwise, false.
- protected virtual bool EqualsSwitch([NotNull] SwitchExpression x, [NotNull] SwitchExpression y)
+ protected virtual bool EqualsSwitch([DisallowNull] SwitchExpression x, [DisallowNull] SwitchExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.SwitchValue, y.SwitchValue)
&& Equals(x.Comparison, y.Comparison)
@@ -27,8 +35,10 @@ protected virtual bool EqualsSwitch([NotNull] SwitchExpression x, [NotNull] Swit
/// The first SwitchCase to compare.
/// The second SwitchCase to compare.
/// true if the specified SwitchCase are equal; otherwise, false.
- protected virtual bool EqualsSwitchCase([NotNull] SwitchCase x, [NotNull] SwitchCase y)
+ protected virtual bool EqualsSwitchCase([DisallowNull] SwitchCase x, [DisallowNull] SwitchCase y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return Equals(x.Body, y.Body)
&& Equals(x.TestValues, y.TestValues);
}
@@ -36,8 +46,9 @@ protected virtual bool EqualsSwitchCase([NotNull] SwitchCase x, [NotNull] Switch
/// Gets the hash code for the specified SwitchExpression.
/// The SwitchExpression for which to get a hash code.
/// A hash code for the specified SwitchExpression.
- protected virtual int GetHashCodeSwitch([NotNull] SwitchExpression node)
+ protected virtual int GetHashCodeSwitch([DisallowNull] SwitchExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.SwitchValue),
@@ -48,8 +59,9 @@ protected virtual int GetHashCodeSwitch([NotNull] SwitchExpression node)
/// Gets the hash code for the specified SwitchCase.
/// The SwitchCase for which to get a hash code.
/// A hash code for the specified SwitchCase.
- protected virtual int GetHashCodeSwitchCase([NotNull] SwitchCase switchCase)
+ protected virtual int GetHashCodeSwitchCase([DisallowNull] SwitchCase switchCase)
{
+ if (switchCase == null) throw new ArgumentNullException(nameof(switchCase));
return GetHashCode(
GetHashCode(switchCase.Body),
GetHashCode(switchCase.TestValues));
@@ -59,7 +71,7 @@ protected virtual int GetHashCodeSwitchCase([NotNull] SwitchCase switchCase)
/// The first SwitchExpression to compare.
/// The second SwitchExpression to compare.
/// true if the specified SwitchExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(SwitchExpression x, SwitchExpression y)
+ bool IEqualityComparer.Equals([AllowNull] SwitchExpression? x, [AllowNull] SwitchExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -74,7 +86,7 @@ bool IEqualityComparer.Equals(SwitchExpression x, SwitchExpres
/// The for which a hash code is to be returned.
/// A hash code for the specified SwitchExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(SwitchExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] SwitchExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Try.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Try.cs
index 8f0363a..95a2ceb 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Try.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Try.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first TryExpression to compare.
/// The second TryExpression to compare.
/// true if the specified TryExpression are equal; otherwise, false.
- protected virtual bool EqualsTry([NotNull] TryExpression x, [NotNull] TryExpression y)
+ protected virtual bool EqualsTry([DisallowNull] TryExpression x, [DisallowNull] TryExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Body, y.Body)
&& Equals(x.Fault, y.Fault)
@@ -27,8 +35,10 @@ protected virtual bool EqualsTry([NotNull] TryExpression x, [NotNull] TryExpress
/// The first CatchBlock to compare.
/// The second CatchBlock to compare.
/// true if the specified CatchBlock are equal; otherwise, false.
- protected virtual bool EqualsCatchBlock([NotNull] CatchBlock x, [NotNull] CatchBlock y)
+ protected virtual bool EqualsCatchBlock([DisallowNull] CatchBlock x, [DisallowNull] CatchBlock y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Test == y.Test
&& Equals(x.Body, y.Body)
&& Equals(x.Filter, y.Filter)
@@ -38,8 +48,9 @@ protected virtual bool EqualsCatchBlock([NotNull] CatchBlock x, [NotNull] CatchB
/// Gets the hash code for the specified TryExpression.
/// The TryExpression for which to get a hash code.
/// A hash code for the specified TryExpression.
- protected virtual int GetHashCodeTry([NotNull] TryExpression node)
+ protected virtual int GetHashCodeTry([DisallowNull] TryExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetHashCode(node.Body),
@@ -51,8 +62,9 @@ protected virtual int GetHashCodeTry([NotNull] TryExpression node)
/// Gets the hash code for the specified CatchBlock.
/// The CatchBlock for which to get a hash code.
/// A hash code for the specified CatchBlock.
- protected virtual int GetHashCodeCatchBlock([NotNull] CatchBlock catchBlock)
+ protected virtual int GetHashCodeCatchBlock([DisallowNull] CatchBlock catchBlock)
{
+ if (catchBlock == null) throw new ArgumentNullException(nameof(catchBlock));
return GetHashCode(
GetDefaultHashCode(catchBlock.Test),
GetHashCode(catchBlock.Body),
@@ -64,7 +76,7 @@ protected virtual int GetHashCodeCatchBlock([NotNull] CatchBlock catchBlock)
/// The first TryExpression to compare.
/// The second TryExpression to compare.
/// true if the specified TryExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(TryExpression x, TryExpression y)
+ bool IEqualityComparer.Equals([AllowNull] TryExpression? x, [AllowNull] TryExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -79,7 +91,7 @@ bool IEqualityComparer.Equals(TryExpression x, TryExpression y)
/// The for which a hash code is to be returned.
/// A hash code for the specified TryExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(TryExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] TryExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.TypeBinary.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.TypeBinary.cs
index 14b8176..652c33b 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.TypeBinary.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.TypeBinary.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparerThe first TypeBinaryExpression to compare.
/// The second TypeBinaryExpression to compare.
/// true if the specified TypeBinaryExpression are equal; otherwise, false.
- protected virtual bool EqualsTypeBinary([NotNull] TypeBinaryExpression x, [NotNull] TypeBinaryExpression y)
+ protected virtual bool EqualsTypeBinary([DisallowNull] TypeBinaryExpression x, [DisallowNull] TypeBinaryExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& x.TypeOperand == y.TypeOperand
&& Equals(x.Expression, y.Expression);
@@ -24,8 +32,9 @@ protected virtual bool EqualsTypeBinary([NotNull] TypeBinaryExpression x, [NotNu
/// Gets the hash code for the specified TypeBinaryExpression.
/// The TypeBinaryExpression for which to get a hash code.
/// A hash code for the specified TypeBinaryExpression.
- protected virtual int GetHashCodeTypeBinary([NotNull] TypeBinaryExpression node)
+ protected virtual int GetHashCodeTypeBinary([DisallowNull] TypeBinaryExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetDefaultHashCode(node.TypeOperand),
@@ -36,7 +45,7 @@ protected virtual int GetHashCodeTypeBinary([NotNull] TypeBinaryExpression node)
/// The first TypeBinaryExpression to compare.
/// The second TypeBinaryExpression to compare.
/// true if the specified TypeBinaryExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(TypeBinaryExpression x, TypeBinaryExpression y)
+ bool IEqualityComparer.Equals([AllowNull] TypeBinaryExpression? x, [AllowNull] TypeBinaryExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -51,7 +60,7 @@ bool IEqualityComparer.Equals(TypeBinaryExpression x, Type
/// The for which a hash code is to be returned.
/// A hash code for the specified TypeBinaryExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(TypeBinaryExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] TypeBinaryExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Unary.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Unary.cs
index e9bc20b..498eeed 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Unary.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.Unary.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -14,8 +20,10 @@ partial class ExpressionEqualityComparer : IEqualityComparer
/// The first UnaryExpression to compare.
/// The second UnaryExpression to compare.
/// true if the specified UnaryExpression are equal; otherwise, false.
- protected virtual bool EqualsUnary([NotNull] UnaryExpression x, [NotNull] UnaryExpression y)
+ protected virtual bool EqualsUnary([DisallowNull] UnaryExpression x, [DisallowNull] UnaryExpression y)
{
+ if (x == null) throw new ArgumentNullException(nameof(x));
+ if (y == null) throw new ArgumentNullException(nameof(y));
return x.Type == y.Type
&& Equals(x.Method, y.Method)
&& Equals(x.Operand, y.Operand);
@@ -24,8 +32,9 @@ protected virtual bool EqualsUnary([NotNull] UnaryExpression x, [NotNull] UnaryE
/// Gets the hash code for the specified UnaryExpression.
/// The UnaryExpression for which to get a hash code.
/// A hash code for the specified UnaryExpression.
- protected virtual int GetHashCodeUnary([NotNull] UnaryExpression node)
+ protected virtual int GetHashCodeUnary([DisallowNull] UnaryExpression node)
{
+ if (node == null) throw new ArgumentNullException(nameof(node));
return GetHashCode(
GetDefaultHashCode(node.Type),
GetDefaultHashCode(node.Method),
@@ -36,7 +45,7 @@ protected virtual int GetHashCodeUnary([NotNull] UnaryExpression node)
/// The first UnaryExpression to compare.
/// The second UnaryExpression to compare.
/// true if the specified UnaryExpressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(UnaryExpression x, UnaryExpression y)
+ bool IEqualityComparer.Equals([AllowNull] UnaryExpression? x, [AllowNull] UnaryExpression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -51,7 +60,7 @@ bool IEqualityComparer.Equals(UnaryExpression x, UnaryExpressio
/// The for which a hash code is to be returned.
/// A hash code for the specified UnaryExpression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(UnaryExpression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] UnaryExpression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.cs b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.cs
index 9dee377..b03cf34 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.cs
+++ b/src/ExpressionTreeToolkit.Core/ExpressionEqualityComparer.cs
@@ -4,7 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using JetBrains.Annotations;
+using System.Diagnostics.CodeAnalysis;
+
+#if JETBRAINS_ANNOTATIONS
+using AllowNullAttribute = JetBrains.Annotations.CanBeNullAttribute;
+using DisallowNullAttribute = JetBrains.Annotations.NotNullAttribute;
+using AllowItemNullAttribute = JetBrains.Annotations.ItemCanBeNullAttribute;
+#endif
namespace ExpressionTreeToolkit
{
@@ -32,7 +38,7 @@ public ExpressionEqualityComparer()
/// Initializes a new instance of the ExpressionEqualityComparer class and uses the specified equality comparer for the unknown Expression node.
///
/// The EqualityComparer for comparing unknown Expression node in the Expression tree, or null to use the default EqualityComparer implementation.
- public ExpressionEqualityComparer([CanBeNull] IEqualityComparer equalityComparer)
+ public ExpressionEqualityComparer([AllowNull] IEqualityComparer? equalityComparer)
{
_equalityComparer = equalityComparer ?? EqualityComparer.Default;
}
@@ -41,7 +47,7 @@ public ExpressionEqualityComparer([CanBeNull] IEqualityComparer equa
/// The first Expression to compare.
/// The second Expression to compare.
/// true if the specified Expressions are equal; otherwise, false.
- public virtual bool Equals([CanBeNull] Expression x, [CanBeNull] Expression y)
+ public virtual bool Equals([AllowNull] Expression? x, [AllowNull] Expression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -173,7 +179,7 @@ public virtual bool Equals([CanBeNull] Expression x, [CanBeNull] Expression y)
/// Serves as a hash function for the specified Expression for hashing algorithms and data structures, such as a hash table.
/// The Expression for which to get a hash code.
/// A hash code for the specified Expression.
- public virtual int GetHashCode([CanBeNull] Expression expression)
+ public virtual int GetHashCode([AllowNull] Expression? expression)
{
if (expression == null)
return 0;
@@ -300,7 +306,7 @@ public virtual int GetHashCode([CanBeNull] Expression expression)
/// The first Expression to compare.
/// The second Expression to compare.
/// true if the specified Expressions are equal; otherwise, false.
- bool IEqualityComparer.Equals(Expression x, Expression y)
+ bool IEqualityComparer.Equals([AllowNull] Expression? x, [AllowNull] Expression? y)
{
if (ReferenceEquals(x, y))
return true;
@@ -316,7 +322,7 @@ bool IEqualityComparer.Equals(Expression x, Expression y)
/// The second Expression to compare.
/// true if the specified Expressions are equal; otherwise, false.
/// x or y is of a type that cannot be cast to Expression.
- bool System.Collections.IEqualityComparer.Equals(object x, object y)
+ bool System.Collections.IEqualityComparer.Equals([AllowNull] object? x, [AllowNull] object? y)
{
if (x == y)
return true;
@@ -334,7 +340,7 @@ bool System.Collections.IEqualityComparer.Equals(object x, object y)
/// The Expression for which to get a hash code.
/// A hash code for the specified Expression.
/// The obj is null.
- int IEqualityComparer.GetHashCode(Expression obj)
+ int IEqualityComparer.GetHashCode([DisallowNull] Expression obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
@@ -346,7 +352,7 @@ int IEqualityComparer.GetHashCode(Expression obj)
/// A hash code for the specified Expression.
/// The obj is null.
/// obj is of a type that cannot be cast to Expression
- int System.Collections.IEqualityComparer.GetHashCode([NotNull] object obj)
+ int System.Collections.IEqualityComparer.GetHashCode([DisallowNull] object obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
diff --git a/src/ExpressionTreeToolkit.Core/ExpressionTreeToolkit.Core.csproj b/src/ExpressionTreeToolkit.Core/ExpressionTreeToolkit.Core.csproj
index e0f7577..553557d 100644
--- a/src/ExpressionTreeToolkit.Core/ExpressionTreeToolkit.Core.csproj
+++ b/src/ExpressionTreeToolkit.Core/ExpressionTreeToolkit.Core.csproj
@@ -9,10 +9,9 @@
-
+
All
-
diff --git a/test/ExpressionTreeToolkit.UnitTests/ExpressionTreeToolkit.UnitTests.csproj b/test/ExpressionTreeToolkit.UnitTests/ExpressionTreeToolkit.UnitTests.csproj
index f6051f5..fbc1780 100644
--- a/test/ExpressionTreeToolkit.UnitTests/ExpressionTreeToolkit.UnitTests.csproj
+++ b/test/ExpressionTreeToolkit.UnitTests/ExpressionTreeToolkit.UnitTests.csproj
@@ -1,15 +1,15 @@
- netcoreapp2.0;net461
+ netcoreapp2.1;netcoreapp3.1;net461
false
-
-
-
+
+
+