chore(dotnet): fix channel generation for 1.17 (#10711)
This commit is contained in:
parent
7765131a14
commit
c3687a693b
|
|
@ -96,7 +96,7 @@ classNameMap.set('Readable', 'Stream');
|
||||||
* @param {string} folder
|
* @param {string} folder
|
||||||
* @param {string} extendsName
|
* @param {string} extendsName
|
||||||
*/
|
*/
|
||||||
function writeFile(kind, name, spec, body, folder, extendsName = null, namespace = "Microsoft.Playwright") {
|
function writeFile(kind, name, spec, body, folder, extendsName = null) {
|
||||||
const out = [];
|
const out = [];
|
||||||
// console.log(`Generating ${name}`);
|
// console.log(`Generating ${name}`);
|
||||||
|
|
||||||
|
|
@ -122,7 +122,7 @@ function writeFile(kind, name, spec, body, folder, extendsName = null, namespace
|
||||||
out.push(...body);
|
out.push(...body);
|
||||||
out.push('}');
|
out.push('}');
|
||||||
|
|
||||||
let content = template.replace('[NAMESPACE]', namespace).replace('[CONTENT]', out.join(EOL));
|
let content = template.replace('[CONTENT]', out.join(EOL));
|
||||||
fs.writeFileSync(path.join(folder, name + '.cs'), content);
|
fs.writeFileSync(path.join(folder, name + '.cs'), content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
namespace [NAMESPACE]
|
namespace Microsoft.Playwright
|
||||||
{
|
{
|
||||||
[CONTENT]
|
[CONTENT]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
utils/generate_dotnet_channels.js
Executable file → Normal file
11
utils/generate_dotnet_channels.js
Executable file → Normal file
|
|
@ -18,7 +18,6 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const os = require('os');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const yaml = require('yaml');
|
const yaml = require('yaml');
|
||||||
|
|
||||||
|
|
@ -41,8 +40,13 @@ function mapType(type) {
|
||||||
return 'bool';
|
return 'bool';
|
||||||
if (type === 'number')
|
if (type === 'number')
|
||||||
return 'int';
|
return 'int';
|
||||||
|
// TODO: keep the same names in .NET as upstream
|
||||||
if (type === 'ResourceTiming')
|
if (type === 'ResourceTiming')
|
||||||
return 'RequestTimingResult';
|
return 'RequestTimingResult';
|
||||||
|
if (type === 'LifecycleEvent')
|
||||||
|
return 'WaitUntilState';
|
||||||
|
if (type === 'NameValue')
|
||||||
|
return 'HeaderEntry';
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +69,7 @@ function inlineType(type, indent = '', wrapEnums = false) {
|
||||||
return { ts: mapType(type), scheme: `t${titleCase(type)}`, optional };
|
return { ts: mapType(type), scheme: `t${titleCase(type)}`, optional };
|
||||||
}
|
}
|
||||||
if (channels.has(type))
|
if (channels.has(type))
|
||||||
return { ts: `${type}`, scheme: `tChannel('${type}')` , optional };
|
return { ts: `Core.${type}`, scheme: `tChannel('${type}')` , optional };
|
||||||
if (type === 'Channel')
|
if (type === 'Channel')
|
||||||
return { ts: `Channel`, scheme: `tChannel('*')`, optional };
|
return { ts: `Channel`, scheme: `tChannel('*')`, optional };
|
||||||
return { ts: mapType(type), scheme: `tType('${type}')`, optional };
|
return { ts: mapType(type), scheme: `tType('${type}')`, optional };
|
||||||
|
|
@ -179,7 +183,6 @@ for (const [name, item] of Object.entries(protocol)) {
|
||||||
*/
|
*/
|
||||||
`)
|
`)
|
||||||
channels_ts.push('using System.Collections.Generic;');
|
channels_ts.push('using System.Collections.Generic;');
|
||||||
channels_ts.push('using Microsoft.Playwright.Core;');
|
|
||||||
channels_ts.push(``);
|
channels_ts.push(``);
|
||||||
channels_ts.push(`namespace Microsoft.Playwright.Transport.Protocol`);
|
channels_ts.push(`namespace Microsoft.Playwright.Transport.Protocol`);
|
||||||
channels_ts.push(`{`);
|
channels_ts.push(`{`);
|
||||||
|
|
@ -227,4 +230,4 @@ function processCustomType(type, optional) {
|
||||||
&& inlineType(type.properties.name).ts === 'string') {
|
&& inlineType(type.properties.name).ts === 'string') {
|
||||||
return { ts: 'DeviceDescriptorEntry', scheme: 'tObject()', optional };
|
return { ts: 'DeviceDescriptorEntry', scheme: 'tObject()', optional };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue