Skip to content

CommandLineApplication.ExecuteAsync is inherently synchronous #208

@rlvandaveer

Description

@rlvandaveer

Describe the bug
ExecuteAsync is not asynchronous. This seems related to bugs #153 and #196.

All of the ExecuteAsync methods eventually call the method below in CommandLineApplication.Execute.cs.

        public static Task<int> ExecuteAsync<TApp>(CommandLineContext context)
            where TApp : class
            => Task.FromResult(Execute<TApp>(context));

As you may well know, this method uses Task.FromResult to wrap a slew of synchronous calls in a task. This is inherently synchronous and effectively just deceives the consumer into thinking that their commands will execute asynchronously.

Expected behavior
Instead of wrapping synchronous code, the asynchronous execution should have its own separate async path.

I've logged this as a bug because the methods exist, but I realize that with the amount of work necessary to remediate, this is likely a feature request.

Metadata

Metadata

Assignees

Labels

enhancementhelp wantedWe would be willing to take a well-written PR to help fix this.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions