Facepunch / sbox-issues

177 stars 12 forks source link

Whitelist C# 11 static abstract/virtual interface members #6555

Open GavrilovNI opened 1 month ago

GavrilovNI commented 1 month ago

What it is?

@handsomematt closed #3441 and it looks like you can write abstract/virtual interface members but not use them

the following code

public interface ITest
{
    static virtual string TestString { get; } = string.Empty;
}

public class Test<T> where T : ITest
{
    public string Run()
    {
        return T.TestString;
    }
}

will produce

 10:20:09   PackageLoader/GameMenu Whitelist Error: .Test`1.Run(..) - [Constrained]   Missing callvirt following constrained prefix.

Why do you need to use this?

this is a cool c# feature writing oop code is gonna be easier with this

handsomematt commented 1 month ago

Will be resolved with #6557