VsixCommunity / Community.VisualStudio.Toolkit.DependencyInjection

Adds Dependency Injection tooling for the Community.VisualStudio.Toolkit
Other
14 stars 7 forks source link

Redundant code #12

Open tonyhallett opened 10 months ago

tonyhallett commented 10 months ago

https://github.com/VsixCommunity/Community.VisualStudio.Toolkit.DependencyInjection/blob/639e8340345a0d528670b70f7817af662d64c01a/src/Core/Shared/CommandWrapper.cs#L62

        protected async Task ExecuteAsync(OleMenuCmdEventArgs e)
        {
            using var scope = this._serviceProvider.CreateScope();
            BaseDICommand instance = (BaseDICommand)scope.ServiceProvider.GetRequiredService(typeof(T));
            Task executeAsyncTask = (Task)_executeAsyncMethod.Invoke(instance, new object[] { e });
            await executeAsyncTask;
        }

The OleMenuCommand will Invoke the CommandWapper Execute method. This will invoke the BaseCommand Execute which will invoke the BaseCommand ExecuteAsync if not overridden.