Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(dotnet): treat file as a reserved word (#5960)

Darío Kondratiukbc6dc1d10811
diff --git a/utils/doclint/generateDotnetApi.js b/utils/doclint/generateDotnetApi.js
index f2cf2aea32..5e74542b4f 100644
--- a/utils/doclint/generateDotnetApi.js
+++ b/utils/doclint/generateDotnetApi.js
@@ -40,6 +40,13 @@ let documentation;
/** @type {Map<string, string>} */
let classNameMap;
+/** @type {Map<string, string>} */
+const customTypeNames = new Map([
+ ['domcontentloaded', 'DOMContentLoaded'],
+ ['networkidle', 'NetworkIdle'],
+ ['File', 'FilePayload'],
+]);
+
{
const typesDir = process.argv[2] || '../generate_types/csharp/';
let checkAndMakeDir = (path) => {
@@ -179,17 +186,13 @@ let classNameMap;
enumTypes.forEach((values, name) =>
innerRenderElement('enum', name, null, (out) => {
- const knownEnumValues = new Map([
- ['domcontentloaded', 'DOMContentLoaded'],
- ['networkidle', 'NetworkIdle']
- ]);
out.push('\tUndefined = 0,');
values.forEach((v, i) => {
// strip out the quotes
v = v.replace(/[\"]/g, ``)
let escapedName = v.replace(/[-]/g, ' ')
.split(' ')
- .map(word => knownEnumValues.get(word) || word[0].toUpperCase() + word.substring(1)).join('');
+ .map(word => customTypeNames.get(word) || word[0].toUpperCase() + word.substring(1)).join('');
out.push(`\t[EnumMember(Value = "${v}")]`);
out.push(`\t${escapedName},`);
@@ -341,6 +344,8 @@ function generateNameDefault(member, name, t, parent) {
if (attemptedName.endsWith('s')
&& !["properties", "httpcredentials"].includes(attemptedName.toLowerCase()))
attemptedName = attemptedName.substring(0, attemptedName.length - 1);
+ if (customTypeNames.get(attemptedName))
+ attemptedName = customTypeNames.get(attemptedName);
let probableType = additionalTypes.get(attemptedName);
if ((probableType && typesDiffer(t, probableType))
|| (["Value"].includes(attemptedName))) {