Description
I found code that throws a VerificationException for static virtual interface methods, and generic constraints, similar to this issue #73658 but without reflection.
Reproduction Steps
Run this code:
publicinterfaceITestItem<T>{}publicinterfaceIStaticInterfaceBase<T,inTRequest>whereT:classwhereTRequest:IStaticInterfaceBase<T,TRequest>{staticabstractvoidTryInvoke<TItem>(TItemitem,TRequestrequest)whereTItem:ITestItem<T>;}publicinterfaceIStaticInterface<T,inTRequest>:IStaticInterfaceBase<T,TRequest>whereT:classwhereTRequest:IStaticInterface<T,TRequest>{staticvoidIStaticInterfaceBase<T,TRequest>.TryInvoke<TItem>(TItemitem,TRequestrequest){}}publicclassRequest:IStaticInterface<object,Request>{}internalclassProgram{publicstaticvoidInvoke<T,TRequest>(TRequestrequest)whereT:classwhereTRequest:IStaticInterfaceBase<T,TRequest>=>TRequest.TryInvoke((ITestItem<T>)null!,request);publicstaticvoidMain(string[]args)=>Invoke<object,Request>(newRequest());}Expected behavior
The code will run without error.
Actual behavior
Unhandled exception. System.Security.VerificationException: Method StaticInterfaceBug.IStaticInterface`2[System.Object,StaticInterfaceBug.Request].StaticInterfaceBug.IStaticInterfaceBase<T,TRequest>.TryInvoke: type argument 'TItem' violates the constraint of type parameter 'TItem'.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Description
I found code that throws a VerificationException for static virtual interface methods, and generic constraints, similar to this issue #73658 but without reflection.
Reproduction Steps
Run this code:
Expected behavior
The code will run without error.
Actual behavior
Unhandled exception. System.Security.VerificationException: Method StaticInterfaceBug.IStaticInterface`2[System.Object,StaticInterfaceBug.Request].StaticInterfaceBug.IStaticInterfaceBase<T,TRequest>.TryInvoke: type argument 'TItem' violates the constraint of type parameter 'TItem'.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response