-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
…de comments (#4785) * fix(csharp): XML encode contents of <summary> and <example><code> code comments
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Writer } from ".."; | ||
|
||
export class DocXmlWriter { | ||
writer: Writer; | ||
constructor(writer: Writer) { | ||
this.writer = writer; | ||
} | ||
|
||
public writeLine(text?: string): void { | ||
this.writer.writeLine(`/// ${text}`); | ||
} | ||
|
||
public writePrefix(): this { | ||
this.writer.write("/// "); | ||
return this; | ||
} | ||
|
||
public writeOpenNode(nodeName: string): void { | ||
this.writeLine(`<${nodeName}>`); | ||
} | ||
|
||
public writeCloseNode(nodeName: string): void { | ||
this.writeLine(`</${nodeName}>`); | ||
} | ||
|
||
public writeNode(nodeName: string, text: string): void { | ||
this.writeOpenNode(nodeName); | ||
this.writeMultiline(text); | ||
this.writeCloseNode(nodeName); | ||
} | ||
|
||
public writeNodeWithEscaping(nodeName: string, text: string): void { | ||
this.writeOpenNode(nodeName); | ||
this.writeMultilineWithEscaping(text); | ||
this.writeCloseNode(nodeName); | ||
} | ||
|
||
public writeMultiline(text: string): void { | ||
text.trim() | ||
.split("\n") | ||
.forEach((line) => { | ||
this.writeLine(line); | ||
}); | ||
} | ||
|
||
public writeMultilineWithEscaping(text: string): void { | ||
text = this.escapeXmlDocContent(text); | ||
this.writeMultiline(text); | ||
} | ||
|
||
private escapeXmlDocContent(text: string): string { | ||
return text.replaceAll("<", "<").replaceAll(">", ">"); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.