33
44namespace CSharpToJsonSchema . IntegrationTests
55{
6- public class GetCurrentWeatherArgs
6+ public class GetCurrentWeather2Args
77 {
88 public string Location { get ; set ; } = string . Empty ;
99 public global ::CSharpToJsonSchema . IntegrationTests . Unit2 Unit { get ; set ; }
1010 }
1111
12- public class GetCurrentWeatherAsyncArgs
12+ public class GetCurrentWeatherAsync2Args
1313 {
1414 public string Location { get ; set ; } = string . Empty ;
1515 public global ::CSharpToJsonSchema . IntegrationTests . Unit2 Unit { get ; set ; }
@@ -24,77 +24,146 @@ public static partial class WeatherStrictToolsExtensions
2424 {
2525 return new global ::System . Collections . Generic . Dictionary < string , global ::System . Func < string , global ::System . Threading . CancellationToken , global ::System . Threading . Tasks . Task < string > > >
2626 {
27- [ "GetCurrentWeather " ] = ( json , _ ) =>
27+ [ "GetCurrentWeather2 " ] = ( json , _ ) =>
2828 {
29- return global ::System . Threading . Tasks . Task . FromResult ( service . CallGetCurrentWeather ( json ) ) ;
29+ return global ::System . Threading . Tasks . Task . FromResult ( service . CallGetCurrentWeather2 ( json ) ) ;
3030 } ,
3131
32- [ "GetCurrentWeatherAsync " ] = async ( json , cancellationToken ) =>
32+ [ "GetCurrentWeatherAsync2 " ] = async ( json , cancellationToken ) =>
3333 {
34- return await service . CallGetCurrentWeatherAsync ( json , cancellationToken ) ;
34+ return await service . CallGetCurrentWeatherAsync2 ( json , cancellationToken ) ;
3535 } ,
3636
3737 } ;
3838 }
3939
40- public static GetCurrentWeatherArgs AsGetCurrentWeatherArgs (
40+ public static GetCurrentWeather2Args AsGetCurrentWeather2Args (
4141 this IWeatherStrictTools functions ,
4242 string json )
4343 {
44-
44+ #if NET6_0_OR_GREATER
45+ if ( global ::System . Text . Json . JsonSerializer . IsReflectionEnabledByDefault )
46+ {
47+ return
48+ global ::System . Text . Json . JsonSerializer . Deserialize < GetCurrentWeather2Args > ( json , new global ::System . Text . Json . JsonSerializerOptions
49+ {
50+ PropertyNamingPolicy = global ::System . Text . Json . JsonNamingPolicy . CamelCase ,
51+ Converters = { { new global ::System . Text . Json . Serialization . JsonStringEnumConverter ( global ::System . Text . Json . JsonNamingPolicy . CamelCase ) } }
52+ } ) ??
53+ throw new global ::System . InvalidOperationException ( "Could not deserialize JSON." ) ;
54+
55+ }
56+ else
57+ {
58+ return global ::System . Text . Json . JsonSerializer . Deserialize ( json , global ::CSharpToJsonSchema . IntegrationTests . WeatherStrictToolsExtensionsJsonSerializerContext . Default . GetCurrentWeather2Args ) ??
59+ throw new global ::System . InvalidOperationException ( "Could not deserialize JSON." ) ;
60+
61+ }
62+ #else
4563 return
46- global ::System . Text . Json . JsonSerializer . Deserialize < GetCurrentWeatherArgs > ( json , new global ::System . Text . Json . JsonSerializerOptions
64+ global ::System . Text . Json . JsonSerializer . Deserialize < GetCurrentWeather2Args > ( json , new global ::System . Text . Json . JsonSerializerOptions
4765 {
4866 PropertyNamingPolicy = global ::System . Text . Json . JsonNamingPolicy . CamelCase ,
4967 Converters = { { new global ::System . Text . Json . Serialization . JsonStringEnumConverter ( global ::System . Text . Json . JsonNamingPolicy . CamelCase ) } }
5068 } ) ??
5169 throw new global ::System . InvalidOperationException ( "Could not deserialize JSON." ) ;
52-
70+ #endif
5371 }
5472
55- public static GetCurrentWeatherAsyncArgs AsGetCurrentWeatherAsyncArgs (
73+ public static GetCurrentWeatherAsync2Args AsGetCurrentWeatherAsync2Args (
5674 this IWeatherStrictTools functions ,
5775 string json )
5876 {
59-
77+ #if NET6_0_OR_GREATER
78+ if ( global ::System . Text . Json . JsonSerializer . IsReflectionEnabledByDefault )
79+ {
80+ return
81+ global ::System . Text . Json . JsonSerializer . Deserialize < GetCurrentWeatherAsync2Args > ( json , new global ::System . Text . Json . JsonSerializerOptions
82+ {
83+ PropertyNamingPolicy = global ::System . Text . Json . JsonNamingPolicy . CamelCase ,
84+ Converters = { { new global ::System . Text . Json . Serialization . JsonStringEnumConverter ( global ::System . Text . Json . JsonNamingPolicy . CamelCase ) } }
85+ } ) ??
86+ throw new global ::System . InvalidOperationException ( "Could not deserialize JSON." ) ;
87+
88+ }
89+ else
90+ {
91+ return global ::System . Text . Json . JsonSerializer . Deserialize ( json , global ::CSharpToJsonSchema . IntegrationTests . WeatherStrictToolsExtensionsJsonSerializerContext . Default . GetCurrentWeatherAsync2Args ) ??
92+ throw new global ::System . InvalidOperationException ( "Could not deserialize JSON." ) ;
93+
94+ }
95+ #else
6096 return
61- global ::System . Text . Json . JsonSerializer . Deserialize < GetCurrentWeatherAsyncArgs > ( json , new global ::System . Text . Json . JsonSerializerOptions
97+ global ::System . Text . Json . JsonSerializer . Deserialize < GetCurrentWeatherAsync2Args > ( json , new global ::System . Text . Json . JsonSerializerOptions
6298 {
6399 PropertyNamingPolicy = global ::System . Text . Json . JsonNamingPolicy . CamelCase ,
64100 Converters = { { new global ::System . Text . Json . Serialization . JsonStringEnumConverter ( global ::System . Text . Json . JsonNamingPolicy . CamelCase ) } }
65101 } ) ??
66102 throw new global ::System . InvalidOperationException ( "Could not deserialize JSON." ) ;
67-
103+ #endif
68104 }
69105
70- public static string CallGetCurrentWeather ( this IWeatherStrictTools functions , string json )
106+ public static string CallGetCurrentWeather2 ( this IWeatherStrictTools functions , string json )
71107 {
72- var args = functions . AsGetCurrentWeatherArgs ( json ) ;
73- var jsonResult = functions . GetCurrentWeather ( args . Location , args . Unit ) ;
108+ var args = functions . AsGetCurrentWeather2Args ( json ) ;
109+ var jsonResult = functions . GetCurrentWeather2 ( args . Location , args . Unit ) ;
74110
75- return global ::System . Text . Json . JsonSerializer . Serialize ( jsonResult , new global ::System . Text . Json . JsonSerializerOptions
111+ #if NET6_0_OR_GREATER
112+ if ( global ::System . Text . Json . JsonSerializer . IsReflectionEnabledByDefault )
76113 {
77- PropertyNamingPolicy = global ::System . Text . Json . JsonNamingPolicy . CamelCase ,
78- Converters = { new global ::System . Text . Json . Serialization . JsonStringEnumConverter ( global ::System . Text . Json . JsonNamingPolicy . CamelCase ) } ,
79- } ) ;
114+ return global ::System . Text . Json . JsonSerializer . Serialize ( jsonResult , new global ::System . Text . Json . JsonSerializerOptions
115+ {
116+ PropertyNamingPolicy = global ::System . Text . Json . JsonNamingPolicy . CamelCase ,
117+ Converters = { new global ::System . Text . Json . Serialization . JsonStringEnumConverter ( global ::System . Text . Json . JsonNamingPolicy . CamelCase ) } ,
118+ } ) ;
119+ }
120+ else
121+ {
122+ return global ::System . Text . Json . JsonSerializer . Serialize ( jsonResult , global ::CSharpToJsonSchema . IntegrationTests . WeatherStrictToolsExtensionsJsonSerializerContext . Default . GetTypeInfo ( jsonResult . GetType ( ) ) ) ;
123+ }
124+ #else
125+ return global ::System . Text . Json . JsonSerializer . Serialize ( jsonResult , new global ::System . Text . Json . JsonSerializerOptions
126+ {
127+ PropertyNamingPolicy = global ::System . Text . Json . JsonNamingPolicy . CamelCase ,
128+ Converters = { new global ::System . Text . Json . Serialization . JsonStringEnumConverter ( global ::System . Text . Json . JsonNamingPolicy . CamelCase ) } ,
129+ } ) ;
130+ #endif
131+
80132 }
81133
82134
83135
84- public static async global ::System . Threading . Tasks . Task < string > CallGetCurrentWeatherAsync (
136+ public static async global ::System . Threading . Tasks . Task < string > CallGetCurrentWeatherAsync2 (
85137 this IWeatherStrictTools functions ,
86138 string json ,
87139 global ::System . Threading . CancellationToken cancellationToken = default )
88140 {
89- var args = functions . AsGetCurrentWeatherAsyncArgs ( json ) ;
90- var jsonResult = await functions . GetCurrentWeatherAsync ( args . Location , args . Unit , cancellationToken ) ;
141+ var args = functions . AsGetCurrentWeatherAsync2Args ( json ) ;
142+ var jsonResult = await functions . GetCurrentWeatherAsync2 ( args . Location , args . Unit , cancellationToken ) ;
91143
144+ #if NET6_0_OR_GREATER
145+ if ( global ::System . Text . Json . JsonSerializer . IsReflectionEnabledByDefault )
146+ {
147+ return global ::System . Text . Json . JsonSerializer . Serialize ( jsonResult , new global ::System . Text . Json . JsonSerializerOptions
148+ {
149+ PropertyNamingPolicy = global ::System . Text . Json . JsonNamingPolicy . CamelCase ,
150+ Converters = { new global ::System . Text . Json . Serialization . JsonStringEnumConverter ( global ::System . Text . Json . JsonNamingPolicy . CamelCase ) } ,
151+ } ) ;
152+ }
153+ else
154+ {
155+ return global ::System . Text . Json . JsonSerializer . Serialize ( jsonResult , global ::CSharpToJsonSchema . IntegrationTests . WeatherStrictToolsExtensionsJsonSerializerContext . Default . GetTypeInfo ( jsonResult . GetType ( ) ) ) ;
156+ }
157+ #else
92158 return global ::System . Text . Json . JsonSerializer . Serialize ( jsonResult , new global ::System . Text . Json . JsonSerializerOptions
93159 {
94160 PropertyNamingPolicy = global ::System . Text . Json . JsonNamingPolicy . CamelCase ,
95161 Converters = { new global ::System . Text . Json . Serialization . JsonStringEnumConverter ( global ::System . Text . Json . JsonNamingPolicy . CamelCase ) } ,
96162 } ) ;
163+ #endif
164+
97165 }
166+
98167
99168
100169
0 commit comments