ScriptGlobalOptions class contains options that cannot be customized per-script and apply globally to all Script instances in the application.
Access
Global options are accessed via the static propertyScript.GlobalOptions:
Properties
Gets or sets the platform abstraction to use.This controls how SolarSharp interacts with the underlying platform for file I/O, environment detection, and other platform-specific operations.
Gets or sets the custom converters for CLR-to-Lua type conversions.Allows you to define custom conversion logic for specific types when passing objects between C# and Lua.
Gets or sets whether interpreter exceptions should be re-thrown as nested exceptions.When true, exceptions from Lua are wrapped in an outer exception that preserves the CLR stack trace. When false, the original exception is thrown directly.
Gets or sets an enum that controls behavior when a symbol (method, property, userdata) is not found in a userdata’s descriptor.For example, when set to
UpperFirstLetter and Lua code calls someuserdata.someMethod(), SolarSharp will also try someuserdata.SomeMethod().Flags can be combined:None: No fuzzy matchingUpperFirstLetter: Try with first letter uppercaseCamelify: Try converting snake_case to camelCasePascalCase: Try converting to PascalCase
Example Usage
Custom Type Converters
Enhanced Error Handling
Fuzzy Symbol Matching
Custom Platform Accessor
Application-Wide Configuration
Important Notes
-
Global Scope: Changes to
ScriptGlobalOptionsaffect ALL scripts in the application, including existing ones. - Thread Safety: Be careful when modifying global options from multiple threads. It’s recommended to configure them once at application startup.
- Custom Converters: Custom converters are global and permanent once registered. Consider the impact on all scripts.
- Platform Accessor: Changing the platform accessor at runtime can have unpredictable effects. Set it once at startup.
- Fuzzy Matching Performance: Fuzzy symbol matching adds a small performance overhead when methods/properties are not found. Disable it for performance-critical scenarios where you control the naming.
Default Values
When aScript is created, ScriptGlobalOptions has these defaults: