ILSpy icon indicating copy to clipboard operation
ILSpy copied to clipboard

Generics Params types not getting decompiled correctly

Open skysgh opened this issue 15 years ago • 2 comments

Just gave it a first spin. Love where it's going! Definitely see a lot of use for it.

That said, did notice that v1.0 is decompiling some things incorrectly.

This: private static void Initialize() { Type attributeType = typeof (DefaultServiceAttribute); Type[] serviceTypes = AppDomain.CurrentDomain.GetTypesDecoratedWithAttributes(attributeType); foreach (Type serviceType in serviceTypes) { var defaultServiceAttribute = serviceType.GetAttribute(false);

            _container.Register(defaultServiceAttribute.ServiceInterface, serviceType);
        }
    }

got decompiled to:

    private static void Initialize()
    {
        Type typeFromHandle = typeof(DefaultServiceAttribute);
        Type[] typesDecoratedWithAttributes = AppDomain.CurrentDomain.GetTypesDecoratedWithAttributes(typeFromHandle, true);
        Type[] array = typesDecoratedWithAttributes;
        for (int i = 0; i < array.Length; i++)
        {
            Type type = array[i];
            DefaultServiceAttribute attribute = type.GetAttribute(false);
            ServiceLocatorService._container.Register(attribute.ServiceInterface, type, null, false, false);
        }
    }

losing its generic Type info in the GetAttribute method.

Again, thanks for all the hard work. Really fantastic.

skysgh avatar Nov 04 '11 08:11 skysgh

It's a bit difficult to see what's wrong here, looks like HTML ate your generics. I think this is the same issue as #293.

dgrunwald avatar Nov 26 '11 14:11 dgrunwald

This was likely fixed in the new decompiler engine (which just landed on the master branch).

siegfriedpammer avatar Sep 14 '17 20:09 siegfriedpammer