fluffynuts commented on code in PR #246:
URL: https://github.com/apache/logging-log4net/pull/246#discussion_r2101974038


##########
src/log4net/Util/ThreadContextStack.cs:
##########
@@ -188,10 +188,10 @@ internal Stack InternalStack
     set
     {
       _stack.Clear();
-      var frames = (StackFrame[])value.ToArray();
+      object[] frames = value.ToArray();
       for (int i = frames.Length - 1; i >= 0; i--)
       {
-        _stack.Push(frames[i]);
+        _stack.Push(frames[i].EnsureIs<StackFrame>());

Review Comment:
   minor: I'd suggest rather using pettern-matching instead of throwing if 
something in that array is wrong, eg
   
   ```csharp
   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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to