Skip to content
Taritsyn edited this page Sep 1, 2024 · 45 revisions

JavaScriptEngineSwitcher.Jint contains a JintJsEngine adapter (wrapper for the Jint version 4.0.2).

Engine settings

You can specify a settings of JS engine during its registration:

engineSwitcher.EngineFactories
    .AddJint(new JintSettings
    {
        StrictMode = true
    })
    ;

If you manually create an instance of JS engine, then you can pass settings via the constructor:

IJsEngine engine = new JintJsEngine(
    new JintSettings
    {
        StrictMode = true
    }
);

Consider in detail properties of the JintSettings class:

Property name Data type Default value Description
AllowReflection Boolean false

Flag for whether to allow the usage of reflection API in the script code.

This affects Object.GetType, Exception.GetType, Exception.TargetSite and Delegate.Method.

DebuggerBreakCallback DebugEventHandler delegate null Debugger break callback.
DebuggerStatementHandlingMode JsDebuggerStatementHandlingMode enumeration Ignore Handling mode for script debugger statements. Can take the following values:
  • Ignore. No action will be taken when encountering a debugger statement.
  • Clr. debugger statements will trigger debugging through the System.Diagnostics.Debugger class.
  • Script. debugger statements will trigger a break in Jint's DebugHandler. See the DebuggerBreakCallback configuration property.
DebuggerStepCallback DebugEventHandler null Debugger step callback.
DisableEval Boolean false Flag for whether to disable calls of eval function with custom code and Function constructors taking function code as string.
EnableDebugging Boolean false Flag for whether to enable debug mode.
LocalTimeZone TimeZoneInfo TimeZoneInfo.Local Local time zone for the Date objects in the script.
MaxArraySize UInt32 UInt32.MaxValue Maximum size for JavaScript array.
MaxJsonParseDepth Int32 64 Maximum depth allowed when parsing JSON data using the JSON.parse static method.
MaxRecursionDepth Int32 -1 Maximum allowed depth of recursion:
  • -1 - recursion without limits;
  • N - one scope function can be called no more than N times.
MaxStatements Int32 0 Maximum number of statements.
MemoryLimit Int64 0 Current memory limit for a engine in bytes.
RegexTimeoutInterval Nullable<TimeSpan> null

Timeout interval for regular expressions.

If the value of this property is null, then the value of regular expression timeout interval are taken from the TimeoutInterval property.

StrictMode Boolean false Flag for whether to allow run the script in strict mode.
TimeoutInterval TimeSpan TimeSpan.Zero Interval to wait before the script execution times out.