-
Notifications
You must be signed in to change notification settings - Fork 76
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
Crash on ref return #28
Comments
hi, yes I already discovered that PE Verify doesnt support newer c# language versions very well. So for now mark the test with an "PEVerifyNotSupported" attribute so we find them later more easy. |
I can mark the test with an attribute so that it can be easily revisited later, but I still have to ignore this particular PEVerify error for all tests, not just mine. This is because the weaved version of I just wanted to confirm that this is how I should proceed. |
can't you just use a flag which will be forwarded to the PEVerify step which will then be skipped? If it is possible I want to keep the pe verify for the others tests to be sure. |
I mean, I can skip PEVerify in my test, but the problem is that adding the needed method to the TestAssembly makes the TestAssembly unverifiable for all tests, no matter whether the weaver touched it or not. I could add a second test assembly that's not verified, but that feels contrived to me. Note that I wasn't proposing not verifying. I was proposing passing a flag in the PEVerify command line arguments that would cause it to ignore the error that it throws because of ref returns. |
…unverifiable code. Issue vescon#28
Ok, I added a PR that I think is probably the best way of handling it: leave the existing TestAssembly fully verified in all the tests that use it, but have a separate test assembly that contains unverifiable code, and ignore the errors it's known to produce only when verifying that assembly. Let me know if any problems with this approach. |
fixed by #34 |
ref return parameters were added in C# 7.0. However, weaving a method with such a return type causes a runtime exception when the OnExit handler attempts to access the MethodExecutionArgs's ReturnValue property.
That can be reproduced with this simple example:
In short, MBA does not properly convert the ref return type to a non-ref object before setting it as the ReturnValue property of the MethodExecutionArgs. I went to add a test for this so I could fix it, and I ran into a different but related issue. Specifically, PEVerify considers ref return types to be invalid, even the latest version of PEVerify from the .NET 4.7.2 sdk running against a simple assembly output by the compiler with no code weaver involved. As such, whenever I try to add a method to the unit test assembly that uses a ref return type, the test fails because PEVerify fails, even though the code actually runs just fine.
I was able to find no evidence of short-term plans by Microsoft to update the verifier to account for this new language feature, so the only way I can get it to work at the moment is by telling PEVerify to ignore this particular error. I have a fix ready to PR which would fix the issue above, but the only way I can get the tests to pass is by simply disabling that error. Should I submit it as is (with the error disabled) or do you want to try to find another way to handle these issues?
The text was updated successfully, but these errors were encountered: