@@ -60,12 +60,12 @@ public static void Execute(
60
60
var config = LoadConfig ( configurationFiles ) ;
61
61
62
62
StringBuilder namespaceBuilder = new ( ) ;
63
-
63
+
64
64
var urlSourceBuilder = new SourceStringBuilder ( ) ;
65
65
66
66
if ( config . PreAppendLines is { Count : > 0 } )
67
67
{
68
- config . PreAppendLines . ForEach ( e=> namespaceBuilder . AppendLine ( e ) ) ;
68
+ config . PreAppendLines . ForEach ( e => namespaceBuilder . AppendLine ( e ) ) ;
69
69
}
70
70
71
71
namespaceBuilder . AppendLine ( "using System.Net.Http;" ) ;
@@ -99,8 +99,8 @@ public static void Execute(
99
99
}
100
100
101
101
namespaceBuilder . AppendLine ( ) ;
102
-
103
-
102
+
103
+
104
104
var source = new SourceStringBuilder ( ) ;
105
105
source . Append ( namespaceBuilder . ToString ( ) ) ;
106
106
source . AppendLine ( ! string . IsNullOrWhiteSpace ( config . Namespace )
@@ -255,7 +255,7 @@ private static RouteGeneratorSettings LoadConfig(IEnumerable<AdditionalText> con
255
255
{
256
256
config . OutputFiles = config . OutputFiles . Select ( e => Path . GetFullPath ( Path . Combine ( configFileDirectory , e ) ) ) . ToList ( ) ;
257
257
}
258
-
258
+
259
259
if ( config . URLGeneration is { Count : > 0 } )
260
260
{
261
261
foreach ( var urlGenerationSetting in config . URLGeneration )
@@ -695,52 +695,51 @@ private static void SetUpSingleApi(RouteGeneratorSettings config, ControllerRout
695
695
}
696
696
}
697
697
698
+ if ( config . OutputUrls )
699
+ {
700
+ List < string > secondParamList = new ( ) ;
698
701
702
+ var methodParameterMappings = action . Mapping
703
+ . Where ( f => f . Parameter . FullTypeName != IFormFile_Q )
704
+ . Where ( e => action . Method == HttpMethod . Get ||
705
+ ( action . Method != HttpMethod . Get && ! action . Body . Any ( b => string . Equals ( b . Key , e . Key , StringComparison . InvariantCultureIgnoreCase ) ) ) )
706
+ . ToList ( ) ;
699
707
700
- if ( config . OutputUrls )
701
- {
702
- List < string > secondParamList = new ( ) ;
708
+ if ( methodParameterMappings . Any ( ) )
709
+ {
710
+ secondParamList . AddRange ( methodParameterMappings . Select ( parameterMapping => $ "{ parameterMapping . Parameter . FullTypeName } { parameterMapping . Key } { GetDefaultValue ( parameterMapping . Parameter ) } ") ) ;
711
+ }
703
712
704
- var methodParameterMappings = action . Mapping
705
- . Where ( f => f . Parameter . FullTypeName != IFormFile_Q )
706
- . Where ( e => action . Method == HttpMethod . Get ||
707
- ( action . Method != HttpMethod . Get && ! action . Body . Any ( b => string . Equals ( b . Key , e . Key , StringComparison . InvariantCultureIgnoreCase ) ) ) )
708
- . ToList ( ) ;
713
+ /*foreach (var (key, parameter) in methodParameterMappings)
714
+ {
715
+ source.AppendLine($"// {key} {parameter.FullTypeName}");
716
+ }*/
709
717
710
- if ( methodParameterMappings . Any ( ) )
711
- {
712
- secondParamList . AddRange ( methodParameterMappings . Select ( parameterMapping => $ "{ parameterMapping . Parameter . FullTypeName } { parameterMapping . Key } { GetDefaultValue ( parameterMapping . Parameter ) } ") ) ;
713
- }
714
-
715
- /*foreach (var (key, parameter) in methodParameterMappings)
716
- {
717
- source.AppendLine($"// {key} {parameter.FullTypeName}");
718
- }*/
719
-
720
- if ( methodParameterMappings . Any ( ) )
721
- {
722
- string parameterListWithoutFile = string . Join ( ", " , methodParameterMappings . Select ( m => $ "{ m . Parameter . FullTypeName } { m . Key } { GetDefaultValue ( m . Parameter ) } ") ) ;
723
- source . AppendLine ( $ "public string { config . OutputUrlsPrefix } { action . Name } { config . OutputUrlsPostfix } ({ string . Join ( "," , parameterListWithoutFile ) } , QueryString queryString = default)") ;
724
- }
725
- else
726
- {
727
- source . AppendLine ( $ "public string { config . OutputUrlsPrefix } { action . Name } { config . OutputUrlsPostfix } (QueryString queryString = default)") ;
728
- }
729
- source . AppendOpenCurlyBracketLine ( ) ;
730
-
731
- if ( methodParameterMappings != null && methodParameterMappings . Any ( ) )
732
- {
733
- foreach ( var parameterMapping in methodParameterMappings . Where ( r=> ! actionValues . ContainsKey ( r . Key ) ) )
718
+ if ( methodParameterMappings . Any ( ) )
719
+ {
720
+ var parameterListWithoutFile = string . Join ( ", " , methodParameterMappings . Select ( m => $ "{ m . Parameter . FullTypeName } { m . Key } { GetDefaultValue ( m . Parameter ) } ") ) ;
721
+ source . AppendLine ( $ "public string { config . OutputUrlsPrefix } { action . Name } { config . OutputUrlsPostfix } ({ string . Join ( "," , parameterListWithoutFile ) } , QueryString queryString = default)") ;
722
+ }
723
+ else
724
+ {
725
+ source . AppendLine ( $ "public string { config . OutputUrlsPrefix } { action . Name } { config . OutputUrlsPostfix } (QueryString queryString = default)") ;
726
+ }
727
+
728
+ source . AppendOpenCurlyBracketLine ( ) ;
729
+
730
+ if ( methodParameterMappings != null && methodParameterMappings . Any ( ) )
734
731
{
735
- source . AppendLine ( $ "queryString = queryString.Add(\" { parameterMapping . Key } \" , { parameterMapping . Key } .ToString());") ;
732
+ foreach ( var parameterMapping in methodParameterMappings . Where ( r => ! actionValues . ContainsKey ( r . Key ) ) )
733
+ {
734
+ source . AppendLine ( $ "queryString = queryString.Add(\" { parameterMapping . Key } \" , { parameterMapping . Key } .ToString());") ;
735
+ }
736
736
}
737
+
738
+ source . AppendLine ( $ "return { routeString } ;") ;
739
+
740
+ source . AppendCloseCurlyBracketLine ( ) ;
737
741
}
738
-
739
- source . AppendLine ( $ "return { routeString } ;") ;
740
-
741
- source . AppendCloseCurlyBracketLine ( ) ;
742
- }
743
-
742
+
744
743
CreateURLOutput ( urlSourceBuilder , controllerRoute , action , actionValues , routeString ) ;
745
744
}
746
745
}
@@ -761,7 +760,8 @@ private static void CreateURLOutput(SourceStringBuilder urlSourceBuilder, Contro
761
760
secondParamList . AddRange ( methodParameterMappings . Select ( parameterMapping => $ "{ parameterMapping . Parameter . FullTypeName } { parameterMapping . Key } { GetDefaultValue ( parameterMapping . Parameter ) } ") ) ;
762
761
}
763
762
764
- string methodName = string . Empty ;
763
+ var methodName = string . Empty ;
764
+
765
765
if ( controllerRoute . Area != null && ! string . IsNullOrWhiteSpace ( controllerRoute . Area ) )
766
766
{
767
767
methodName = $ "{ controllerRoute . Area } _{ controllerRoute . Name } ";
@@ -793,7 +793,6 @@ private static void CreateURLOutput(SourceStringBuilder urlSourceBuilder, Contro
793
793
794
794
urlSourceBuilder . AppendLine ( $ "return { routeString } ;") ;
795
795
}
796
-
797
796
}
798
797
799
798
private static string GetDefaultValue ( Parameter argParameter )
0 commit comments