@@ -24,8 +24,7 @@ public static void MaxInstancesToLaunch(int value)
2424 /// </summary>
2525 public static void Kill ( string tempFile , string targetFile )
2626 {
27- Guard . AgainstNullOrEmpty ( tempFile , nameof ( tempFile ) ) ;
28- Guard . AgainstNullOrEmpty ( targetFile , nameof ( targetFile ) ) ;
27+ GuardFiles ( tempFile , targetFile ) ;
2928 var extension = Extensions . GetExtension ( tempFile ) ;
3029 if ( ! DiffTools . TryFind ( extension , out var diffTool ) )
3130 {
@@ -44,8 +43,7 @@ public static void Kill(string tempFile, string targetFile)
4443
4544 public static LaunchResult Launch ( DiffTool tool , string tempFile , string targetFile )
4645 {
47- Guard . FileExists ( tempFile , nameof ( tempFile ) ) ;
48- Guard . AgainstNullOrEmpty ( targetFile , nameof ( targetFile ) ) ;
46+ GuardFiles ( tempFile , targetFile ) ;
4947 var extension = Extensions . GetExtension ( tempFile ) ;
5048 if ( ! DiffTools . TryFind ( tool , extension , out var resolvedTool ) )
5149 {
@@ -60,8 +58,7 @@ public static LaunchResult Launch(DiffTool tool, string tempFile, string targetF
6058 /// </summary>
6159 public static LaunchResult Launch ( string tempFile , string targetFile )
6260 {
63- Guard . FileExists ( tempFile , nameof ( tempFile ) ) ;
64- Guard . AgainstNullOrEmpty ( targetFile , nameof ( targetFile ) ) ;
61+ GuardFiles ( tempFile , targetFile ) ;
6562 var extension = Extensions . GetExtension ( tempFile ) ;
6663
6764 if ( ! DiffTools . TryFind ( extension , out var diffTool ) )
@@ -74,7 +71,7 @@ public static LaunchResult Launch(string tempFile, string targetFile)
7471
7572 static LaunchResult Launch ( ResolvedDiffTool diffTool , string tempFile , string targetFile )
7673 {
77- if ( launchedInstances >= maxInstancesToLaunch )
74+ if ( CheckInstanceCount ( ) )
7875 {
7976 return LaunchResult . TooManyRunningDiffTools ;
8077 }
@@ -88,6 +85,11 @@ static LaunchResult Launch(ResolvedDiffTool diffTool, string tempFile, string ta
8885 }
8986 }
9087
88+ return InnerLaunch ( diffTool , tempFile , targetFile ) ;
89+ }
90+
91+ static LaunchResult InnerLaunch ( ResolvedDiffTool diffTool , string tempFile , string targetFile )
92+ {
9193 launchedInstances ++ ;
9294
9395 var command = diffTool . BuildCommand ( tempFile , targetFile ) ;
@@ -119,5 +121,15 @@ static LaunchResult Launch(ResolvedDiffTool diffTool, string tempFile, string ta
119121 }
120122 }
121123
124+ static void GuardFiles ( string tempFile , string targetFile )
125+ {
126+ Guard . FileExists ( tempFile , nameof ( tempFile ) ) ;
127+ Guard . AgainstNullOrEmpty ( targetFile , nameof ( targetFile ) ) ;
128+ }
129+
130+ static bool CheckInstanceCount ( )
131+ {
132+ return launchedInstances >= maxInstancesToLaunch ;
133+ }
122134 }
123135}
0 commit comments