< Summary

Class:Azure.Data.Tables.Queryable.ReferenceEqualityComparer`1
Assembly:Azure.Data.Tables
File(s):C:\Git\azure-sdk-for-net\sdk\tables\Azure.Data.Tables\src\Queryable\ReferenceEqualityComparer{T}.cs
Covered lines:9
Uncovered lines:1
Coverable lines:10
Total lines:50
Line coverage:90% (9 of 10)
Covered branches:3
Total branches:4
Branch coverage:75% (3 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
get_Instance()-100%100%
Equals(...)-100%100%
GetHashCode(...)-66.67%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\tables\Azure.Data.Tables\src\Queryable\ReferenceEqualityComparer{T}.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Collections.Generic;
 5using System.Diagnostics;
 6
 7namespace Azure.Data.Tables.Queryable
 8{
 9
 10    internal sealed class ReferenceEqualityComparer<T> : ReferenceEqualityComparer, IEqualityComparer<T>
 11    {
 12        private static ReferenceEqualityComparer<T> s_instance;
 13
 14        private ReferenceEqualityComparer()
 215            : base()
 16        {
 217        }
 18
 19        internal static ReferenceEqualityComparer<T> Instance
 20        {
 21            get
 22            {
 92023                if (s_instance == null)
 24                {
 25                    Debug.Assert(!typeof(T).IsValueType, "!typeof(T).IsValueType -- can't use reference equality in a me
 226                    ReferenceEqualityComparer<T> newInstance = new ReferenceEqualityComparer<T>();
 227                    System.Threading.Interlocked.CompareExchange(ref s_instance, newInstance, null);
 28                }
 29
 92030                return s_instance;
 31            }
 32        }
 33
 34        public bool Equals(T x, T y)
 35        {
 6436            return object.ReferenceEquals(x, y);
 37        }
 38
 39        public int GetHashCode(T obj)
 40        {
 67041            if (obj == null)
 42            {
 043                return 0;
 44            }
 45
 67046            return obj.GetHashCode();
 47        }
 48
 49    }
 50}