chore(dotnet): handle setters and ordering bug (#5654)

This commit is contained in:
Anže Vodovnik 2021-03-01 18:49:14 +01:00 committed by GitHub
parent 6c9e806672
commit 86c7d77967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 9 deletions

View File

@ -30,7 +30,7 @@ Optional error code. Defaults to `failed`, could be one of the following:
## async method: Route.continue
* langs:
- alias-csharp: resume
- alias-csharp: ResumeAsync
- alias-java: resume
- alias-python: continue_

View File

@ -88,7 +88,7 @@ let classNameMap;
classNameMap.set('path', 'string');
classNameMap.set('URL', 'string');
classNameMap.set('RegExp', 'Regex');
// this are types that we don't explicility render even if we get the specs
const ignoredTypes = ['TimeoutException'];
@ -194,11 +194,6 @@ function translateMemberName(memberKind, name, member = null) {
// like, when generating classes inside methods for params
name = name.replace(/[@-]/g, '');
// we sanitize some common abbreviations to ensure consistency
name = name.replace(/(HTTP[S]?)/g, (m, g) => {
return g[0].toUpperCase() + g.substring(1).toLowerCase();
});
if (memberKind === 'argument') {
if (['params', 'event'].includes(name)) { // just in case we want to add others
return `@${name}`;
@ -206,6 +201,7 @@ function translateMemberName(memberKind, name, member = null) {
return name;
}
}
// check if there's an alias in the docs, in which case
// we return that, otherwise, we apply our dotnet magic to it
if (member) {
@ -214,6 +210,11 @@ function translateMemberName(memberKind, name, member = null) {
}
}
// we sanitize some common abbreviations to ensure consistency
name = name.replace(/(HTTP[S]?)/g, (m, g) => {
return g[0].toUpperCase() + g.substring(1).toLowerCase();
});
let assumedName = name.charAt(0).toUpperCase() + name.substring(1);
switch (memberKind) {
@ -384,11 +385,12 @@ function renderMethod(member, parent, output, name) {
}
}
type = type || typeResolve(member.type); //translateType(member.type, parent);
type = type || typeResolve(member.type);
// TODO: this is something that will probably go into the docs
// translate simple getters into read-only properties, and simple
// set-only methods to settable properties
if (member.args.size == 0
&& type !== 'void'
&& !name.startsWith('Is')
&& !name.startsWith('Get')) {
if (!member.async) {
if (member.spec)
@ -397,6 +399,15 @@ function renderMethod(member, parent, output, name) {
return;
}
name = `Get${name}`;
} else if (member.args.size == 1
&& type === 'void'
&& name.startsWith('Set')
&& !member.async) {
name = name.substring(3); // remove the 'Set'
if (member.spec)
output(XmlDoc.renderXmlDoc(member.spec, maxDocumentationColumnWidth));
output(`${translateType(member.argsArray[0].type, parent)} ${name} { set; }`);
return;
}
// HACK: special case for generics handling!