@@ -35,8 +35,10 @@ bool IBuildActions.FileExists(string file)
3535 FileExistsIn . Add ( file ) ;
3636 if ( FileExists . TryGetValue ( file , out var ret ) )
3737 return ret ;
38+
3839 if ( FileExists . TryGetValue ( Path . GetFileName ( file ) , out ret ) )
3940 return ret ;
41+
4042 throw new ArgumentException ( "Missing FileExists " + file ) ;
4143 }
4244
@@ -51,28 +53,36 @@ int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory,
5153 {
5254 var pattern = cmd + " " + args ;
5355 RunProcessIn . Add ( pattern ) ;
54- if ( RunProcessOut . TryGetValue ( pattern , out var str ) )
55- stdOut = str . Split ( "\n " ) ;
56- else
56+
57+ if ( ! RunProcessOut . TryGetValue ( pattern , out var str ) )
5758 throw new ArgumentException ( "Missing RunProcessOut " + pattern ) ;
59+
60+ stdOut = str . Split ( "\n " ) ;
61+
5862 RunProcessWorkingDirectory . TryGetValue ( pattern , out var wd ) ;
63+
5964 if ( wd != workingDirectory )
6065 throw new ArgumentException ( "Missing RunProcessWorkingDirectory " + pattern ) ;
61- if ( RunProcess . TryGetValue ( pattern , out var ret ) )
62- return ret ;
63- throw new ArgumentException ( "Missing RunProcess " + pattern ) ;
66+
67+ if ( ! RunProcess . TryGetValue ( pattern , out var ret ) )
68+ throw new ArgumentException ( "Missing RunProcess " + pattern ) ;
69+
70+ return ret ;
6471 }
6572
6673 int IBuildActions . RunProcess ( string cmd , string args , string ? workingDirectory , IDictionary < string , string > ? env )
6774 {
6875 var pattern = cmd + " " + args ;
6976 RunProcessIn . Add ( pattern ) ;
7077 RunProcessWorkingDirectory . TryGetValue ( pattern , out var wd ) ;
78+
7179 if ( wd != workingDirectory )
7280 throw new ArgumentException ( "Missing RunProcessWorkingDirectory " + pattern ) ;
73- if ( RunProcess . TryGetValue ( pattern , out var ret ) )
74- return ret ;
75- throw new ArgumentException ( "Missing RunProcess " + pattern ) ;
81+
82+ if ( ! RunProcess . TryGetValue ( pattern , out var ret ) )
83+ throw new ArgumentException ( "Missing RunProcess " + pattern ) ;
84+
85+ return ret ;
7686 }
7787
7888 public readonly IList < string > DirectoryDeleteIn = new List < string > ( ) ;
@@ -86,18 +96,20 @@ void IBuildActions.DirectoryDelete(string dir, bool recursive)
8696
8797 bool IBuildActions . DirectoryExists ( string dir )
8898 {
89- if ( DirectoryExists . TryGetValue ( dir , out var ret ) )
90- return ret ;
91- throw new ArgumentException ( "Missing DirectoryExists " + dir ) ;
99+ if ( ! DirectoryExists . TryGetValue ( dir , out var ret ) )
100+ throw new ArgumentException ( "Missing DirectoryExists " + dir ) ;
101+
102+ return ret ;
92103 }
93104
94105 public readonly IDictionary < string , string ? > GetEnvironmentVariable = new Dictionary < string , string ? > ( ) ;
95106
96107 string ? IBuildActions . GetEnvironmentVariable ( string name )
97108 {
98- if ( GetEnvironmentVariable . TryGetValue ( name , out var ret ) )
99- return ret ;
100- throw new ArgumentException ( "Missing GetEnvironmentVariable " + name ) ;
109+ if ( ! GetEnvironmentVariable . TryGetValue ( name , out var ret ) )
110+ throw new ArgumentException ( "Missing GetEnvironmentVariable " + name ) ;
111+
112+ return ret ;
101113 }
102114
103115 public string GetCurrentDirectory = "" ;
@@ -111,18 +123,22 @@ string IBuildActions.GetCurrentDirectory()
111123
112124 IEnumerable < string > IBuildActions . EnumerateFiles ( string dir )
113125 {
114- if ( EnumerateFiles . TryGetValue ( dir , out var str ) )
115- return str . Split ( "\n " ) . Select ( p => PathCombine ( dir , p ) ) ;
116- throw new ArgumentException ( "Missing EnumerateFiles " + dir ) ;
126+ if ( ! EnumerateFiles . TryGetValue ( dir , out var str ) )
127+ throw new ArgumentException ( "Missing EnumerateFiles " + dir ) ;
128+
129+ return str . Split ( "\n " ) . Select ( p => PathCombine ( dir , p ) ) ;
117130 }
118131
119132 public readonly IDictionary < string , string > EnumerateDirectories = new Dictionary < string , string > ( ) ;
120133
121134 IEnumerable < string > IBuildActions . EnumerateDirectories ( string dir )
122135 {
123- if ( EnumerateDirectories . TryGetValue ( dir , out var str ) )
124- return string . IsNullOrEmpty ( str ) ? Enumerable . Empty < string > ( ) : str . Split ( "\n " ) . Select ( p => PathCombine ( dir , p ) ) ;
125- throw new ArgumentException ( "Missing EnumerateDirectories " + dir ) ;
136+ if ( ! EnumerateDirectories . TryGetValue ( dir , out var str ) )
137+ throw new ArgumentException ( "Missing EnumerateDirectories " + dir ) ;
138+
139+ return string . IsNullOrEmpty ( str )
140+ ? Enumerable . Empty < string > ( )
141+ : str . Split ( "\n " ) . Select ( p => PathCombine ( dir , p ) ) ;
126142 }
127143
128144 public bool IsWindows ;
@@ -152,15 +168,16 @@ void IBuildActions.WriteAllText(string filename, string contents)
152168
153169 XmlDocument IBuildActions . LoadXml ( string filename )
154170 {
155- if ( LoadXml . TryGetValue ( filename , out var xml ) )
156- return xml ;
157- throw new ArgumentException ( "Missing LoadXml " + filename ) ;
171+ if ( ! LoadXml . TryGetValue ( filename , out var xml ) )
172+ throw new ArgumentException ( "Missing LoadXml " + filename ) ;
173+ return xml ;
158174 }
159175
160176 public string EnvironmentExpandEnvironmentVariables ( string s )
161177 {
162178 foreach ( var kvp in GetEnvironmentVariable )
163179 s = s . Replace ( $ "%{ kvp . Key } %", kvp . Value ) ;
180+
164181 return s ;
165182 }
166183
0 commit comments