[Mono-dev] Questions on Cecil

Bjarke Hammersholt Roune bjarke.roune at gmail.com
Sun Aug 27 19:05:31 EDT 2006


Hi,

I have some (more) questions related to Cecil.

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?

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).

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.

Regards
Bjarke Roune



More information about the Mono-devel-list mailing list