[Mono-dev] Questions on Cecil

Jb Evain mono at evain.net
Mon Aug 28 03:41:14 EDT 2006


Hi,

Bjarke Hammersholt Roune wrote:
> 1. Suppose I can make Cecil throw an exception from somewhere deep down 
> in its core. An example would be setting a public field to null and then 
> getting a NullReferenceException when some internal Cecil method tries 
> to call methods on that pointer. Is that then a Cecil bug that I should 
> report or is it intended behavior? I.e., does Cecil guarantee good 
> behavior in the face of it being used inappropriately?

While it does not yet, it should. Please use bugzilla, component 
Mono.Cecil to reports this kind of bugs. They'll be assigned to me, and 
I'll be notified.

> 2. How do I get Cecil to tell me the difference between the following 
> two C# methods (currently my program turns the first into the second).

It is not the responsibility of Cecil to analyze the CIL stream and to 
tell you that a method have the same behavior of another one.

> void method1() { // this method prints 13
> 	try {
> 		try {
> 			throw new System.NullReferenceException ()
> 		} catch (System.Exception)
> 			System.Console.WriteLine("1");
> 			throw;
> 		} catch {
> 			System.Console.WriteLine("2");
> 		}
> 	} catch {
> 		System.Console.WriteLine("3");
> 	}
> }
> 
> void method2() { // this methods prints 12
> 	try {
> 		try {
> 			try {
> 				throw new System.NullReferenceException
> ()
> 			} catch (System.Exception)
> 				System.Console.WriteLine("1");
> 				throw;
> 			}
> 		} catch {
> 			System.Console.WriteLine("2");
> 		}
> 	} catch {
> 		System.Console.WriteLine("3");
> 	}
> }
> 
> Actually, I looked at the ECMA spec, and I can't find anything in there 
> that explains how something like the situation in method1 can even be 
> represented. E.g. the explanation of the rethrow bytecode is silent on 
> the matter. So are the explanations related to exceptions that I have 
> been able to find in the spec, or perhaps I am misreading them.

I don't get what the problem is here. Both methods will have 3 
exceptions handlers, but their try start, try end will be different. And 
that's enough to see which handlers contains the others.

Jb




More information about the Mono-devel-list mailing list