Skip to content

Commit

Permalink
Merge branch 'hotfix/langsamu-hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
alecsg77 committed May 14, 2020
2 parents da989e1 + 0f7c75a commit f263f80
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected virtual bool EqualsCatchBlock([NotNull] CatchBlock x, [NotNull] CatchB
return x.Test == y.Test
&& Equals(x.Body, y.Body)
&& Equals(x.Filter, y.Filter)
&& EqualsParameter(x.Variable, y.Variable);
&& Equals(x.Variable, y.Variable);
}

/// <summary>Gets the hash code for the specified TryExpression.</summary>
Expand All @@ -57,7 +57,7 @@ protected virtual int GetHashCodeCatchBlock([NotNull] CatchBlock catchBlock)
GetDefaultHashCode(catchBlock.Test),
GetHashCode(catchBlock.Body),
GetHashCode(catchBlock.Filter),
GetHashCodeParameter(catchBlock.Variable));
GetHashCode(catchBlock.Variable));
}

/// <summary>Determines whether the specified TryExpressions are equal.</summary>
Expand Down
37 changes: 37 additions & 0 deletions test/ExpressionTreeToolkit.UnitTests/Bugs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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.Collections.Generic;
using System.Linq.Expressions;
using Xunit;

namespace ExpressionTreeToolkit.UnitTests
{
public class Bugs
{
private readonly IEqualityComparer<Expression> _target = ExpressionEqualityComparer.Default;

private void AssertAreEqual(Expression x, Expression y)
{
Assert.True(_target.Equals(x, y));
Assert.Equal(_target.GetHashCode(x), _target.GetHashCode(y));
}

private void AssertAreNotEqual(Expression x, Expression y)
{
Assert.False(_target.Equals(x, y));
}

[Fact]
public void Issue_4()
{
// Expression similar to this code `try { } catch (Exception) { }`
// Same expression twice to evade reference equality check
var x = Expression.TryCatch(Expression.Empty(), Expression.Catch(typeof(Exception), Expression.Empty()));
var y = Expression.TryCatch(Expression.Empty(), Expression.Catch(typeof(Exception), Expression.Empty()));

AssertAreEqual(x, y);
}
}
}

0 comments on commit f263f80

Please sign in to comment.