You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
new Exception().StackTrace is an incorrect translation from Java. We should find all calls to Exception.StackTrace as well as the StackTrace class and convert them correctly. From ChatGPT:
In Java, the code new Exception().getStackTrace() creates a new instance of the Exception class, and then calls the getStackTrace() method on that instance to obtain an array of StackTraceElement objects. Each element in the array represents a stack trace element, providing information about the call stack at the point where the exception was created.
This code prints out the class name, method name, and line number for each element in the stack trace.
In C#, the equivalent code would use the StackTrace class from the System.Diagnostics namespace. Here's an example:
using System;using System.Diagnostics;classProgram{staticvoidMain(){StackTracetrace=new StackTrace();
StackFrame[]frames= trace.GetFrames();foreach(StackFrame frame in frames){
Console.WriteLine($"{frame.GetMethod().DeclaringType} - {frame.GetMethod().Name} - {frame.GetFileLineNumber()}");}}}
This C# code creates a new StackTrace instance and then uses the GetFrames() method to obtain an array of StackFrame objects. Similar to the Java example, it prints out the declaring type, method name, and line number for each frame in the stack trace.
We have a class called StackTraceHelper that we could add the support to convert it to a string. There are also several calls to .printStackTace() that should be reviewed. In .NET, Exception.StackTrace doesn't contain the exception type, so a lot of the tests use Exception.ToString() instead. But we would be better off with a centralized way of dealing with stack traces (in Support) - StackTraceHelper only applies to the test code, but there is code in production that is also not correctly translated. Of course, since it is something we own, moving it to Support is an option.
In short, we want to review all of the code that was using .getStackTrace() or .printStackTrace() in Lucene.
new Exception().StackTrace
is an incorrect translation from Java. We should find all calls toException.StackTrace
as well as theStackTrace
class and convert them correctly. From ChatGPT:We have a class called
StackTraceHelper
that we could add the support to convert it to a string. There are also several calls to.printStackTace()
that should be reviewed. In .NET,Exception.StackTrace
doesn't contain the exception type, so a lot of the tests useException.ToString()
instead. But we would be better off with a centralized way of dealing with stack traces (in Support) -StackTraceHelper
only applies to the test code, but there is code in production that is also not correctly translated. Of course, since it is something we own, moving it to Support is an option.In short, we want to review all of the code that was using
.getStackTrace()
or.printStackTrace()
in Lucene.Originally posted by @NightOwl888 in #926 (comment)
The text was updated successfully, but these errors were encountered: