Skip to content

Configuration Files

kevingadd edited this page Apr 14, 2012 · 25 revisions

JSILc allows you to control translation of your applications and libraries by providing one or more JSIL Configuration Files with the extension .jsilconfig.

Where JSILc finds configuration files

  • JSILc will automatically load any .jsilconfig files you pass it on the command line and apply them to all files translated during that session.
  • JSILc will search next to each .sln file translated for a matching .jsilconfig file: Foo.sln.jsilconfig. This configuration file will affect only that solution and its outputs.
  • JSILc will search next to each .exe or .dll file translated for a matching .jsilconfig file: Foo.dll.jsilconfig. This configuration file will affect that assembly and its dependencies. Note that this only works for assemblies being translated directly; you cannot set per-assembly configuration for dependencies.
  • A file named defaults.jsilconfig is automatically placed in the JSILc bin folder during the compile process. This file will be automatically loaded and applied during translation unless disabled (see ApplyDefaults below).

Configuration file format

A configuration file is a single JSON dictionary. The dictionary can contain the following setting keys:

Key Type Default Value Description
ApplyDefaults Boolean true If true, the default project settings will be applied from defaults.jsilconfig. Note that default project settings never override settings you have specified yourself.
Assemblies Dictionary See the 'Assembly Settings' section below.
FrameworkVersion Float automatic Allows you to specify which version of the .NET framework your application uses. Currently, JSILc only supports 3.5 and 4.0.
GenerateSkeletonsForStubbedAssemblies Boolean false If true, any stubbed assemblies translated will be produced as a 'skeleton', where the class definitions are replaced with JSIL.ImplementExternals calls and each method body is replaced with a throw statement. These skeletons can easily be copy-pasted to create your own JavaScript implementation of .NET libraries.
IncludeDependencies Boolean true If true, any assembly loaded for translation will be automatically scanned for dependent assemblies, and those dependent assemblies will be loaded and translated with it. This is necessary in order to produce working JavaScript, but you can disable it if you are certain that none of the dependent assemblies' types or functions are used.
Optimizer Dictionary See the 'Optimizer Settings' section below.
UseSymbols Boolean true If true, JSILc will search for .pdb/.mdb symbols for each loaded assembly, and use variable names from the symbols to improve the quality of the output JavaScript.
UseThreads Boolean true If true, JSILc will attempt to use multiple threads for translation. This typically provides a 25-50% speedup per-core when decompiling .NET assemblies and optimizing output JavaScript. Note, however, that this may increase memory usage or cause you to hit bugs in the compiler, so you may wish to try turning it off if you run into problems.

Assembly Settings

The assembly settings are stored as a nested JSON dictionary, with the following options:

Key Type Default Value Description
Boolean true

Optimizer Settings

The optimizer has a number of passes with specific purposes. By default, they are all enabled, but if your application is having strange issues, disabling one of these passes may fix it. If a problem in your application goes away when you disable any of these passes, please report an Issue! Note that disabling an optimization pass may break some applications because certain optimizations are required for working JavaScript to be produced. The optimizer settings are stored as a nested JSON dictionary, with the following options:

Key Type Default Value Description
CacheMethodSignatures Boolean true If false, disables the use of cached method signatures. Cached method signatures look like $sig.get(xxxx, and are used to speed up overloaded method calls.
EliminateStructCopies Boolean true If false, disables the struct copy elimination pass. This pass is based on static analysis of your program and may introduce subtle errors into code that uses structs.
SimplifyLoops Boolean true If false, disables the loop simplification pass. This pass attempts to convert the while loops contained in raw .NET IL back into for and do loops that better match the original C#.
SimplifyOperators Boolean true If false, disables the operator simplification pass. This pass attempts to simplify redundant binary and unary expressions (for example, by turning !!!false into !false.
Clone this wiki locally