xsharp.eu • Strange error message in the immediate window
Page 1 of 1

Strange error message in the immediate window

Posted: Thu Jul 02, 2020 4:34 pm
by pemo18
Hello X#-Community,

I am using the immediate window in Visual Studio (2017 with Bandol 2.41) a lot for debugging. So I am thankful for the recent improvements like being able to use the X# syntax instead of C#.

But there are still some limiations. Many times I have to deal with DataTables and DataColumns from the .NET 2.0 System.Data namespace.

If I have a Row-Variable which is a DataRow-object and a ColumnName-variable which is the name of the column:

Row[ColumName]:GetType().Name

This should give me the type of the column value for example.

Instead I'll get this:

error CS0019: Der --Operator kann nicht auf Operanden vom Typ "string" und "int" angewendet werden.

This is strange because there is no -- involved.

If I use the column index instead there is no error (please see attached screen shot)

Kind regards,
Peter

Strange error message in the immediate window

Posted: Fri Jul 03, 2020 2:15 am
by Chris
Hi Peter,

I see the problem, this is because of an attempt to make the collection indexes 1-based, instead of 0-based which is the standard in .Net, by always subtracting 1 from the index, hence the error message about the "-" operator. But this is wrong, because this way oData:Columns[nIndex] would be actually translated to oData:Columns[nIndex-1], which would obviously return the wrong Column, so I think this needs to be removed.

In the particular case of the error that you get, you are using a string indexer instead of an int one, which the VS integration code does not realize and still tries to incorrectly subtract one. So it's two separate but related issues, I will log them for Robert to have a look, I suspect it will not be difficult to fix this. Thanks for your report!

Strange error message in the immediate window

Posted: Fri Jul 03, 2020 2:37 pm
by pemo18
Hi Robert,

That would be a little but big improvement;)

Regards,
Peter

Strange error message in the immediate window

Posted: Sat Jul 04, 2020 12:11 am
by Chris
He's fixed that already now :)