il-repack: Bug: cannot reduce access in 2.0.15

The following code fails when run through ilrepack on windows. the error is Unhandled Exception: System.TypeLoadException: Derived method 'Meth' in type 'TestIlRepack.ArrayHandler``1' from assembly 'x, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' cannot reduce access.

The method in Class3 is having its access changed to internal from public while the base class remains public.

using System;
using System.Threading.Tasks;

namespace TestIlRepack {
    class Program {
        static void Main(string[] args) {
            GC.KeepAlive(new Class3());
            System.Console.WriteLine("done");
        }
    }

    class Class3 : Class2<Array> {
        public override ValueTask<Array> Meth() { 
            throw new NotImplementedException();
        }
    }

    abstract class Class2<T> : Class1 {

        public abstract ValueTask<T> Meth();

        internal override ValueTask<T2> Meth<T2>() {
            throw new NotImplementedException();
        }
    }

    abstract class Class1 {
        internal abstract ValueTask<T> Meth<T>();
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 17 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Yes, will do a bunch of modernization and go through the outstanding PRs and bugs as time allows

Yes, stay tuned

Also hit this on Program Synthesis: https://www.microsoft.com/en-us/research/project/prose-framework/.

In that case, it’s for protected method that overrides a parent class’ method, and later overriden by a deeper child.

Any plan to merge the fix and publish an official nuget?