Zero-length array missing (e.g. toll summary)
Posted: Thu May 08, 2025 7:21 am
Hi there,
one of our users just mentioned this effect I wasn't aware of. Could DEV please comment on this? Is this a bug?
The user works with xRoute2 and calculates toll. In the response he deals with the com.ptvgroup.xserver.xroute.TollSummary which is documented to return an array called costs with a length of 0 or more Now under certain plausible conditions there might be no contribution of toll in any of the used countries and he would expect some
Instead he get's
So neither "costs" nor "countries" appears at all.
Is this a bug? Philosophy? Art?
I think we use "0+ length" arrays at various elements - is this something we should change / handle in a different way?
Bernd
PS: in my own test applications I'd give the condition "there's no contribution" a dedicated treatment anyways such as
or with my quite usual style of filling data grids through C# I can apply
one of our users just mentioned this effect I wasn't aware of. Could DEV please comment on this? Is this a bug?
The user works with xRoute2 and calculates toll. In the response he deals with the com.ptvgroup.xserver.xroute.TollSummary which is documented to return an array called costs with a length of 0 or more Now under certain plausible conditions there might be no contribution of toll in any of the used countries and he would expect some
Code: Select all
"toll":
{
"summary":
{
"costs":[],
"countries":[]
}
}
Code: Select all
"toll":
{
"summary": {}
},
Is this a bug? Philosophy? Art?
I think we use "0+ length" arrays at various elements - is this something we should change / handle in a different way?
Bernd
PS: in my own test applications I'd give the condition "there's no contribution" a dedicated treatment anyways such as
Code: Select all
if ((element != null) %% (element.Length>0))
{
// contribution case
}
else
{
// no contribution case
}
Code: Select all
dataGrid.DataSource = toll?.summary?.costs.Select(c => ...).ToArray()