Overview
SolarSharp maintains high API compatibility with MoonSharp while providing:- Performance improvements across the interpreter and parser
- Modern C# features from .NET Standard 2.1
- Bug fixes and improved stability
- Continued maintenance and updates
Key Differences from MoonSharp
Namespace Changes
The primary namespace change:Target Framework
SolarSharp requires .NET Standard 2.1 or higher:- MoonSharp: .NET Standard 2.0, .NET Framework 4.x
- SolarSharp: .NET Standard 2.1+, .NET 5+, .NET Framework 4.7.2+
Migration Steps
Step 1: Update Dependencies
Remove MoonSharp and add SolarSharp:Step 2: Update Using Directives
Replace all MoonSharp namespace references:Step 3: Update Assembly References
If you have assembly attributes or references:Step 4: Test Core Functionality
The core API remains the same:API Compatibility
Core Classes
These classes work identically in SolarSharp:Script- Main scripting classLuaValue- Lua value wrapperTable- Lua table implementationClosure- Lua function/closureUserData- CLR object wrapper
Example: Basic Script Execution
UserData Registration
UserData registration is identical:Coroutines
Coroutine handling remains unchanged:Performance Improvements
SolarSharp includes several performance enhancements:Parser Performance
- Faster Lua code parsing
- Reduced memory allocations during parsing
- Improved bytecode generation
Interpreter Performance
- Optimized instruction execution
- Better memory management
- Faster table operations
Benchmarking Your Migration
To verify performance improvements:Bug Fixes and Improvements
SolarSharp includes fixes for various MoonSharp issues:- Improved error messages and stack traces
- Better handling of edge cases in string operations
- Fixed memory leaks in certain scenarios
- Enhanced IL2CPP compatibility
Breaking Changes
Minimal Breaking Changes
SolarSharp maintains high compatibility, but there are a few considerations:-
.NET Standard 2.1 Requirement
- Requires .NET Framework 4.7.2+ or .NET Core 3.0+
- Unity 2021.2 or higher
-
Performance Statistics
- Some internal performance counters may have different names
-
Deprecated APIs
- Very few APIs were removed; most deprecated APIs still work with warnings
Unity-Specific Migration
Unity Version Requirements
Script Loader
Testing Your Migration
Create a Migration Test Suite
Common Migration Issues
Issue 1: Namespace Not Found
Problem:Issue 2: Target Framework Errors
Problem:Issue 3: Unity Version Compatibility
Problem:Gradual Migration Strategy
For large codebases, consider a gradual migration:Phase 1: Update Infrastructure
- Update build configurations
- Update package references
- Update using directives
Phase 2: Test Core Functionality
- Run existing test suites
- Verify critical paths
- Test integration points
Phase 3: Performance Validation
- Run performance benchmarks
- Profile memory usage
- Validate improvements
Phase 4: Full Deployment
- Deploy to staging environment
- Monitor for issues
- Gradual rollout to production
Support and Resources
- Performance Comparisons: https://braedonwooding.github.io/solarsharp/dev/bench/
- Source Code: https://github.com/BraedonWooding/solarsharp
- Issue Tracker: Report migration issues on GitHub
Next Steps
- Review Error Handling for improved error management
- Check out Unity Integration for Unity-specific features
- Explore API Reference for detailed documentation