Using the option outputFormatting in H5 configuration file, transpilled JS code can be directly minified.
This worked great with Bridge.Net and also with H5, but now I have a project whose H5 compilation raises the following exception:
[fail] [10:20:27] Error minifiying code. Saved output to [/path/to/tmp/file]
System.NullReferenceException: Object reference not set to an instance of an object.
H5 is actually using NUglify 1.20.7 for this operation. So using a minimal project, I tried to find the line(s) causing the NUglify exception(s), feeding it with H5's temp output.
What I found is that for an unknown reason, when I am using System.Linq functions, H5 define the type variable with a type named "?" instead of the real type name, like "Element" for example. When I manually change the "?" for the correct type name, then NUglify correctly proceeds the code ... until the next misnamed type parameter.
This problem does not occur in a systematic way, as for example in my minimal project, which is a copy-paste of several classes of the original project, type parameters are correctly transpilled. I have to admit that this project's H5 formatted result (so its beautified javascript output) is about 3.7 [Mb] (~ 32'000 lines length), which is why I'm using the minified option. I tried for example to use intermediate IEnumerable<Element> variables in C# code, but H5 keeps using "?" as type parameter value
Is there any size limit for H5 compiler? Am I doing something wrong? Any other idea?
Example illustrating transpilation error
Original C# code example (`rootContainer` is a `H5.Core.dom.HTMLDivElement` and is inherited) :
```C#
namespace ANamespace
{
public class AClassName : AParentClassName
{
public int Index
{
get
{
if (rootContainer.parentNode != null)
return rootContainer.parentElement.children.ToList().IndexOf(rootContainer);
else
return -1;
}
}
}
}
```
Javascript transpilation result of the H5 compiler (from temp saved output):
_Notice the `return ($t = ?,` in the beginning of the line 8._
```JavaScript showLineNumbers
H5.define("ANamespace.AClassName", {
inherits: [AParentClassName],
props: {
Index: {
get: function () {
var $t;
/*##|24,186,17|##*/if (/*##|24,186,21|##*/this.rootContainer.parentNode != /*##|24,186,49|##*/null) {
/*##|24,187,21|##*/return /*##|24,187,28|##*/($t = /*##|24,187,58|##*/?, System.Linq.Enumerable.from(/*##|24,187,79|##*/this.rootContainer.parentElement.children, $t).toList($t)).indexOf(/*##|24,187,125|##*/this.rootContainer);
} else {
/*##|24,189,21|##*/return /*##|24,189,28|##*/-1;
}
}
}
}
});
```
Using the option
outputFormatting
in H5 configuration file, transpilled JS code can be directly minified. This worked great with Bridge.Net and also with H5, but now I have a project whose H5 compilation raises the following exception: [fail] [10:20:27] Error minifiying code. Saved output to [/path/to/tmp/file] System.NullReferenceException: Object reference not set to an instance of an object.H5 is actually using NUglify 1.20.7 for this operation. So using a minimal project, I tried to find the line(s) causing the NUglify exception(s), feeding it with H5's temp output.
What I found is that for an unknown reason, when I am using System.Linq functions, H5 define the type variable with a type named "?" instead of the real type name, like "Element" for example. When I manually change the "?" for the correct type name, then NUglify correctly proceeds the code ... until the next misnamed type parameter.
This problem does not occur in a systematic way, as for example in my minimal project, which is a copy-paste of several classes of the original project, type parameters are correctly transpilled. I have to admit that this project's H5 formatted result (so its beautified javascript output) is about 3.7 [Mb] (~ 32'000 lines length), which is why I'm using the minified option. I tried for example to use intermediate
IEnumerable<Element>
variables in C# code, but H5 keeps using "?" as type parameter valueIs there any size limit for H5 compiler? Am I doing something wrong? Any other idea?
Example illustrating transpilation error
Original C# code example (`rootContainer` is a `H5.Core.dom.HTMLDivElement` and is inherited) : ```C# namespace ANamespace { public class AClassName : AParentClassName { public int Index { get { if (rootContainer.parentNode != null) return rootContainer.parentElement.children.ToList().IndexOf(rootContainer); else return -1; } } } } ``` Javascript transpilation result of the H5 compiler (from temp saved output): _Notice the `return ($t = ?,` in the beginning of the line 8._ ```JavaScript showLineNumbers H5.define("ANamespace.AClassName", { inherits: [AParentClassName], props: { Index: { get: function () { var $t; /*##|24,186,17|##*/if (/*##|24,186,21|##*/this.rootContainer.parentNode != /*##|24,186,49|##*/null) { /*##|24,187,21|##*/return /*##|24,187,28|##*/($t = /*##|24,187,58|##*/?, System.Linq.Enumerable.from(/*##|24,187,79|##*/this.rootContainer.parentElement.children, $t).toList($t)).indexOf(/*##|24,187,125|##*/this.rootContainer); } else { /*##|24,189,21|##*/return /*##|24,189,28|##*/-1; } } } } }); ```