-
Notifications
You must be signed in to change notification settings - Fork 920
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
Fix building proxies for classess with static interface members #3298
Conversation
@bahusoid @fredericDelaporte, I want to know your opinion:
|
5.4
No opinion. It seems static members are tested without it.
I don't get it. Can you provide an example? |
I wrote my comment before I discovered that static interface members do not work in lower .NET (Core) versions.
This is the modification of the test that will fail in .NET 7: [Test(Description = "GH3295")]
public void VerifyProxyForInterfaceWithStaticAbstractMethod()
{
var factory = new StaticProxyFactory();
factory.PostInstantiate(
typeof(IWithStaticMethods).FullName,
typeof(object),
new HashSet<System.Type> { typeof(INHibernateProxy), typeof(IWithStaticMethods) },
null, null, null, true);
var proxy = factory.GetProxy(1, null);
Assert.That(proxy, Is.Not.Null);
} There are two scenarios where this can be used:
However, as I said, it does not make much sense for to. |
To enable the test for this case, yes we should switch net6.0 target to 7.0 in the test project. Ok for the target branch. |
C# 8 (.NET Core 3.1) has introduced static interface members. Currently they are throwing "IndexOutOfRangeException: Index was outside the bounds of the array."
C# 11 (.NET 7) has introduced abstract/virtual interface members. Currently they are throwing "TypeLoadException: Signature of the body and declaration in a method implementation do not match."
In general static interface members should not be proxiable (same as regular static methods) with one exception of interface-only entities for which, if such interface would have an abstract static member it must be implemented by a proxy. However, I could not find a valid use case for this. In this case proxy will fail with "System.TypeLoadException: Virtual static method 'XXX' is not implemented on type 'YYYProxy' from assembly 'YYYProxyAssembly'"
Fixes #3295