Skip to content

Conversation

FreeAndNil
Copy link
Contributor

fixes #244

@FreeAndNil FreeAndNil added this to the 3.1.1 milestone May 19, 2025
@FreeAndNil FreeAndNil changed the title #244 fix InvalidCastException in ThreadContextStack.InternalStack.set #246 fix InvalidCastException in ThreadContextStack.InternalStack.set May 19, 2025
@FreeAndNil FreeAndNil force-pushed the Feature/#244-fix-InvalidCastException-in-ThreadContextStack.InternalStack.set branch from 25b27ed to a65c1d5 Compare May 19, 2025 15:15
for (int i = frames.Length - 1; i >= 0; i--)
{
_stack.Push(frames[i]);
_stack.Push(frames[i].EnsureIs<StackFrame>());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: I'd suggest rather using pettern-matching instead of throwing if something in that array is wrong, eg

if (frames[i] is StackFrame s)
{
  _stack.Push(s)
}

This would stop a throw on invalid data set, but leave the collection empty, which may not be better - this may just be a stylistic choice on my part.

@FreeAndNil FreeAndNil merged commit 50738b0 into master May 22, 2025
3 checks passed
@FreeAndNil FreeAndNil deleted the Feature/#244-fix-InvalidCastException-in-ThreadContextStack.InternalStack.set branch May 22, 2025 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v3.1.0 - Exception with RollingFileAppender when files are already present
2 participants