88
99namespace SmartCmdArgs . Services
1010{
11+ public enum UpdateProjectConfigReason { RunDebugLaunch , TreeChange , UseVirtualProfileChanged }
1112 public interface IProjectConfigService
1213 {
1314 bool IsSupportedProject ( IVsHierarchyWrapper project ) ;
1415
1516 List < CmdItemJson > GetItemsFromProjectConfig ( IVsHierarchyWrapper project ) ;
1617
17- void UpdateProjectConfig ( IVsHierarchyWrapper project ) ;
18+ void UpdateProjectConfig ( IVsHierarchyWrapper project , UpdateProjectConfigReason reason ) ;
19+
20+
1821 }
1922
2023 public class ProjectConfigService : IProjectConfigService
@@ -48,7 +51,7 @@ public ProjectConfigService(
4851
4952 private class ProjectConfigHandlers
5053 {
51- public delegate void SetConfigDelegate ( EnvDTE . Project project , string arguments , IDictionary < string , string > envVars , string workDir , string launchApp ) ;
54+ public delegate void SetConfigDelegate ( EnvDTE . Project project , string arguments , IDictionary < string , string > envVars , string workDir , string launchApp , UpdateProjectConfigReason reason ) ;
5255 public delegate void GetAllArgumentsDelegate ( EnvDTE . Project project , List < CmdItemJson > allArgs , bool includeArgs , bool includeEnvVars , bool includeWorkDir , bool includeLaunchApp ) ;
5356 public SetConfigDelegate SetConfig ;
5457 public GetAllArgumentsDelegate GetItemsFromConfig ;
@@ -59,7 +62,7 @@ private Dictionary<Guid, ProjectConfigHandlers> InitConfigHandlerForSupportedPro
5962 {
6063 // C#
6164 { ProjectKinds . CS , new ProjectConfigHandlers ( ) {
62- SetConfig = ( project , arguments , envVars , workDir , launchApp ) => {
65+ SetConfig = ( project , arguments , envVars , workDir , launchApp , reason ) => {
6366 SetMultiConfigProperty ( project , arguments , "StartArguments" ) ;
6467 SetMultiConfigProperty ( project , workDir , "StartWorkingDirectory" ) ;
6568 SetMultiConfigProperty ( project , launchApp , "StartProgram" ) ;
@@ -68,13 +71,13 @@ private Dictionary<Guid, ProjectConfigHandlers> InitConfigHandlerForSupportedPro
6871 } } ,
6972 // C# UWP
7073 { ProjectKinds . CS_UWP , new ProjectConfigHandlers ( ) {
71- SetConfig = ( project , arguments , envVars , workDir , launchApp ) => SetMultiConfigProperty ( project , arguments , "UAPDebug.CommandLineArguments" ) ,
74+ SetConfig = ( project , arguments , envVars , workDir , launchApp , reason ) => SetMultiConfigProperty ( project , arguments , "UAPDebug.CommandLineArguments" ) ,
7275 GetItemsFromConfig = GetItemsFromMultiConfig ( "UAPDebug.CommandLineArguments" )
7376 } } ,
7477
7578 // VB.NET
7679 { ProjectKinds . VB , new ProjectConfigHandlers ( ) {
77- SetConfig = ( project , arguments , _ , workDir , launchApp ) => {
80+ SetConfig = ( project , arguments , _ , workDir , launchApp , reason ) => {
7881 SetMultiConfigProperty ( project , arguments , "StartArguments" ) ;
7982 SetMultiConfigProperty ( project , workDir , "StartWorkingDirectory" ) ;
8083 SetMultiConfigProperty ( project , launchApp , "StartProgram" ) ;
@@ -88,7 +91,7 @@ private Dictionary<Guid, ProjectConfigHandlers> InitConfigHandlerForSupportedPro
8891 } } ,
8992 // Python
9093 { ProjectKinds . Py , new ProjectConfigHandlers ( ) {
91- SetConfig = ( project , arguments , envVars , workDir , _ ) => {
94+ SetConfig = ( project , arguments , envVars , workDir , _ , reason ) => {
9295 SetSingleConfigProperty ( project , arguments , "CommandLineArguments" ) ;
9396 SetSingleConfigEnvVars ( project , envVars , "Environment" ) ;
9497 SetSingleConfigProperty ( project , workDir , "WorkingDirectory" ) ;
@@ -97,7 +100,7 @@ private Dictionary<Guid, ProjectConfigHandlers> InitConfigHandlerForSupportedPro
97100 } } ,
98101 // Node.js
99102 { ProjectKinds . Node , new ProjectConfigHandlers ( ) {
100- SetConfig = ( project , arguments , envVars , workDir , _ ) => {
103+ SetConfig = ( project , arguments , envVars , workDir , _ , reason ) => {
101104 SetSingleConfigProperty ( project , arguments , "ScriptArguments" ) ;
102105 SetSingleConfigEnvVars ( project , envVars , "Environment" ) ;
103106 SetSingleConfigProperty ( project , workDir , "WorkingDirectory" ) ;
@@ -111,7 +114,7 @@ private Dictionary<Guid, ProjectConfigHandlers> InitConfigHandlerForSupportedPro
111114 } } ,
112115 // F#
113116 { ProjectKinds . FS , new ProjectConfigHandlers ( ) {
114- SetConfig = ( project , arguments , _ , workDir , launchApp ) => {
117+ SetConfig = ( project , arguments , _ , workDir , launchApp , reason ) => {
115118 SetMultiConfigProperty ( project , arguments , "StartArguments" ) ;
116119 SetMultiConfigProperty ( project , workDir , "StartWorkingDirectory" ) ;
117120 SetMultiConfigProperty ( project , launchApp , "StartProgram" ) ;
@@ -377,7 +380,7 @@ private static ProjectConfigHandlers.GetAllArgumentsDelegate GetItemsFromMultiCo
377380 ( "AppHostLocalDebugger" , "CommandLineArgs" , null , null , null ) ,
378381 } ;
379382
380- private static void SetVCProjEngineConfig ( EnvDTE . Project project , string arguments , IDictionary < string , string > envVars , string workDir , string launchApp )
383+ private static void SetVCProjEngineConfig ( EnvDTE . Project project , string arguments , IDictionary < string , string > envVars , string workDir , string launchApp , UpdateProjectConfigReason reason )
381384 {
382385 ThreadHelper . ThrowIfNotOnUIThread ( ) ;
383386
@@ -591,7 +594,7 @@ private static string VFFormatConfigName(EnvDTE.Configuration vcCfg)
591594 // to optain the right configurations object from `Project.Object.Configurations`
592595 // this object is simmilar to the VCProjEngine configuration and has `DebugSettings`
593596 // which contain the CommandArguments which we can use to set the args.
594- private static void SetVFProjEngineConfig ( EnvDTE . Project project , string arguments , IDictionary < string , string > envVars , string workDir , string launchApp )
597+ private static void SetVFProjEngineConfig ( EnvDTE . Project project , string arguments , IDictionary < string , string > envVars , string workDir , string launchApp , UpdateProjectConfigReason reason )
595598 {
596599 ThreadHelper . ThrowIfNotOnUIThread ( ) ;
597600
@@ -773,7 +776,7 @@ public List<CmdItemJson> GetItemsFromProjectConfig(IVsHierarchyWrapper project)
773776 return result ;
774777 }
775778
776- public void UpdateProjectConfig ( IVsHierarchyWrapper project )
779+ public void UpdateProjectConfig ( IVsHierarchyWrapper project , UpdateProjectConfigReason reason )
777780 {
778781 if ( ! lifeCycleService . Value . IsEnabled || project == null )
779782 return ;
@@ -788,10 +791,11 @@ public void UpdateProjectConfig(IVsHierarchyWrapper project)
788791
789792 if ( TryGetProjectConfigHandlers ( project , out ProjectConfigHandlers handler ) )
790793 {
791- handler . SetConfig ( project . GetProject ( ) , commandLineArgs , envVars , workDir , launchApp ) ;
794+ handler . SetConfig ( project . GetProject ( ) , commandLineArgs , envVars , workDir , launchApp , reason ) ;
795+
792796 }
793797
794- Logger . Info ( $ "Updated Configuration for Project: { project . GetName ( ) } ") ;
798+ Logger . Info ( $ "Updated Configuration for Project: { project . GetName ( ) } command line: { commandLineArgs } ") ;
795799 }
796800 }
797801
0 commit comments