1

Closed

Compare Enums

description

When I try to compare a class that has an enum in it, Compare returns a false positive if the enum values don't match. Debugging through the code, TypeHelper.CanHaveChildren(info.PropertyType) returns true for the enum. On the surface, that doesn't make sense.
If I add a check if the type is an enum in that method, the call works as expected.

Thanks,
Eric Gurney

comments

gfinzer wrote Jan 14, 2016 at 7:03 PM

Eric,

Thanks for finding this issue. Can you send post the fix that you created?

Thanks,
Greg

ekgurney14 wrote Jan 18, 2016 at 11:29 AM

Just added check for IsEnum to IsSimpleType...
        public static bool IsSimpleType(Type type)
        {
            if (type == null)
                return false;

            if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
            {
                type = Nullable.GetUnderlyingType(type);
            }

            return type.IsPrimitive
                    || type.IsEnum
                   || type == typeof(DateTime)
                   || type == typeof(decimal)
                   || type == typeof(string)
                   || type == typeof(Guid);

        }

gfinzer wrote Jan 18, 2016 at 12:58 PM

Eric,

Thanks for the fix. It will be a while before this fix can be checked in. Codeplex repositories have been down for weeks. We are still waiting for a fix.

Thanks,
Greg

ekgurney14 wrote Jan 18, 2016 at 1:37 PM

No problem. Using my private copy for now.
Sounds like a good reason to move to GitHub :)

Thanks,
Eric

ekgurney14 wrote Mar 4, 2016 at 1:06 PM

Now that you are over at github, are these issues still going to be tracked here, or should we resubmit them over at there?

Thanks,
Eric

gfinzer wrote Mar 4, 2016 at 1:58 PM

Eric,

We are going to track issues at Github now. This fix has already been submitted on Github.
https://github.com/GregFinzer/Compare-Net-Objects/commit/1cf7491f93b81e2398da022b24ce194912ad0037

Thanks,
Greg

wrote Mar 5, 2016 at 1:20 AM