@@ -37,9 +37,9 @@ private static class Metadata
3737 public const string WithCulture = "WithCulture" ;
3838 }
3939
40- private static Regex _namedParameterMatcher = new Regex ( @"\{([a-z]\w+)\}" , RegexOptions . IgnoreCase ) ;
41- private static Regex _numberParameterMatcher = new Regex ( @"\{(\d+)\}" ) ;
42- private List < ITaskItem > _createdFiles = new List < ITaskItem > ( ) ;
40+ private static readonly Regex _namedParameterMatcher = new Regex ( @"\{([a-z]\w+)\}" , RegexOptions . IgnoreCase ) ;
41+ private static readonly Regex _numberParameterMatcher = new Regex ( @"\{(\d+)\}" ) ;
42+ private readonly List < ITaskItem > _createdFiles = new List < ITaskItem > ( ) ;
4343
4444 /// <summary>
4545 /// <para>
@@ -102,7 +102,7 @@ public override bool Execute()
102102 return true ;
103103 }
104104
105- private bool GenerateCsharp ( string resxFile , string outputFileName , string manifestName )
105+ private void GenerateCsharp ( string resxFile , string outputFileName , string manifestName )
106106 {
107107 if ( string . IsNullOrEmpty ( outputFileName ) )
108108 {
@@ -122,7 +122,7 @@ private bool GenerateCsharp(string resxFile, string outputFileName, string manif
122122 if ( ! File . Exists ( resxFile ) )
123123 {
124124 Log . LogError ( "'{0}' does not exist" , resxFile ) ;
125- return false ;
125+ return ;
126126 }
127127
128128 var xml = XDocument . Load ( resxFile ) ;
@@ -135,7 +135,7 @@ private bool GenerateCsharp(string resxFile, string outputFileName, string manif
135135 var name = entry . Attribute ( "name" ) . Value ;
136136 var value = entry . Element ( "value" ) . Value ;
137137
138- bool usingNamedArgs = true ;
138+ var usingNamedArgs = true ;
139139 var match = _namedParameterMatcher . Matches ( value ) ;
140140 if ( match . Count == 0 )
141141 {
@@ -219,11 +219,8 @@ private static string GetString(string name, params string[] formatterNames)
219219}" ) ;
220220
221221 }
222-
223- return true ;
224222 }
225223
226-
227224 private static void RenderHeader ( TextWriter writer , ResourceData resourceString )
228225 {
229226 writer . WriteLine ( "/// <summary>" ) ;
@@ -238,7 +235,7 @@ private static void RenderProperty(TextWriter writer, ResourceData resourceStrin
238235 {
239236 writer . WriteLine ( "internal static string {0}" , resourceString . Name ) ;
240237 writer . WriteLine ( "{" ) ;
241- using ( var indent = writer . Indent ( 4 ) )
238+ using ( var indent = writer . Indent ( ) )
242239 {
243240 indent . WriteLine ( $@ "get => GetString(""{ resourceString . Name } "");") ;
244241 }
@@ -249,7 +246,7 @@ private static void RenderFormatMethod(TextWriter writer, ResourceData resourceS
249246 {
250247 writer . WriteLine ( $ "internal static string Format{ resourceString . Name } ({ resourceString . Parameters } )") ;
251248
252- using ( var indent = writer . Indent ( 4 ) )
249+ using ( var indent = writer . Indent ( ) )
253250 {
254251 if ( resourceString . Arguments . Count > 0 )
255252 {
@@ -273,25 +270,13 @@ private class ResourceData
273270
274271 public bool UsingNamedArgs { get ; set ; }
275272
276- public string FormatArguments
277- {
278- get { return string . Join ( ", " , Arguments . Select ( a => "\" " + a + "\" " ) ) ; }
279- }
273+ public string FormatArguments => string . Join ( ", " , Arguments . Select ( a => "\" " + a + "\" " ) ) ;
280274
281- public string ArgumentNames
282- {
283- get { return string . Join ( ", " , Arguments . Select ( GetArgName ) ) ; }
284- }
275+ public string ArgumentNames => string . Join ( ", " , Arguments . Select ( GetArgName ) ) ;
285276
286- public string Parameters
287- {
288- get { return string . Join ( ", " , Arguments . Select ( a => "object " + GetArgName ( a ) ) ) ; }
289- }
277+ public string Parameters => string . Join ( ", " , Arguments . Select ( a => "object " + GetArgName ( a ) ) ) ;
290278
291- public string GetArgName ( string name )
292- {
293- return UsingNamedArgs ? name : 'p' + name ;
294- }
279+ private string GetArgName ( string name ) => UsingNamedArgs ? name : 'p' + name ;
295280 }
296281 }
297282}
0 commit comments