Skip to content

Demystifier shows async methods in AOP aspect #218

@deastr

Description

@deastr

I have a sample async console app with Aspect Oriented Programming logger, in this structure:

ConsoleApp
Project.Class.Method1
Project.Class.Method2

Call list is: ConsoleApp.Main -> Project.Class.Method1 -> Project.Class.Method2

All three of them are async.

This is the GetFrame list when observed by AOP logger while entering to Method2:

EnhancedStackTrace.Current().FrameCount
8
EnhancedStackTrace.Current().GetFrame(0).GetMethod().Name
"Method2"
EnhancedStackTrace.Current().GetFrame(1).GetMethod().Name
"MoveNext"
EnhancedStackTrace.Current().GetFrame(2).GetMethod().Name
"Start"
EnhancedStackTrace.Current().GetFrame(3).GetMethod().Name
"Method1"
EnhancedStackTrace.Current().GetFrame(4).GetMethod().Name
"MoveNext"
EnhancedStackTrace.Current().GetFrame(5).GetMethod().Name
"Start"
EnhancedStackTrace.Current().GetFrame(6).GetMethod().Name
"Main"
EnhancedStackTrace.Current().GetFrame(7).GetMethod().Name
"<Main>"

Interestingly .ToString() method shows somewhat different list:

 at Task Project2.Class1.Method2()
 at async Task Project2.Class1.Method1()
 at void System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<TStateMachine>(ref TStateMachine stateMachine)
 at Task Project2.Class1.Method1()
 at async Task Application.Program.Main(string[] args)
 at void System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<TStateMachine>(ref TStateMachine stateMachine)
 at Task Application.Program.Main(string[] args)
 at void Application.Program.<Main>(?)

I'm attaching sample project.

test.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions