chore(dotnet): fix generator escaping, make script lf-friendly (#6606)

This commit is contained in:
Pavel Feldman 2021-05-16 09:58:40 -07:00 committed by GitHub
parent fd1e62b8c5
commit 333397c0e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -204,6 +204,15 @@ const customTypeNames = new Map([
if (process.argv[3] !== "--skip-format") {
// run the formatting tool for .net, to ensure the files are prepped
execSync(`dotnet format -f "${typesDir}" --include-generated --fix-whitespace`);
if (process.platform !== 'win32') {
for (const folder of [typesDir, path.join(typesDir, 'Models'), path.join(typesDir, 'Enums'), path.join(typesDir, 'Extensions'), path.join(typesDir, 'Constants')])
for (const name of fs.readdirSync(folder)) {
if (!name.includes('\.cs'))
continue;
const content = fs.readFileSync(path.join(folder, name), 'utf-8');
fs.writeFileSync(path.join(folder, name), content.split('\r\n').join('\n'));
}
}
}
}

View file

@ -77,7 +77,7 @@ function _wrapCode(lines) {
let i = 0;
let out = [];
for (let line of lines) {
line = line.replace('<', '&lt;').replace('>', '&gt;');
line = line.replace(/[&]/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
if (i < lines.length - 1)
line = line + "<br/>";
out.push(line);