Closed GoogleCodeExporter closed 9 years ago
Are you still not able to install later versions of SharpKit?
Original comment by DanelK...@gmail.com
on 21 Nov 2013 at 3:27
#324 was fixed with 5.2.7
I tried this issue in 5.2.7 and it is still there.
Original comment by Hultqvis...@gmail.com
on 21 Nov 2013 at 3:51
Cool, thanks for pointing it out.
Sebastian do you mind having a look?
Original comment by DanelK...@gmail.com
on 21 Nov 2013 at 4:39
I can't reproduce this issue. Please submit an minimalistic sample project.
Code used:
using SharpKit.JavaScript;
using SharpKit.Html;
using SharpKit.jQuery;
[assembly: JsType(NativeOperatorOverloads = true, TargetType = typeof(int))]
[assembly: JsExport(FilenameFormat = "res/{0}", CodeInjectionFilename =
"res/delegates.js", UseStrict = true, UseExactEquals = true,
DefaultFilenameAsCsFilename = true)]
[assembly: JsType(Mode = JsMode.Clr, NativeParams = false, NativeJsons = true)]
[assembly: JsMethod(TargetType = typeof(Nullable<>), TargetMethod =
"get_HasValue", Name = "!=null", OmitDotOperator = true, OmitParanthesis =
true)]
namespace SharpKitWebApp3
{
public class test
{
public void func()
{
var m = new MyObject() { Property1 = true, Propery2 = "hello" };
}
}
public class MyObject
{
public bool Property1 { get; set; }
public string Propery2 { get; set; }
}
}
Original comment by sebastia...@gmail.com
on 22 Nov 2013 at 6:26
This example works in 5.2.0 but triggers the bug in later versions.
using SharpKit.JavaScript;
//Trigger part 1/2
[assembly: JsType(NativeArrayEnumerator = true)]
namespace Issue325
{
[JsType(JsMode.Prototype)]
public class Test
{
public void func ()
{
//Trigger part 2/2: parameters
var t = new MyObject () {
PropertyA = 123,
};
}
}
[JsType (JsMode.Json)]
public class MyObject
{
public int PropertyA { get; set; }
}
}
Original comment by Hultqvis...@gmail.com
on 22 Nov 2013 at 8:37
The problem is:
[assembly: JsType(NativeArrayEnumerator = true)]
marks ALL classes classes with that (by default).
The logic with initializers is:
When a type have NativeArrayEnumerator = true, an array constructor will be
generated.
I'm not sure, but i think, this is by design. But when this should be fixed,
than this could be the solution: Check, if the inizializer statements are a
single expression per item, or a nassignment per item.
Dan-el, what do you think about this issue?
Original comment by sebastia...@gmail.com
on 23 Nov 2013 at 2:19
I think that it's very dangerous to mark JsNativeArrayEnumerator globally. It
should only be used on classes that need to behave like js arrays. Still, the
compiler shouldn't crash.
I suppose that if:
JsNativeArrayEnumerator=true and JsNativeEnumerator=false,
and
trying to initialize an object using initializer, we should initialize it as if
it's a standard class:
(function(){var $x = new MyObject(); x.Propery1="Hello"; return x;})();
What do you guys think? Is this your expected behavior?
Original comment by DanelK...@gmail.com
on 23 Nov 2013 at 8:44
I have reviewed my own code and removed the problematic use of the attribute.
It appears as if all is working fine.
From what I read in Sebastians comment the behaviour is a reasonable one.
An array constructor with parameters does not make sense - thus the original
crash.
The issue might then be limited to the naming or documentation of the
attribute. As it is written now it appears to only affect foreach statements,
whereas what it actually does is treating the c# object as an jsArray from
constructor to foreach loops.
Renaming the Attribute would be a breaking change but amending the summary is
something I could do.
Original comment by Hultqvis...@gmail.com
on 23 Nov 2013 at 9:54
"As it is written now it appears to only affect foreach statements"
That why i think, the compiler should not use this attribute on inizializers.
the compielr should check, if its the "initializerStatements" are a collection
of expressions (=array items), or assignment (=property inizializer).
Original comment by sebastia...@gmail.com
on 23 Nov 2013 at 11:51
The error should not occur anymore in the next version.
Original comment by sebastia...@gmail.com
on 25 Nov 2013 at 10:30
Original issue reported on code.google.com by
Hultqvis...@gmail.com
on 10 Nov 2013 at 6:06