PostSharp OnException on mscorlib(ignore exception) - What are the dangers?

64 Views Asked by At

I was thinking if one could make an exception free app(not really, but one with minimal exception throwing)

Lets say i apply my aspect with the OnException method to everything inside mscorlib(sounds like a bad idea).

This can lead to stackoverflow exceptions in some case but they can be prevented with ThreadStatic tag and a boolean.

What i am asking is although this sounds good in paper, what problems i might face in the future which could doom this concept?

1

There are 1 best solutions below

0
On

From PostSharp point of view this use case is not supported, i.e. we do not regularly run tests with aspects targeting everything in mscorlib. It means we cannot guarantee everything will always work as you expect. For example, some of the exceptions might not be caught and you will find out only later in production environment.

Also, by applying the aspect in this way, you will end up with many try-catch blocks in each method wrapping every call to mscorlib. This is just less optimal then having one or a few catch blocks per method.

Overall, this approach looks suspicious and doesn't represent the usual purpose of using PostSharp in a project. It would be cleaner to apply the exception aspect to your own methods instead of mscorlib.