mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore(dotnet): treat file as a reserved word (#5960)
Avoid collision with System.IO.File and unify handling reserved file names and enum values.
This commit is contained in:
parent
0943af2806
commit
bc6dc1d108
@ -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))) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user