-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCSTOJSOptions.cs
More file actions
232 lines (216 loc) · 6.59 KB
/
CSTOJSOptions.cs
File metadata and controls
232 lines (216 loc) · 6.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
using System.Collections.Generic;
using System.Text;
namespace CSharpToJavaScript;
/// <summary>
/// Options for <see cref="CSTOJS" />.
/// </summary>
public class CSTOJSOptions
{
/// <summary>
/// Debug. When set to true prints additional info to console, cs lines to js file.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option Debug="false" />
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>false</c>
/// </value>
public bool Debug { get; set; } = false;
/// <summary>
/// Getting diagnostics is expensive.
/// Enable if you want faster translation.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option DisableDiagnostics="false" />
/// </para>
/// </blockquote>
/// <para><see href = "https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.semanticmodel.getdiagnostics?view=roslyn-dotnet-4.13.0#remarks"><em>See remarks.</em></see></para>
/// </remarks>
/// <value>
/// Default: <c>false</c>
/// </value>
public bool DisableDiagnostics { get; set; } = false;
/// <summary>
/// Self-explanatory, Use <c>var</c> over <c>let</c>.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option UseVarOverLet="false" />
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>false</c>
/// </value>
public bool UseVarOverLet { get; set; } = false;
/// <summary>
/// Keep Brace <c>{</c> on the same line.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5><para>Note: It is better write from the start in c#, then using this option.</para></blockquote>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option KeepBraceOnTheSameLine="false" />
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>false</c>
/// </value>
public bool KeepBraceOnTheSameLine { get; set; } = false;
/// <summary>
/// Self-explanatory, Normalize Whitespace.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5><para>Note: If using with <see cref="CSTOJSOptions.KeepBraceOnTheSameLine" />. Normalization running before <see cref="CSTOJSOptions.KeepBraceOnTheSameLine" />.</para></blockquote>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option NormalizeWhitespace="false" />
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>false</c>
/// </value>
public bool NormalizeWhitespace { get; set; } = false;
/// <summary>
/// Translate current <see cref="FileData" />. If false, walker will not be called.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option TranslateFile="true" />
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>true</c>
/// </value>
public bool TranslateFile { get; set; } = true;
/// <summary>
/// Make properties enumerable, needed if you want to use JSON.stringify.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option MakePropertiesEnumerable="false" />
/// </para>
/// </blockquote>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// Note, class must have constructor!
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>false</c>
/// </value>
public bool MakePropertiesEnumerable { get; set; } = false;
/// <summary>
/// Enable module export/import. Three-state value.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option EnableModules="1" />
/// </para>
/// </blockquote>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// Note, for imports a filename needs to be supplied.
/// </para>
/// </blockquote>
/// <blockquote class="IMPORTANT"><h5>IMPORTANT</h5>
/// <para>
/// Only public classes are exported/imported.
/// </para>
/// </blockquote>
/// <para>
/// Possible values: <br />
/// 0 = Disable modules. No exports or imports. <br />
/// 1 = Automatic. If 2 or more files are supplied, enable modules. <br />
/// 2 = Enable modules. <br />
/// </para>
/// </remarks>
/// <value>
/// Default: <c>1</c>
/// </value>
public byte EnableModules { get; set; } = 1;
/// <summary>
/// Array of custom names to convert.
/// </summary>
/// <remarks>Example: <c>new(){["Console"] = "console"}</c>. Will convert "Console" to "console".
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option CustomCSNamesToJS="Console-console,WriteLine-log" />
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>new()</c>
/// </value>
public Dictionary<string, string> CustomCSNamesToJS { get; set; } = new();
/// <summary>
/// Custom directory path to the DLLs.
/// </summary>
/// <remarks>
/// <para>
/// Searches for any DLL in the specified directory and then imports references into compilation.
/// </para>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option CustomPathToDLLs="./bin" />
/// </para>
/// </blockquote>
/// <blockquote class="IMPORTANT"><h5>IMPORTANT</h5>
/// <para>
/// The option needs to be specified in the first file or globally if using CSTOJS_CLI.
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>./bin/</c>
/// </value>
public string CustomPathToDLLs { get; set; } = "./bin/";
/// <summary>
/// Add a <see cref="StringBuilder" /> to the front of a javascript file.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option AddSBAtTheTop="//this is comment" />
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>new()</c>
/// </value>
public StringBuilder AddSBAtTheTop { get; set; } = new();
/// <summary>
/// Add a <see cref="StringBuilder" /> to the end of a javascript file.
/// </summary>
/// <remarks>
/// <blockquote class="NOTE"><h5>NOTE</h5>
/// <para>
/// cstojs_options.xml: <Option AddSBAtTheBottom="//this is comment" />
/// </para>
/// </blockquote>
/// </remarks>
/// <value>
/// Default: <c>new()</c>
/// </value>
public StringBuilder AddSBAtTheBottom { get; set; } = new();
/// <summary>
/// Creates new default options. See <see cref="CSTOJSOptions" />.
/// </summary>
public CSTOJSOptions()
{
}
}