-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration Files
JSILc allows you to control translation of your applications and libraries by providing one or more JSIL Configuration Files with the extension .jsilconfig.
- 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).
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. | |
AutoLoadConfigFiles | Boolean | true | If true, JSILc will automatically search for and load .jsilconfig files next to solutions and assemblies, as described above. |
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. | |
OutputDirectory | String | none | Specifies the location where all output JavaScript, Manifests and log files will be placed. |
Profile | String | automatic | Specifies the name of a specific Profile to use during translation. |
ProfileSettings | Dictionary | Specifies settings for the profile being used during translation. The default profile has no settings. | |
SolutionBuilder | Dictionary | See the 'Solution Builder Settings' section below. | |
UseDefaultProxies | Boolean | true | If true, JSILc will automatically load the default proxies library for the FrameworkVersion you've specified. If false, no default proxies library will be loaded and you must specify one yourself. This is useful if you are using a custom version of mscorlib. |
UseLocalProxies | Boolean | true | If true, JSILc will automatically scan each translated assembly for Proxies to apply during the translation process. If false, only Proxy libraries loaded explicitly using the Proxies setting (below, in Assembly Settings) will be used. |
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. |
The assembly settings are stored as a nested JSON dictionary, with the following options:
Key | Type | Default Value | Description |
---|---|---|---|
Ignored | Array of Strings | [] | Specifies one or more regular expressions to apply to the filename and/or assembly name of all assemblies translated. If a match is found, that assembly is completely ignored during translation. |
Proxies | Array of Strings | [] | Specifies the location of one or more Proxy Assemblies to apply when translating your application. |
Stubbed | Array of Strings | [] | Specifies one or more regular expressions to apply to the filename and/or assembly name of all assemblies translated. If a match is found, code will not be generated for that assembly's methods; only type information and external method signatures will be produced. |
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. |
EliminateRedundantControlFlow | Boolean | true | If false, disables elimination of redundant control flow. This pass is primarily responsible for eliminating break, continue and goto statements that cannot possibly be reached within a given function during normal execution. |
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. |
EliminateTemporaries | Boolean | true | If false, disables elimination of temporary variables. Temporary variable elimination is based on static analysis of your program, so bugs may cause it to eliminate variables in a way that changes the behavior of your program or makes it dramatically slower. |
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. |
The solution builder is responsible for building any .sln files passed to JSILc on the command line and producing a list of the project's outputs. The solution builder settings are stored as a nested JSON dictionary, with the following options:
Key | Type | Default Value | Description |
---|---|---|---|
Configuration | String | MSBuild default | Specifies the specific configuration of your solution(s) to build. |
Platform | String | MSBuild default | Specifies the specific platform of your solution(s) to build. |
Target | String | Build | Specifies the specific target of your solution(s) to build. Meaningful choices are probably Build and Rebuild |
LogVerbosity | String | Quiet | Specifies the verbosity of MSBuild log messages. Adjusting this can be useful when troubleshooting problems with MSBuild. Valid options are Quiet, Minimal, Normal, Detailed, and Diagnostic. |