@@ -67,7 +67,7 @@ public static void Generate(string rootDir, Quantity[] quantities, QuantityNameT
67
67
new Regex ( @"<version>(?<version>[\d.]+)(?<suffix>-[a-z\d]+)?<\/version>" , RegexOptions . IgnoreCase ) ,
68
68
"projectVersion" ) ;
69
69
70
- foreach ( var quantity in quantities )
70
+ foreach ( Quantity quantity in quantities )
71
71
{
72
72
var projectPath = Path . Combine ( outputDir , quantity . Name ) ;
73
73
Directory . CreateDirectory ( projectPath ) ;
@@ -95,7 +95,6 @@ public static void Generate(string rootDir, Quantity[] quantities, QuantityNameT
95
95
{
96
96
var replacements = new Dictionary < string , string >
97
97
{
98
- //{ "(\\)sdecimal(\\s)", "$1float$2" }
99
98
{ "(\\ d)m" , "$1d" } ,
100
99
{ "(\\ d)M" , "$1d" } ,
101
100
{ " decimal " , " double " } ,
@@ -119,22 +118,22 @@ public static void Generate(string rootDir, Quantity[] quantities, QuantityNameT
119
118
}
120
119
121
120
/// <summary>
122
- /// Updates existing nanoFramework projects and nuspecs with the latest versions.
121
+ /// Updates existing nanoFramework projects and nuspec files with the latest versions.
123
122
/// </summary>
124
123
/// <param name="rootDir">The root directory</param>
125
- /// <param name="quantities">The quantities to update nuspecs </param>
124
+ /// <param name="quantities">The quantities to update nuspec files </param>
126
125
public static bool UpdateNanoFrameworkDependencies (
127
126
string rootDir ,
128
127
Quantity [ ] quantities )
129
128
{
130
129
// working path
131
- string path = Path . Combine ( rootDir , "UnitsNet.NanoFramework\\ GeneratedCode" ) ;
130
+ var path = Path . Combine ( rootDir , "UnitsNet.NanoFramework\\ GeneratedCode" ) ;
132
131
133
132
Log . Information ( "" ) ;
134
133
Log . Information ( "Restoring .NET nanoFramework projects" ) ;
135
134
136
135
// run nuget CLI
137
- var nugetCLI = new Process
136
+ using var nugetRestore = new Process
138
137
{
139
138
StartInfo = new ProcessStartInfo
140
139
{
@@ -147,7 +146,7 @@ public static bool UpdateNanoFrameworkDependencies(
147
146
} ;
148
147
149
148
// start nuget CLI and wait for exit
150
- if ( ! nugetCLI . Start ( ) )
149
+ if ( ! nugetRestore . Start ( ) )
151
150
{
152
151
Log . Information ( "" ) ;
153
152
Log . Information ( "Failed to start nuget CLI to restore .NET nanoFramework projects" ) ;
@@ -156,25 +155,25 @@ public static bool UpdateNanoFrameworkDependencies(
156
155
else
157
156
{
158
157
// wait for exit, within 2 minutes
159
- if ( ! nugetCLI . WaitForExit ( ( int ) TimeSpan . FromMinutes ( 2 ) . TotalMilliseconds ) )
158
+ if ( ! nugetRestore . WaitForExit ( ( int ) TimeSpan . FromMinutes ( 2 ) . TotalMilliseconds ) )
160
159
{
161
160
Log . Information ( "" ) ;
162
161
Log . Information ( "Failed to complete execution of nuget CLI to restore .NET nanoFramework projects" ) ;
163
162
Log . Information ( "" ) ;
164
163
}
165
164
else
166
165
{
167
- if ( nugetCLI . ExitCode == 0 )
166
+ if ( nugetRestore . ExitCode == 0 )
168
167
{
169
168
Log . Information ( "Done!" ) ;
170
169
Log . Information ( "" ) ;
171
170
}
172
171
else
173
172
{
174
173
Log . Information ( "" ) ;
175
- Log . Information ( $ "nuget CLI executed with { nugetCLI . ExitCode } exit code") ;
174
+ Log . Information ( "nuget CLI executed with {ExitCode} exit code" , nugetRestore . ExitCode ) ;
176
175
177
- Log . Information ( nugetCLI . StandardError . ReadToEnd ( ) ) ;
176
+ Log . Information ( "{StandardError}" , nugetRestore . StandardError . ReadToEnd ( ) ) ;
178
177
179
178
return false ;
180
179
}
@@ -185,7 +184,7 @@ public static bool UpdateNanoFrameworkDependencies(
185
184
Log . Information ( "Updating .NET nanoFramework references using nuget CLI" ) ;
186
185
187
186
// run nuget CLI to perform update
188
- nugetCLI = new Process
187
+ using var nugetUpdate = new Process
189
188
{
190
189
StartInfo = new ProcessStartInfo
191
190
{
@@ -198,7 +197,7 @@ public static bool UpdateNanoFrameworkDependencies(
198
197
} ;
199
198
200
199
// start nuget CLI and wait for exit
201
- if ( ! nugetCLI . Start ( ) )
200
+ if ( ! nugetUpdate . Start ( ) )
202
201
{
203
202
Log . Information ( "" ) ;
204
203
Log . Information ( "Failed to start nuget CLI to update .NET nanoFramework projects" ) ;
@@ -207,23 +206,23 @@ public static bool UpdateNanoFrameworkDependencies(
207
206
else
208
207
{
209
208
// wait for exit, within 2 minutes
210
- if ( ! nugetCLI . WaitForExit ( ( int ) TimeSpan . FromMinutes ( 2 ) . TotalMilliseconds ) )
209
+ if ( ! nugetUpdate . WaitForExit ( ( int ) TimeSpan . FromMinutes ( 2 ) . TotalMilliseconds ) )
211
210
{
212
211
Log . Information ( "" ) ;
213
212
Log . Information ( "Failed to complete execution of nuget CLI to update .NET nanoFramework projects" ) ;
214
213
Log . Information ( "" ) ;
215
214
}
216
215
else
217
216
{
218
- if ( nugetCLI . ExitCode == 0 )
217
+ if ( nugetUpdate . ExitCode == 0 )
219
218
{
220
219
Log . Information ( "Done!" ) ;
221
220
Log . Information ( "" ) ;
222
221
223
222
Log . Information ( "Updating .NET nanoFramework nuspec files" ) ;
224
223
Log . Information ( "" ) ;
225
224
226
- foreach ( var quantity in quantities )
225
+ foreach ( Quantity quantity in quantities )
227
226
{
228
227
var projectPath = Path . Combine ( path , quantity . Name ) ;
229
228
@@ -254,9 +253,9 @@ public static bool UpdateNanoFrameworkDependencies(
254
253
else
255
254
{
256
255
Log . Information ( "" ) ;
257
- Log . Information ( $ "nuget CLI executed with { nugetCLI . ExitCode } exit code") ;
256
+ Log . Information ( "nuget CLI executed with {ExitCode} exit code" , nugetUpdate . ExitCode ) ;
258
257
259
- Log . Information ( nugetCLI . StandardError . ReadToEnd ( ) ) ;
258
+ Log . Information ( "{StandardError}" , nugetUpdate . StandardError . ReadToEnd ( ) ) ;
260
259
261
260
return false ;
262
261
}
@@ -272,7 +271,7 @@ public static bool UpdateNanoFrameworkDependencies(
272
271
private static NanoFrameworkVersions ParseCurrentNanoFrameworkVersions ( string rootDir )
273
272
{
274
273
// Angle has both mscorlib and System.Math dependency
275
- string generatedCodePath = Path . Combine ( rootDir , "UnitsNet.NanoFramework" , "GeneratedCode" ) ;
274
+ var generatedCodePath = Path . Combine ( rootDir , "UnitsNet.NanoFramework" , "GeneratedCode" ) ;
276
275
var angleProjectFile = Path . Combine ( generatedCodePath , "Angle" , "Angle.nfproj" ) ;
277
276
var projectFileContent = File . ReadAllText ( angleProjectFile ) ;
278
277
@@ -305,7 +304,7 @@ private static string ParseVersion(
305
304
string descriptiveName ,
306
305
bool throwOnFailure = true )
307
306
{
308
- var match = versionRegex . Match ( projectFileContent ) ;
307
+ Match match = versionRegex . Match ( projectFileContent ) ;
309
308
310
309
if ( ! match . Success && throwOnFailure )
311
310
{
@@ -321,8 +320,7 @@ private static void GeneratePackageConfig(
321
320
string mscorlibNuGetVersion ,
322
321
string mathNuGetVersion )
323
322
{
324
- string filePath = Path . Combine ( projectPath , "packages.config" ) ;
325
-
323
+ var filePath = Path . Combine ( projectPath , "packages.config" ) ;
326
324
var content = GeneratePackageConfigFile ( quantityName , mscorlibNuGetVersion , mathNuGetVersion ) ;
327
325
328
326
File . WriteAllText ( filePath , content ) ;
@@ -334,7 +332,7 @@ private static void GenerateNuspec(
334
332
string mscorlibNuGetVersion ,
335
333
string mathNuGetVersion )
336
334
{
337
- string filePath = Path . Combine ( projectPath , $ "UnitsNet.NanoFramework.{ quantity . Name } .nuspec") ;
335
+ var filePath = Path . Combine ( projectPath , $ "UnitsNet.NanoFramework.{ quantity . Name } .nuspec") ;
338
336
339
337
var content = new NuspecGenerator (
340
338
quantity ,
0 commit comments