-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Ignore type resolution failures when checking for attributes in StackTrace.ToString.
#104530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore type resolution failures when checking for attributes in StackTrace.ToString.
#104530
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-reflection |
|
I do not think we want to be catching exceptions in reflection to make it resilient against missing assemblies. It is very fragile path. For example, this fix would make unsealing an attribute potentially breaking change going forward. #104528 should be fixed by ignoring reflection failures in the stacktrace printing code. |
StackTrace.ToString.
3386509 to
6d27738
Compare
…m throwing. An `IsDefinedSafe` method was added that returns false if checking for the attribute throws, and other usages in the file were updated as well. This also allows us to remove a big try catch block.
6d27738 to
2afa59f
Compare
Didn't think about this, thanks! I updated the PR as you suggested, and guarded another possible source of resolver failures. |
|
Build breaks... |
|
Fixed build failures. Current CI failures are seemingly unrelated. |
jkotas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks
Fixes #104528.
Similar to #48535, this PR makes
StackTrace.ToStringresilient to exceptions when performing some more custom attribute retrieving. We do this by introducing***Safeedition of reflection methods that perform the operation and return a negative result if an exception was thrown, and updating all uses ofIsDefinedandGetCustomAttributesin theStackTraceclass.