This is a convenient feature in some cases. For example:
public static T RequireComponent<T>(this Component comp) where T : Component {
T result = comp.GetComponent<T>();
if(result == null) Debug.LogErrorFormat( comp, "Object '{0}' hasn't component '{1}'", comp.gameObject.name, typeof( T ).Name ); // I want callstack points to my RequireComponent instead of LogErrorFormat.
return result;
}
Will it work in new Mono?
And second question.
Now when I’m getting NullReferenceException I can’t see name of reference.
It is very inconvenient and time-consuming.
So, will it work?
NullReferenceException: Object reference not set to an instance of an object MyScript.Awake () (at Assets/MyScript:10) … Where is name ‘myVar’ of null reference? if I have code: csharp* *if( ref1.ref2.ref3.num == 0 ) ref4.ref5.ref6.num = 1;* * It is difficult to understand what the reference was null.
Ahh, ok. This is not a new bug then. Thinking more about this, I’m not sure there is much more we can do here. The name of the variable in C# code is probably not available to the runtime.
For the DebuggerHidden attribute, it looks like something we probably can support. We’re getting the managed debugger working with the Mono preview build now, so we will try this.
It would be really nice to see the DebuggerHidden attribute supported! Especially for generated code I don’t want to step through all that generated code when debugging. This could also hide stuff in the stacktrace of the console view in Unity. So we don’t always see UnityEngine.Debug:Log(Object) in the stacktrace. There are already options to show different detail of stacktraces for the console view. So add another one to hide/unhide DebuggerHidden methods.
Yes, sorry, we’ve not made any progress on supporting this attribute yet. It it still something I would like to support, but I’m not sure when we will get it.
Ahhhh, You are killing me !
How about the possibility of intercepting the console’s double click? I am looking and looking an can’t find anything.
Is the only solution to write a console from scratch?
All I want if for my logs to go to the right place WITH OUT using a .dll . I did get the working.
I also would no mind adding the ability to click anywhere in the stack !
Please Unity, add DebuggerHidden to skip over wrapper methods when stepping through code and also in log stack traces.
There’s really no replacement for the builtin console. I’ve tried the major store plugins but none is good enough for something so essential. Also, rerouting logs in Unity is too much overhead and causes performance issues when I implement my own console window. So, this attribute feature seems like a really good cost-benefit.
Even if you have a replacement console, the actual log file will still be polluted.
I have a relatively simple logging framework and it bothers me deeply when I have to read polluted log files. I end having to cleanup the files with sed before I can read them easily.
In editor I use EditorConsole Pro and ignore a bunch of stuff. Previously, I was hot-patching the ExtractFormattedStackTrace method, and I had full control over what to ignore. But it now has a hot path that is on the unmanaged side, so I can’t readily patch it anymore.
I don’t have any solution currently, sadly. If any of you have any idea on how we could improve this, I’m interested!
This issue to simply “remove the first log in a stack trace to ignore custom wrapper for Debug.Log” was brought up back in 2016.
It is now 2021, Unity still isn’t even close to implementing it. It’s under consideration in their roadmap. We still have to constantly face this annoyance of double clicking a custom wrapped log only to navigate back to console and click second stack trace line. For my own custom solution a dll isn’t an option because I do some stuff with custom enums that’ll expand over time.
@Everyone reading this, PLEASE DO THE FOLLOWING TO GET UNITY’S ATTENTION: