Open alexsanv opened 3 years ago
Hi @alexsanv , sorry for delay and thanks for your report! I'll take a look at it asap!
In any case it isn't always possible to hide parts of stacktrace, do you have any specific usecase where for example you parse stacktrace or is it just a matter of convenience?
@pamidur, this mostly is a matter of convenience. But there may be a valid use case, let me describe.
I implemented a helper library\nuget package for NUnit which uses aspect-injector to catch exceptions thrown in NUnit methods (e.g OneTimeSetup) wrapped around (Kind.Around) by aspect.
When you investigate a test failure, probably the first thing you look at is the exception's stacktrace. Having aspect-injector's autogenerated methods in exception's stacktrace in test failure may confuse people who are not familiar with the aspect-injector itself or don't even know that it is used in solution (directly or indirectly, as in my case with the library that uses aspect-injector).
Does this use case make any sense?
Yes, totally. What was done before - we mark our methods with the attributes that prevent those methods appear in the stacktrace in a debugger (read - visual studio)
To hide them completely we'll need other approach, wild guess - either process the stacktrace and hide frames or probably properly rethrowing exceptions might work as well. Or maybe there are some other attributes to try. Anyway it requires investigation
@jerviscui , yes it makes sense. With Kind.Exception it is up to user to decide how stack trace looks
Would it make sense to add StackTraceHiddenAttribute for auto-generated methods?
omg it exists :) but it seems like it is only for net6 and higher
AspectInjector supports all libs that can target netstandard2,0 and netstandard2,0 does not have StackTraceHiddenAttribute
though I believe we can add this attribute only if target assembly is net6
Probably this is a duplicate of #30, but I can reproduce this issue in 2.5.0
Stacktrace: