Skip to content

Commit 2ccda2b

Browse files
committed
Remove sync option
Remove sync option
1 parent 7cd4d37 commit 2ccda2b

File tree

3 files changed

+6
-65
lines changed

3 files changed

+6
-65
lines changed

codegens/csharp-restsharp/lib/restsharp.js

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,7 @@ function makeSnippet (request, options, indentString) {
161161
snippet += '};\n';
162162
}
163163

164-
if (options.asyncType === 'sync') {
165-
snippet += 'RestResponse response = client.Execute(request);\n';
166-
}
167-
else {
168-
snippet += 'RestResponse response = await client.ExecuteAsync(request);\n';
169-
}
164+
snippet += 'RestResponse response = await client.ExecuteAsync(request);\n';
170165
snippet += 'Console.WriteLine(response.Content);';
171166

172167
return snippet;
@@ -225,14 +220,6 @@ self = module.exports = {
225220
type: 'boolean',
226221
default: false,
227222
description: 'Remove white space and additional lines that may affect the server\'s response'
228-
},
229-
{
230-
name: 'Set communication type',
231-
id: 'asyncType',
232-
type: 'enum',
233-
availableOptions: ['async', 'sync'],
234-
default: 'async',
235-
description: 'Set if the requests will be asynchronous or synchronous'
236223
}
237224
];
238225
},
@@ -278,13 +265,10 @@ self = module.exports = {
278265
indentString = indentString.repeat(options.indentCount);
279266

280267
if (options.includeBoilerplate) {
281-
if (options.asyncType === 'sync') {
282-
mainMethodSnippet = indentString.repeat(2) + 'static void Main(string[] args) {\n';
283-
}
284-
else {
285-
mainMethodSnippet = indentString.repeat(2) + 'static async Task Main(string[] args) {\n';
286-
importTask = 'using System.Threading;\nusing System.Threading.Tasks;\n';
287-
}
268+
269+
mainMethodSnippet = indentString.repeat(2) + 'static async Task Main(string[] args) {\n';
270+
importTask = 'using System.Threading;\nusing System.Threading.Tasks;\n';
271+
288272
headerSnippet = 'using System;\n' +
289273
'using RestSharp;\n' +
290274
importTask +

codegens/csharp-restsharp/test/unit/convert.test.js

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var expect = require('chai').expect,
44
mainCollection = require('./fixtures/testcollection/collection.json'),
55
testCollection = require('./fixtures/testcollection/collectionForEdge.json'),
66
getOptions = require('../../lib/index').getOptions,
7-
testResponse = require('./fixtures/testresponse.json'),
87
testResponseAsync = require('./fixtures/testResponseAsync.json'),
98
testResponseJsonParams = require('./fixtures/testResponseJsonParams.json'),
109
sanitize = require('../../lib/util').sanitize,
@@ -13,25 +12,6 @@ var expect = require('chai').expect,
1312
describe('csharp restsharp function', function () {
1413

1514
describe('csharp-restsharp convert function', function () {
16-
it('should return expected snippet', function () {
17-
var request = new sdk.Request(mainCollection.item[4].request),
18-
options = {
19-
indentCount: 1,
20-
indentType: 'Tab',
21-
followRedirect: true,
22-
trimRequestBody: true,
23-
asyncType: 'sync'
24-
};
25-
26-
convert(request, options, function (error, snippet) {
27-
if (error) {
28-
expect.fail(null, null, error);
29-
return;
30-
}
31-
expect(snippet).deep.equal(testResponse.result);
32-
});
33-
});
34-
3515
it('should return expected snippet - Async', function () {
3616
var request = new sdk.Request(mainCollection.item[4].request),
3717
options = {
@@ -86,6 +66,7 @@ describe('csharp restsharp function', function () {
8666
}
8767
expect(snippet).to.include('using System;\nusing RestSharp;\nusing System.Threading;\nusing' +
8868
' System.Threading.Tasks;\nnamespace HelloWorldApplication {\n');
69+
expect(snippet).to.include('static async Task Main(string[] args) {');
8970
});
9071
});
9172

@@ -233,26 +214,6 @@ describe('csharp restsharp function', function () {
233214
});
234215
});
235216

236-
it('should return snippet with boilerplate code given option and async', function () {
237-
convert(request, { includeBoilerplate: true }, function (error, snippet) {
238-
if (error) {
239-
expect.fail(null, null, error);
240-
return;
241-
}
242-
expect(snippet).to.include('static async Task Main(string[] args) {');
243-
});
244-
});
245-
246-
it('should return snippet with boilerplate code given option and sync', function () {
247-
convert(request, { includeBoilerplate: true, asyncType: 'sync' }, function (error, snippet) {
248-
if (error) {
249-
expect.fail(null, null, error);
250-
return;
251-
}
252-
expect(snippet).to.include('static void Main(string[] args) {');
253-
});
254-
});
255-
256217
});
257218

258219
describe('getOptions function', function () {
@@ -339,7 +300,6 @@ describe('csharp restsharp function', function () {
339300

340301
it('should return the same object when valid (but not necessarily defaults) options are provided', function () {
341302
testOptions = {};
342-
testOptions.asyncType = 'async';
343303
testOptions.indentType = 'Tab';
344304
testOptions.indentCount = 3;
345305
testOptions.requestTimeout = 3000;

codegens/csharp-restsharp/test/unit/fixtures/testresponse.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)