Skip to content

Commit aebea36

Browse files
Merge branch 'master' into wt-jengine-util
2 parents 373c4b6 + ae76c38 commit aebea36

518 files changed

Lines changed: 998 additions & 105 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codacy.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Codacy configuration file
2+
# Only scan JEngine code, ignore 3rd party packages and samples
3+
4+
exclude_paths:
5+
# Ignore all 3rd party packages
6+
- "UnityProject/Packages/**"
7+
# Ignore samples
8+
- "UnityProject/Assets/Samples/**"
9+
# Ignore HybridCLR generated code
10+
- "UnityProject/Assets/HybridCLRGenerate/**"
11+
# Ignore Obfuz (3rd party obfuscation tool)
12+
- "UnityProject/Assets/Obfuz/**"
13+
14+
include_paths:
15+
# But include JEngine packages
16+
- "UnityProject/Packages/com.jasonxudeveloper.jengine*/**"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
applyTo: "**"
3+
---
4+
5+
# Code Review Instructions for JEngine
6+
7+
## Priority Checks
8+
9+
### 1. Unity Editor Domain Reload
10+
Editor code with static state MUST handle domain reloads:
11+
- Static fields reset to default on recompile
12+
- Use `SessionState` for session-persistent data
13+
- Use `EditorPrefs` for cross-session data
14+
15+
### 2. Resource Management
16+
Check for proper cleanup:
17+
- ScriptableObjects created with `CreateInstance` must be destroyed
18+
- Event handlers must be unsubscribed
19+
- Use `Object.Destroy` (not `DestroyImmediate`) for most cases
20+
21+
### 3. Async Patterns
22+
Verify async code uses:
23+
- `UniTask` (not `System.Threading.Tasks.Task`)
24+
- Proper `await` usage
25+
- No blocking calls (`Result`, `Wait()`)
26+
27+
### 4. Thread Safety
28+
For state accessed across Unity callbacks:
29+
- Use `volatile` for simple flags
30+
- Consider thread-safe patterns for complex state
31+
32+
### 5. Namespace Compliance
33+
- Runtime: `JEngine.Core.*`
34+
- Editor: `JEngine.Core.Editor.*`
35+
- No namespace = flag for review
36+
37+
## Common Issues to Flag
38+
39+
- Missing XML documentation on public APIs
40+
- Direct `Debug.Log` (should use proper logging)
41+
- `Task` instead of `UniTask`
42+
- Static state in Editor without domain reload handling
43+
- Missing null checks for Unity objects
44+
- `DestroyImmediate` without clear justification
45+
46+
## Suggestions Format
47+
48+
When suggesting code changes:
49+
1. Explain the issue clearly
50+
2. Provide complete code suggestion
51+
3. Reference Unity/JEngine conventions
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
applyTo: "**/*.cs"
3+
---
4+
5+
# JEngine C# Coding Instructions
6+
7+
## Project Context
8+
9+
JEngine is a Unity hot update framework using HybridCLR for runtime C# execution and YooAsset for resource management.
10+
11+
## Code Style
12+
13+
### Namespaces
14+
- Runtime code: `JEngine.Core` or `JEngine.Core.*`
15+
- Editor code: `JEngine.Core.Editor` or `JEngine.Core.Editor.*`
16+
- Hot update code: `HotUpdate.Code`
17+
18+
### Async/Await
19+
Always use `UniTask` instead of `Task`:
20+
```csharp
21+
// Good
22+
public async UniTask DoSomethingAsync() { }
23+
24+
// Bad
25+
public async Task DoSomethingAsync() { }
26+
```
27+
28+
### XML Documentation
29+
Document all public members:
30+
```csharp
31+
/// <summary>
32+
/// Description of what this does.
33+
/// </summary>
34+
public void MyMethod() { }
35+
```
36+
37+
## Editor Scripts
38+
39+
### Domain Reload Handling
40+
Unity reloads the domain on recompile. Static state resets. For persistent state:
41+
```csharp
42+
// Use SessionState for editor session persistence
43+
SessionState.SetBool("MyKey", value);
44+
bool value = SessionState.GetBool("MyKey", defaultValue);
45+
```
46+
47+
### Resource Cleanup
48+
Always clean up ScriptableObjects and event handlers:
49+
```csharp
50+
static MyClass()
51+
{
52+
EditorApplication.quitting += OnQuitting;
53+
}
54+
55+
private static void OnQuitting()
56+
{
57+
EditorApplication.quitting -= OnQuitting;
58+
if (_instance != null)
59+
{
60+
Object.Destroy(_instance);
61+
_instance = null;
62+
}
63+
}
64+
```
65+
66+
### Thread Safety
67+
For properties accessed from callbacks:
68+
```csharp
69+
private static volatile bool _flag;
70+
public static bool Flag => _flag;
71+
```
72+
73+
## Encryption Code
74+
75+
Three algorithms supported: XOR, AES, ChaCha20
76+
- Config classes in `Runtime/Encrypt/Config/`
77+
- Bundle encryption in `Runtime/Encrypt/Bundle/`
78+
- Manifest encryption in `Runtime/Encrypt/Manifest/`
79+
80+
## Common Patterns
81+
82+
### ScriptableObject Singletons
83+
```csharp
84+
public class MyConfig : ScriptableObject
85+
{
86+
private static MyConfig _instance;
87+
public static MyConfig Instance => _instance ??= CreateInstance<MyConfig>();
88+
}
89+
```
90+
91+
### InitializeOnLoad
92+
```csharp
93+
[InitializeOnLoad]
94+
internal class MyEditorClass
95+
{
96+
static MyEditorClass()
97+
{
98+
// Runs on editor load and domain reload
99+
}
100+
}
101+
```
102+
103+
## Review Focus Areas
104+
105+
When reviewing JEngine code, check:
106+
1. UniTask usage (not Task)
107+
2. Domain reload handling in Editor code
108+
3. Resource cleanup (ScriptableObjects, events)
109+
4. Thread safety for callback-accessed state
110+
5. Proper namespace usage

CLAUDE.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# JEngine Development Guidelines
2+
3+
## Project Overview
4+
5+
JEngine is a Unity framework for **runtime hot updates** in games. It enables developers to update game code and assets without requiring users to download new builds.
6+
7+
- **Unity Version**: 2022.3+
8+
- **Primary Language**: C#
9+
- **License**: MIT
10+
11+
## Architecture
12+
13+
### Package Structure
14+
15+
```
16+
Packages/
17+
├── com.jasonxudeveloper.jengine.core/ # Main framework
18+
│ ├── Runtime/ # Runtime code
19+
│ │ ├── Bootstrap.cs # Main entry point
20+
│ │ ├── Encrypt/ # Encryption subsystem
21+
│ │ └── Update/ # Update management
22+
│ └── Editor/ # Editor tools
23+
└── com.code-philosophy.hybridclr/ # HybridCLR integration
24+
25+
Assets/
26+
├── HotUpdate/ # Hot-updateable code
27+
│ └── Code/EntryPoint.cs # Hot update entry point
28+
└── Samples/ # Sample implementations
29+
```
30+
31+
### Key Dependencies
32+
33+
| Package | Purpose |
34+
|---------|---------|
35+
| HybridCLR | Runtime C# code execution |
36+
| YooAsset | Runtime resource management |
37+
| UniTask | Async/await support |
38+
| Nino | High-performance serialization |
39+
| Obfuz | Code obfuscation |
40+
41+
## Coding Conventions
42+
43+
### Namespaces
44+
45+
- Core framework: `JEngine.Core.*`
46+
- Editor code: `JEngine.Core.Editor.*`
47+
- Hot update code: `HotUpdate.Code`
48+
49+
### File Headers
50+
51+
All C# files should include the standard header:
52+
```csharp
53+
// FileName.cs
54+
//
55+
// Author:
56+
// JasonXuDeveloper <jason@xgamedev.net>
57+
//
58+
// Copyright (c) 2025 JEngine
59+
//
60+
// [MIT License...]
61+
```
62+
63+
### Naming Conventions
64+
65+
- **Classes/Interfaces**: PascalCase (interfaces prefixed with `I`)
66+
- **Methods/Properties**: PascalCase
67+
- **Private fields**: camelCase or `_camelCase`
68+
- **Constants**: PascalCase
69+
- **Enums**: PascalCase for both type and members
70+
71+
### Async Patterns
72+
73+
Use `UniTask` for async operations, not `System.Threading.Tasks.Task`:
74+
```csharp
75+
public async UniTask<bool> LoadAssetAsync() { }
76+
```
77+
78+
### XML Documentation
79+
80+
Document all public APIs with XML comments:
81+
```csharp
82+
/// <summary>
83+
/// Brief description of the method.
84+
/// </summary>
85+
/// <param name="param">Parameter description.</param>
86+
/// <returns>Return value description.</returns>
87+
public ReturnType MethodName(ParamType param) { }
88+
```
89+
90+
## Important Patterns
91+
92+
### Encryption Architecture
93+
94+
JEngine supports three encryption algorithms:
95+
- **XOR** (`EncryptionOption.Xor`) - Fast, simple
96+
- **AES** (`EncryptionOption.Aes`) - Moderate security
97+
- **ChaCha20** (`EncryptionOption.ChaCha20`) - High security
98+
99+
Each has implementations for bundles and manifests in `Runtime/Encrypt/`.
100+
101+
### ScriptableObject Configuration
102+
103+
Use `ScriptableObject` for runtime configuration:
104+
```csharp
105+
public abstract class ConfigBase<T> : ScriptableObject where T : ConfigBase<T>
106+
{
107+
public static T Instance { get; }
108+
}
109+
```
110+
111+
### Editor Scripts
112+
113+
- Use `[InitializeOnLoad]` for editor initialization
114+
- Handle Unity domain reloads properly (state resets on recompile)
115+
- Use `SessionState` or `EditorPrefs` for persistent editor state
116+
- Clean up resources in `EditorApplication.quitting`
117+
118+
### Thread Safety
119+
120+
For properties accessed across callbacks:
121+
```csharp
122+
private static volatile bool _flag;
123+
public static bool Flag => _flag;
124+
```
125+
126+
## Testing
127+
128+
- Tests are in `Assets/Tests/` using Unity Test Framework
129+
- Run tests via Unity Test Runner (Window > General > Test Runner)
130+
- Editor code should check `TestRunnerCallbacks.IsRunningTests` to avoid interfering with test execution
131+
132+
## Build & Deployment
133+
134+
### Target Platforms
135+
136+
- `Standalone` - Desktop builds
137+
- `WeChat` / `Douyin` / `Alipay` / `TapTap` - Mini-game platforms
138+
139+
### Hot Update Workflow
140+
141+
1. Build base application with HybridCLR
142+
2. Update code in `Assets/HotUpdate/`
143+
3. Build hot update DLLs
144+
4. Deploy to CDN server
145+
146+
## Common Tasks
147+
148+
### Adding New Encryption
149+
150+
1. Create config class in `Runtime/Encrypt/Config/`
151+
2. Implement bundle encryption in `Runtime/Encrypt/Bundle/`
152+
3. Implement manifest encryption in `Runtime/Encrypt/Manifest/`
153+
4. Add to `EncryptionOption` enum
154+
5. Update `EncryptionMapping` class
155+
156+
### Adding Editor Features
157+
158+
1. Create class in `Editor/` with appropriate namespace
159+
2. Use `[InitializeOnLoad]` for auto-initialization
160+
3. Add menu items via `[MenuItem]` attribute
161+
4. Handle domain reloads if maintaining state
162+
163+
## Code Review Checklist
164+
165+
- [ ] Follows namespace conventions
166+
- [ ] Has appropriate XML documentation
167+
- [ ] Uses UniTask for async (not Task)
168+
- [ ] Handles Unity domain reloads in Editor code
169+
- [ ] No direct `Debug.Log` in production code (use proper logging)
170+
- [ ] Thread-safe where needed (Editor callbacks, etc.)
171+
- [ ] Proper resource cleanup (ScriptableObjects, event handlers)

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ JEngine is a powerful Unity framework that enables **runtime hot updates** for y
3030
| `0.7.x` | 🔒 Legacy | Most popular 2022 version (no longer maintained) |
3131
| `0.6.x` | 🔒 Legacy | Complete with full documentation (no longer maintained) |
3232
| `0.5.x` | 🔒 Legacy | Used by some commercial projects (no longer maintained) |
33-
| `development` | 🔧 Development | Active development branch - PRs welcome! |
3433

3534
## 📦 Packages
3635

README_zh_cn.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ JEngine是针对Unity开发者设计的**开箱即用**的框架,封装了强
3434
| `0.7.x` | 🔒 历史版本 | 2022年最热门版本(不再维护) |
3535
| `0.6.x` | 🔒 历史版本 | 内容完善,文档视频充足(不再维护) |
3636
| `0.5.x` | 🔒 历史版本 | 部分商业项目在使用(不再维护) |
37-
| `development` | 🔧 开发分支 | 活跃开发分支 - 欢迎PR! |
3837

3938
## 📦 功能包
4039

UnityProject/Assets/Samples/YooAsset/2.3.16.meta renamed to UnityProject/Assets/Samples/YooAsset/2.3.18.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityProject/Assets/Samples/YooAsset/2.3.16/Extension Sample.meta renamed to UnityProject/Assets/Samples/YooAsset/2.3.18/Extension Sample.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityProject/Assets/Samples/YooAsset/2.3.16/Extension Sample/Editor.meta renamed to UnityProject/Assets/Samples/YooAsset/2.3.18/Extension Sample/Editor.meta

File renamed without changes.

UnityProject/Assets/Samples/YooAsset/2.3.16/Extension Sample/Editor/ClearBuildCache.meta renamed to UnityProject/Assets/Samples/YooAsset/2.3.18/Extension Sample/Editor/ClearBuildCache.meta

File renamed without changes.

0 commit comments

Comments
 (0)