Skip to content

Commit

Permalink
Fixed the format of TimeSpan
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-v-singh committed May 24, 2024
1 parent 020624c commit 3c8ef7c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions codegens/csharp-restsharp/lib/restsharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ function makeOptionsSnippet (urlOrigin, options, indentString, headers) {
});
}
if (options.requestTimeout) {
snippet += `${indentString}Timeout = new TimeSpan(${options.requestTimeout}),\n`;
}
else {
snippet += `${indentString}Timeout = new TimeSpan(-1),\n`;
snippet += `${indentString}Timeout = new TimeSpan(0, 0, 0, ${options.requestTimeout}),\n`;
}
if (!options.followRedirect) {
snippet += `${indentString}FollowRedirects = false,\n`;
Expand Down
2 changes: 1 addition & 1 deletion codegens/csharp-restsharp/test/unit/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('csharp restsharp function', function () {
expect.fail(null, null, error);
}
expect(snippet).to.be.a('string');
expect(snippet).to.include('Timeout = new TimeSpan(5)');
expect(snippet).to.include('Timeout = new TimeSpan(0, 0, 0, 5)');
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"result" : "var options = new RestClientOptions(\"https://postman-echo.com\")\n{\n\tTimeout = new TimeSpan(-1),\n};\nvar client = new RestClient(options);\nvar request = new RestRequest(\"/post/?hardik=\\\"me\\\"\", Method.Post);\nrequest.AddHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\nrequest.AddParameter(\"1\", \"a\");\nrequest.AddParameter(\"2\", \"b\");\nrequest.AddParameter(\"\\\"\\\"12\\\"\\\"\", \"\\\"23\\\"\");\nrequest.AddParameter(\"'1\\\"2\\\\\\\"\\\"3'\", \"'1\\\"23\\\"4'\");\nRestResponse response = await client.ExecuteAsync(request);\nConsole.WriteLine(response.Content);"
"result" : "var options = new RestClientOptions(\"https://postman-echo.com\")\n{\n};\nvar client = new RestClient(options);\nvar request = new RestRequest(\"/post/?hardik=\\\"me\\\"\", Method.Post);\nrequest.AddHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\nrequest.AddParameter(\"1\", \"a\");\nrequest.AddParameter(\"2\", \"b\");\nrequest.AddParameter(\"\\\"\\\"12\\\"\\\"\", \"\\\"23\\\"\");\nrequest.AddParameter(\"'1\\\"2\\\\\\\"\\\"3'\", \"'1\\\"23\\\"4'\");\nRestResponse response = await client.ExecuteAsync(request);\nConsole.WriteLine(response.Content);"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"result": "var options = new RestClientOptions(\"https://postman-echo.com\")\n{\n\tTimeout = new TimeSpan(-1),\n};\nvar client = new RestClient(options);\nvar request = new RestRequest(\"/post\", Method.Post);\nrequest.AddHeader(\"Content-Type\", \"application/json\");\nvar body = @\"{\" + \"\\n\" +\n@\" \"\"json\"\": \"\"Test-Test\"\"\" + \"\\n\" +\n@\"}\";\nrequest.AddStringBody(body, DataFormat.Json);\nRestResponse response = await client.ExecuteAsync(request);\nConsole.WriteLine(response.Content);"
"result": "var options = new RestClientOptions(\"https://postman-echo.com\")\n{\n};\nvar client = new RestClient(options);\nvar request = new RestRequest(\"/post\", Method.Post);\nrequest.AddHeader(\"Content-Type\", \"application/json\");\nvar body = @\"{\" + \"\\n\" +\n@\" \"\"json\"\": \"\"Test-Test\"\"\" + \"\\n\" +\n@\"}\";\nrequest.AddStringBody(body, DataFormat.Json);\nRestResponse response = await client.ExecuteAsync(request);\nConsole.WriteLine(response.Content);"
}
6 changes: 3 additions & 3 deletions npm/ci-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ pushd ./codegens/csharp-restsharp &>/dev/null;
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-6.0
dotnet new console -o testProject -f net6.0
sudo apt-get install dotnet-sdk-8.0
dotnet new console -o testProject -f net8.0
pushd ./testProject &>/dev/null;
dotnet add package RestSharp
dotnet add package RestSharp --version 111.0.0
popd &>/dev/null;
popd &>/dev/null;

Expand Down

0 comments on commit 3c8ef7c

Please sign in to comment.