Skip to content

Commit 760dec7

Browse files
committed
Linq/Visitors/NameUnNamedParameters.cs: Restore - we are not changing the assembly version, so we should not remove any symbols, even though they are no longer used.
1 parent cc2f1b2 commit 760dec7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq.Expressions;
4+
5+
namespace NHibernate.Linq.Visitors
6+
{
7+
[Obsolete("This class is not required by NHibernate anymore.")]
8+
public class NameUnNamedParameters : NhExpressionTreeVisitor
9+
{
10+
public static Expression Visit(Expression expression)
11+
{
12+
var visitor = new NameUnNamedParameters();
13+
14+
return visitor.VisitExpression(expression);
15+
}
16+
17+
private readonly Dictionary<ParameterExpression, ParameterExpression> _renamedParameters = new Dictionary<ParameterExpression, ParameterExpression>();
18+
19+
protected override Expression VisitParameterExpression(ParameterExpression expression)
20+
{
21+
if (string.IsNullOrEmpty(expression.Name))
22+
{
23+
ParameterExpression renamed;
24+
25+
if (_renamedParameters.TryGetValue(expression, out renamed))
26+
{
27+
return renamed;
28+
}
29+
30+
renamed = Expression.Parameter(expression.Type, Guid.NewGuid().ToString());
31+
32+
_renamedParameters.Add(expression, renamed);
33+
34+
return renamed;
35+
}
36+
37+
return base.VisitParameterExpression(expression);
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)