Skip to content

Commit 9403d8a

Browse files
committed
fix(generate-code): #490 Fixed the escaping of special characters in the Listener exampleCode for the code generation module.
1 parent 27297ac commit 9403d8a

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

changeLog_ioGame.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
11
文档与日志
22
- [框架版本更新日志](https://iohao.github.io/game/docs/version_log)
33
- [ioGame 真.轻量级网络编程框架 - 在线使用文档 ](https://game.iohao.com/)
4-
- <a target="_blank" href='https://app.codacy.com/gh/iohao/ioGame/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade'><img src="https://app.codacy.com/project/badge/Grade/4981fff112754686baad7442be998b17" alt="github star"/></a>
54

65

76
> ioGame 每月会发 1 ~ 2 个版本,通常在大版本内升级总是兼容的,如 21.1 升级到任意 21.x 的高版本。
87
8+
9+
### 2025-07-19 - v21.29
10+
https://github.com/iohao/ioGame/releases/tag/21.29
11+
12+
**Version update summary**
13+
14+
> 1. [#473](https://github.com/iohao/ioGame/issues/473) fix(core): Change the method name from DataSelfEncode getEncodeData to encodeData to avoid JSON serialization.
15+
> 2. fix(doc): [#459](https://github.com/iohao/ioGame/issues/459) Supporting the referencing of classes within a JAR file in a multi-module Gradle environment.
16+
> 3. feat(generate-code): [#452](https://github.com/iohao/ioGame/issues/452)
17+
> 4. fix(generate-code): broadcast_action_example_action.txt、broadcast_action_example.txt
18+
> 5. feat(external): [#469](https://github.com/iohao/ioGame/issues/469) Add HttpFallbackHandler to determine if it's a WebSocket upgrade request.
19+
> 6. perf(doc): Pre-create the Pb for the BroadcastDocument dataClass.
20+
21+
**[other updates]**
22+
23+
Upgrade reactor-netty 1.2.7、commons-io 2.19.0
24+
25+
26+
### 2025-06-17 - v21.28
27+
https://github.com/iohao/ioGame/releases/tag/21.28
28+
29+
**Version update summary**
30+
31+
> 1. feat(room): The room supports convenient operations.
32+
> 2. Deprecated RoomStatusEnum.
33+
> 3. feat(room): The room supports convenient broadcastRange.
34+
> 4. docs(all): Update documentation link (https://iohao.github.io/game).
35+
> 5. [#451](https://github.com/iohao/ioGame/issues/451) Refactor the usage documentation to use the new access address: https://iohao.github.io/game/ .
36+
37+
------
38+
39+
**[other updates]**
40+
41+
```xml
42+
<netty.version>4.1.122.Final</netty.version>
43+
```
44+
945
------
1046

1147
### 2025-05-09 - v21.27

widget/generate-code/src/main/java/com/iohao/game/action/skeleton/core/doc/CsharpDocumentGenerate.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ protected void generateAction(IoGameDocument ioGameDocument) {
9999
@Override
100100
protected void generateBroadcast(IoGameDocument ioGameDocument) {
101101
Template template = ofTemplate(DocumentGenerateKit.broadcastActionTemplatePath);
102-
// template.binding("using", String.join("\n", this.broadcastImportList));
103102
template.binding("namespace", this.namespace);
104103

105104
new BroadcastGenerate()

widget/generate-code/src/main/java/com/iohao/game/action/skeleton/core/doc/DocumentGenerateAbout.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private void init() {
7070
Configuration cfg = Configuration.defaultConfiguration();
7171
gt = new GroupTemplate(resourceLoader, cfg);
7272
gt.registerFunction("codeEscape", new ExampleCodeEscape());
73+
gt.registerFunction("originalCode", new ExampleOriginalCode());
7374
gt.registerFunction("snakeName", new SnakeName());
7475
}
7576

@@ -110,6 +111,18 @@ public Object call(Object[] paras, Context ctx) {
110111
}
111112
}
112113

114+
class ExampleOriginalCode implements org.beetl.core.Function {
115+
@Override
116+
public Object call(Object[] paras, Context ctx) {
117+
return Optional.ofNullable(paras[0])
118+
.map(Object::toString)
119+
.map(str -> {
120+
// Escape
121+
return str.replace("&lt;", "<").replace("&gt;", ">");
122+
}).orElse("");
123+
}
124+
}
125+
113126
class SnakeName implements org.beetl.core.Function {
114127
@Override
115128
public Object call(Object[] paras, Context ctx) {

widget/generate-code/src/main/resources/generate/csharp/broadcast_action.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace ${namespace}
4444
<% if (o.exampleCodeAction == null) { %>
4545
IoGameSetting.GameGameConsole.Log($"{mergeTitle}, {title}");
4646
<% } else { %>
47-
${o.exampleCodeAction}
47+
${originalCode(o.exampleCodeAction)}
4848
IoGameSetting.GameGameConsole.Log($"{mergeTitle}, {title}, {value}");
4949
<%}%>
5050
});

0 commit comments

Comments
 (0)