Skip to content

Commit a050907

Browse files
manuc66wing328
authored andcommitted
fix net35 with JsonSubTypes (#7043)
* upgrade JsonSubTypes to 1.2.0 * update samples * add SwaggerClientNet35 * re-generate * fix the linux build script
1 parent 587dc20 commit a050907

File tree

198 files changed

+17742
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+17742
-73
lines changed

bin/csharp-petstore-all.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
# C# Petstore API client (.NET 4.0)
1313
./bin/csharp-petstore-net-40.sh
1414

15+
# C# Petstore API client (.NET 3.5)
16+
./bin/csharp-petstore-net-35.sh
17+

bin/csharp-petstore-net-35.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"targetFramework": "v3.5"
3+
}

bin/csharp-petstore-net-35.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
ags="generate $@ -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClientNet35 --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-net-35.json"
30+
31+
java $JAVA_OPTS -jar $executable $ags

bin/windows/csharp-petstore-all.bat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ call .\bin\windows\csharp-petstore-netcore-project.bat
1313

1414
call .\bin\windows\csharp-property-changed-petstore.bat
1515

16-
call .\bin\windows\csharp-petstore-net-40.bat
16+
call .\bin\windows\csharp-petstore-net-40.bat
17+
18+
call .\bin\windows\csharp-petstore-net-35.bat
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8+
set ags=generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClientNet35 --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-net-35.json
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%

modules/swagger-codegen/src/main/resources/csharp/Project.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\Newtonsoft.Json.10.0.3\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
7474
</Reference>
7575
<Reference Include="JsonSubTypes">
76-
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
77-
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
78-
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
79-
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
76+
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.2.0\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
77+
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.2.0\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
78+
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.2.0\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
79+
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\JsonSubTypes.1.2.0\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
8080
</Reference>
8181
<Reference Include="RestSharp">
8282
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}\RestSharp.dll</HintPath>

modules/swagger-codegen/src/main/resources/csharp/README.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c
4444
{{^netStandard}}
4545
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0 or later
4646
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later
47+
- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.2.0 or later
4748

4849
The DLLs included in the package may not be the latest version. We recommend using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
4950
```
5051
Install-Package RestSharp
5152
Install-Package Newtonsoft.Json
53+
Install-Package JsonSubTypes
5254
```
5355

5456
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742)

modules/swagger-codegen/src/main/resources/csharp/TestProject.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@
6565
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\Newtonsoft.Json.10.0.3\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
6666
</Reference>
6767
<Reference Include="JsonSubTypes">
68-
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
69-
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
70-
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
71-
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
68+
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.2.0\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
69+
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.2.0\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
70+
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.2.0\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
71+
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\JsonSubTypes.1.2.0\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
7272
</Reference>
7373
<Reference Include="RestSharp">
7474
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}\RestSharp.dll</HintPath>

modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ esac
3333

3434
echo "[INFO] Target framework: ${frameworkVersion}"
3535

36-
if [ ! type nuget &>/dev/null ]; then
36+
if ! type nuget &>/dev/null; then
3737
echo "[INFO] Download nuget and packages"
3838
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
39-
nuget_cmd="mono nuget"
39+
nuget_cmd="mono nuget.exe"
4040
fi
4141

4242
mozroots --import --sync
@@ -46,14 +46,15 @@ echo "[INFO] Copy DLLs to the 'bin' folder"
4646
mkdir -p bin;
4747
cp packages/Newtonsoft.Json.10.0.3/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll;
4848
cp packages/RestSharp.105.1.0/lib/{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}/RestSharp.dll bin/RestSharp.dll;
49+
cp packages/JsonSubTypes.1.2.0/lib/{{targetFrameworkNuget}}/JsonSubTypes.dll bin/JsonSubTypes.dll
4950
{{#generatePropertyChanged}}
5051
cp packages/Fody.1.29.4/Fody.dll bin/Fody.dll
5152
cp packages/PropertyChanged.Fody.1.51.3/PropertyChanged.Fody.dll bin/PropertyChanged.Fody.dll
5253
cp packages/PropertyChanged.Fody.1.51.3/Lib/dotnet/PropertyChanged.dll bin/PropertyChanged.dll
5354
{{/generatePropertyChanged}}
5455

5556
echo "[INFO] Run 'mcs' to build bin/{{{packageName}}}.dll"
56-
mcs -langversion:${langversion} -sdk:${sdk} -r:bin/Newtonsoft.Json.dll,\
57+
mcs -langversion:${langversion} -sdk:${sdk} -r:bin/Newtonsoft.Json.dll,bin/JsonSubTypes.dll,\
5758
{{#generatePropertyChanged}}
5859
bin/Fody.dll,\
5960
bin/PropertyChanged.Fody.dll,\

modules/swagger-codegen/src/main/resources/csharp/compile.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient
1515

1616
if not exist ".\bin" mkdir bin
1717

18-
copy packages\Newtonsoft.Json.{{#isNet40}}4.5.11{{/isNet40}}{{^isNet40}}10.0.3{{/isNet40}}\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll
18+
copy packages\Newtonsoft.Json.10.0.3\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll
19+
copy packages\JsonSubTypes.1.2.0\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll bin\JsonSubTypes.dll
1920
copy packages\RestSharp.105.1.0\lib\{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}\RestSharp.dll bin\RestSharp.dll
2021
{{#generatePropertyChanged}}
2122
copy packages\Fody.1.29.4\Fody.dll bin\Fody.dll
2223
copy packages\PropertyChanged.Fody.1.51.3\PropertyChanged.Fody.dll bin\PropertyChanged.Fody.dll
2324
copy packages\PropertyChanged.Fody.1.51.3\Lib\dotnet\PropertyChanged.dll bin\PropertyChanged.dll
2425
{{/generatePropertyChanged}}
25-
%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll {{#generatePropertyChanged}}/r:bin\Fody.dll;bin\PropertyChanged.Fody.dll;bin\PropertyChanged.dll{{/generatePropertyChanged}} /target:library /out:bin\{{packageName}}.dll /recurse:src\{{packageName}}\*.cs /doc:bin\{{packageName}}.xml
26+
%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\JsonSubTypes.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll {{#generatePropertyChanged}}/r:bin\Fody.dll;bin\PropertyChanged.Fody.dll;bin\PropertyChanged.dll{{/generatePropertyChanged}} /target:library /out:bin\{{packageName}}.dll /recurse:src\{{packageName}}\*.cs /doc:bin\{{packageName}}.xml
2627

0 commit comments

Comments
 (0)