1 // Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
2 
3 using System.Diagnostics.CodeAnalysis;
4 using System.Linq.Expressions;
5 
6 #pragma warning disable 659 // overrides AddToHashCodeCombiner instead
7 
8 namespace System.Web.Mvc.ExpressionUtil
9 {
10     // ConstantExpression fingerprint class
11     //
12     // A ConstantExpression might represent a captured local variable, so we can't compile
13     // the value directly into the cached function. Instead, a placeholder is generated
14     // and the value is hoisted into a local variables array. This placeholder can then
15     // be compiled and cached, and the array lookup happens at runtime.
16 
17     [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals", Justification = "Overrides AddToHashCodeCombiner() instead.")]
18     internal sealed class ConstantExpressionFingerprint : ExpressionFingerprint
19     {
ConstantExpressionFingerprint(ExpressionType nodeType, Type type)20         public ConstantExpressionFingerprint(ExpressionType nodeType, Type type)
21             : base(nodeType, type)
22         {
23             // There are no properties on ConstantExpression that are worth including in
24             // the fingerprint.
25         }
26 
Equals(object obj)27         public override bool Equals(object obj)
28         {
29             ConstantExpressionFingerprint other = obj as ConstantExpressionFingerprint;
30             return (other != null)
31                    && this.Equals(other);
32         }
33     }
34 }
35