icsharpcode / ILSpy

.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
21.45k stars 3.35k forks source link

Generics Params types not getting decompiled correctly #287

Closed skysgh closed 7 years ago

skysgh commented 12 years ago

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.

dgrunwald commented 12 years ago

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.

siegfriedpammer commented 7 years ago

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