I'm reading some crash reports from a UWP application (C#, compiled with .NET Native) and I'm having a hard time understanding the exact syntax/format used in the stack traces. I tried looking for some guides on the internet but I didn't come up with anything useful.
Here are a few examples:
1)
MyProject.ViewModels.SomeViewModel.<OnLogin>d__69.MoveNext()
OnLogin
is the name of a method inSomeViewModel
, so why is it inside angular brackets? Is the"ClassName".<"MethodName>..."
the usual way to indicate an instance method?- I understand that the C# compiler turns every chunk of code between
await
calls into anonymous methods and schedules them using continuations, so I guess thatd__69
indicates an async continuation inside the current method.- What does the 'd' stand for?
- Are those numbers random? I mean, the method doesn't have 69
await
calls, so I guess those numbers aren't sequential. Is it possible to find out the exact part in the original method from that number in the stack trace?
- What is that
MoveNext()
method at the end? What kind of type is it called upon?
2)
MyProject.UserControls.SomeControl.<.ctor>b__0_0
- I know that
.ctor
stands for the object constructor, and looking at the code I found out thatb__0_0
stands for an anonymous event handler added inside the constructor, like this:SomeEvent += (s, e) => Foo();
.- What does the 'b' stand for?
- Why are there two numbers with an underscore? Which one of them refers to the anonymous method index? I mean, it's the first one (so its index is 0) but there are two 0s here. If it was the second, would I have had
0_1
,1_0
or something else?
3) I have this method:
// Returns a Task that immediately throws when awaited, as soon as the token is cancelled
public static Task<T> GetWatchedTask<T>(this Task<T> awaitableTask, CancellationToken token)
{
return awaitableTask.ContinueWith(task => task.GetAwaiter().GetResult(), token);
}
And I have this stack trace:
MyProject.Helpers.Extensions.TasksExtensions.<>c__3$1<System.__Canon>.<GetWatchedTask>b__3_0($Task$1<__Canon> task)
- Why doesn't the second parameter (the token) show up in the signature?
- Why is the type
$Task$1
written with the '$' character? Is it like some sort of placeholder/ground indicator (like in a regex) so that it can be used in other places too? (I mean, I see that$1<System.__Canon>
in what I guess is the method return type)- If that first part is the method return type, why isn't it there for all the methods that have a return type? I have lots of stack traces with method that do return a value, but they don't have that same signature.
- What does all that
.<>c__3$1<System.__Canon>
mean? From the$1
and on I guess that'd be theTask<T>
return type, but what's thatb__3_0
part, since I don't have async calls or event handlers? Does that mean something different in this case?
4)
Windows.UI.Xaml.Media.SolidColorBrush..ctor($Color color)
- Why does the parameter type start with the '$' character? What does it stand for?
5) I have this other method:
public static async Task<ObservableCollection<SomeCustomClass>> LoadItemGroups(String parentId)
And this stack trace:
MyProject.SQLiteDatabase.SQLiteManager.<>c__DisplayClass142_3.<LoadGroups>b__3()
- What's that
c__DisplayClass142_3
? Is that a way to indicate the return type with a single type rather than the three separate classes (Task, ObservableCollection, SomeCustomClass)? - Again, why do I have
b__3
here, where in other stack traces it used the formatd_xxx
to indicate an async code chunk?
Sorry for the many questions, I hope this post will help other UWP C# programmers too.
Thank you in advance for your help!
EDIT: this question should not be considered a duplicate of this other questions because:
- It presents different cases (constructor methods, generic types syntax etc..) instead of just asking for the meaning of some default keywords/symbols related to a certain type of variables
- It specifically asks how to compare a given stack trace to an original method signature, and the steps to do in order to achieve that
- It presents different examples in different contexts, instead of just asking a general question
- And by the way, how can "VS debugger magic names" even be considered a proper question title? How was another user supposed to find that question when looking for C# stack traces symbols meaning?