What does prefix to MoveNext mean in the stackstace?
Asked Answered
J

3

21

The .NET application crashes with the stack trace:

Call Stack:

Layouts!Layouts.Ribbon.SizeAndPositionControlViewModel+OnLayoutSelectionChanged>d__5.MoveNext() 
mscorlib_ni!System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(System.Object)
WindowsBase_ni!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) 

The rest of the callstack is Windows code and does not matter.

Here's what the first call implies: In the async method OnLayoutSelectionChanged() in the instance of SizeAndPositionControlViewModel it failed in method MoveNext(). MoveNext() happens to be Microsoft code in a LINQ method method Any.

What does d__5 signify ?

Junko answered 10/1, 2014 at 19:42 Comment(1)
Linq creates temporary IEnumerable classes that evaluate the results. d__5.MoveNext is an iteration over the IEnumerable it created.Southwards
S
21

The d__5 portion is a prefix that is generated by the C# compiler to keep the construct unique from other generated members / types. In this case the d prefix means that it is an iterator or async method generated class (d is used for both). The number is just incremented for every name that is generated

Sestet answered 10/1, 2014 at 19:48 Comment(0)
K
0

These are the names of lambda expressions which where auto-generated by the compiler (also anonymous methods may look similar when debugging).

Karyn answered 10/1, 2014 at 19:49 Comment(0)
B
0

Several of the newer ways of creating returning IEnumerable objects are implemented in the compiler by defining and instantiating "anonymous" classes. The classes are actually required to have a name, so the compiler generates one like you are seeing. See e.g. this article for what is going on behind the scenes.

Baloney answered 11/1, 2014 at 0:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.