Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract property in hierachy with intermediate generic classes decompiled as default #179

Closed
DennisInSky opened this issue Dec 2, 2021 · 0 comments · Fixed by #180
Closed

Comments

@DennisInSky
Copy link
Contributor

DennisInSky commented Dec 2, 2021

For the case like below

abstract class Base
{
    public abstract string Value { get; }
}

abstract class Base<T> : Base
{
}

class IntChild : Base<int>
{
     public override string Value => "Int";
}

class StringChild : Base<string>
{
    public override string Value => "String";
}

the Base.Value property gets decompiled as null

The below change fixes it:

@@ -9,10 +9,14 @@ static class TypeHierarchy
        public static IEnumerable<Type> Traverse(Type root, IEnumerable<Type> ancestors)
        {
            var result = new List<Type>();
            var children = ancestors.ToLookup(t => t.BaseType);
            var children = ancestors.ToLookup(t =>
                t.BaseType.IsGenericType && !t.BaseType.IsGenericTypeDefinition // This covers hierarchies which include intermediate generic class like C -> B<int> -> A, D -> B<string> -> A
                    ? t.BaseType.GetGenericTypeDefinition()
                    : t.BaseType);

            if (!root.IsInterface)
            {
                Traverse(result, root, children);                
                Traverse(result, root, children);
            }
            else
            {
hazzik pushed a commit that referenced this issue Dec 14, 2021
Fixes #179

Co-authored-by: Alex Zaytsev <[email protected]>

+semver:feature
billybraga pushed a commit to billybraga/DelegateDecompiler that referenced this issue Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant