IDE:Visual Studio 2015 Version:9.1.100.2127 + Actual Island version Target (If relevant): Windows 10/Linux Description:
Method.Invok(aInstance, Arguments) doesnt work as expected.
First Case:
When i call it on a record, it got crashed at runtime
Second Case:
When i call it on a generic record, it got crashed as well.
Expected Behavior:
It should always return the value of every variable, either record or class.
Actual Behavior:
Have a look: (First Case)
var auto : Auto;
Auto.P1 := 'Test';
Auto.P2 := 2000;
Auto.P3 := 'X';
var v := Auto.GetType().Methods.Where(info -> info.Name.StartsWith('get_')).FirstOrDefault(info -> info.Name = 'get_P1').Invoke(Auto, []); //CRASHED HERE
writeLn(v);
Have a look: (SecondCase)
var pair: MyPair<TKey, TValue> := new MyPair<char, int32>('x', 30);
var v := pair.GetType().Methods.Where(info -> info.Name.StartsWith('get_')).FirstOrDefault().Invoke(Auto, []); //CRASHED HERE
writeLn(v);
We can’t fix this bug based on a random bit of code where we can’t see the important parts. Specifically, we the involved records.
That said; as you saw in your previous issue, there was an alignment bug in the invoker api, fixed that locally (should show in tomorrows build) which might just fix these too.
Fields have no getters/setters.
so you nave received nil after car.GetType().Methods.FirstOrDefault(info -> info.Name = 'get_P1') and later NRE
you can use Fields like car.GetType().Fields.FirstOrDefault(...)
I will continue reporting Errors about the invoke here:
As far as I see:
it works for records/classes pretty well, EXCEPT FOR: INT64 and UINT64
they throw total crap values in the console (see “Strange Assignment Bug” for the Project i upload, there you have a good testcase for reproducing it)
when you Change the value of the P8 property, for instance, to UInt32.MaxValue and the P2 property to Int64.MinValue, suddenly, it works, at least in my testcase^^