Comments
5 comments
-
Hi.
How are you looking at the ExceptionHandlers collection?
For your particular example, if I put a breakpoint on the method that writes the IL body of a method, I see that the exception handlers count is 1.
((IMethodBody)value.Body).ExceptionHandlers.Count
0x00000001
This is how the .try is being generated by Reflector in the disassembly, so if there were no exception handlers in the collection, there wouldn't be a .try line in the disassembly. In your example, when Reflector shows you the disassembly, is there a .try line present? If not, could you please email me the example assembly at clive DOT tong AT red HYPHEN gate DOT com
Thanks -
This code comes from my add-in - you can get the code from here:
http://exfinderreflector.codeplex.com/
Right now, 330 of 339 tests are passing (I'm not including AnalyzeAllMscorlibMethods). All of the tests used to pass before 6.x. It seems to be because the count of exception handlers isn't coming out the way I'm expecting them too.
Regards,
Jason -
Thanks - I'll take a look.
-
I think this is due to some places in your addin where you are passing around the wrong representation of the instructions. There appear to be two representatios - one as the standard IL instruction stream and another containing the results of MapWithHandlerInstructions, which returns instances of several classes to represent the boundaries of Try/Catch/Finally/Fault. There are a couple of places in the code where the latter form is expected, but the former is provided; this means that several type tests (using as) fail to get triggered and analysis fails.
I "fixed" some code in the OnAnalyze method of LeakedExceptionsCatchBlockInstructionAnalyzer and the LeakedExceptionsTryBlockInstructionsAnalyzer to use the second form, and now I get 340/340 tests passing.
I hope that helps. I can email you the changes I made if that would help you, if you send me your address to clive DOT tong AT red HYPHEN gate DOT com. -
Thanks for looking at this. I'd like to look at your changes - send them over to jason AT jasonbock DOT net.
Add comment
Please sign in to leave a comment.
.method public hidebysig newslot virtual instance void TryWithNoExceptionAndFaultWithException() cil managed
{
.maxstack 2
L_0000: leave L_000c
L_0005: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
L_000a: throw
L_000b: endfinally
L_000c: ret
.try L_0000 to L_0005 fault handler L_0005 to L_000c
}
When I look at this method's ExceptionHandlers, the count is 0. This is different than what happened when I was using Reflector pre-6.0 (and before .NET 4.0).
I'm not sure what's exactly changed, but I would expect that there should be one handler present in the collection. Is this correct?