xsharp.eu • Error XS0656 Missing compiler required member
Page 1 of 1

Error XS0656 Missing compiler required member

Posted: Mon Apr 27, 2020 12:54 am
by Anonymous
What is causing this error?

It's related to the use of Text/EndText in the running code.
Error XS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create' VPF Xsharp test app 1 H:WorkReposXSharp ProjectsVPF Xsharp test app 1VPF Xsharp test app 1SqlBoBase.prg 50
2020-04-26 19_51_06-VPF Xsharp test app 1 - Microsoft Visual Studio.png
2020-04-26 19_51_06-VPF Xsharp test app 1 - Microsoft Visual Studio.png (37.46 KiB) Viewed 299 times

Error XS0656 Missing compiler required member

Posted: Mon Apr 27, 2020 12:59 am
by FoxProMatt
Okay, I found the answer in another thread here be searching for "XS0656".

The answer is that you must add a reference to Microsoft.CSharp.dll into your project.

Please add this info to the Help File for the Text/EndText function in the docs: https://www.xsharp.eu/help/command_text.html
The attachment 35e092f562a1acc0be993bf318536333 is no longer available
2020-04-26 19_56_26-VPF Xsharp test app 1 (Running) - Microsoft Visual Studio.png
2020-04-26 19_56_26-VPF Xsharp test app 1 (Running) - Microsoft Visual Studio.png (13.02 KiB) Viewed 299 times

Error XS0656 Missing compiler required member

Posted: Mon Apr 27, 2020 6:22 am
by Chris
Hi Matt,

TEXT/ENDTEXT does not require this reference, at least not in any case I am aware of. Are you using DYNAMIC vars elsewhere in your code? Those indeed need this reference.

Error XS0656 Missing compiler required member

Posted: Mon Apr 27, 2020 8:00 am
by robert
Matt,

I suspect that this is caused by a setting at the project level, just like your ticket #373 on Github.
Can you mail us an example ?

Robert

Error XS0656 Missing compiler required member

Posted: Mon Apr 27, 2020 2:50 pm
by FoxProMatt
I have explored this situation further...

In my code there is a Class with public properties, and in the Text/EndText, I had referred to a "This.PkField" class property (wrong name) but the actual property is named "cPkField" (c prefix at front).

Well, because the Text/EndText referred to a bad property name reference to <<This.PkField>>, Visual studio gives a Warning:
"Warning XS9094 Type 'TestClass' does not have a member 'PkField'. This gets resolved to a late bound call to its method 'NoIVarGet'
BUT.. This also causes a Compiler error XS0656 stating "Error XS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'"


The Warning finally caught my eye and helped me see what the problem is, because I was first more worried because of the compiler error.

So when I added the DLL it made the compiler happy, but the Warning about missing property also went away and I thought everything was good until I got a run-time error complaining that "''TestClass' does not contain a definition for 'PkField''

Bottom line is I had a bad property reference in my code, and because I am still learning this stuff, it took me a while to figure out from the help that Visual Studio was giving me.

The bad thing about this case is that with the DLL added to the project, you loose all the help that the compiler can give you (from Warnings), and you can get run-time errors because you are not told that you have bad code.


Here is the code that will demo the error.

Code: Select all

Using System
Using System.Collections.Generic
Using System.Linq
Using System.Text

Using XSharp.Core
Using XSharp.VFP
Using XSharp.RT
Using XSharp.RDD



FUNCTION Start() As Void Strict
	
	Var oTest = TestClass{}
	
	oTest.DemoCsharpDllRequiredError()
		
	Return
	
END FUNCTION
	

*======================================================================
Define Class TestClass As Custom
	
	Public cTable = "Customers"
	Public cPkField = "ID"
	
	*---------------------------------------------------------------------------------
	Function DemoCsharpDllRequiredError(uValue)
  
		Local lcSql

		Text To lcSql Textmerge Noshow
			Select * From <<This.cTable>> Where <<This.PkField>> = <<uValue>>
		Endtext
  
		? lcSql
	
		Wait
		
		Return
  
	End Function
  
End Define


2020-04-27 09_35_14-VPF Xsharp test app 2 - Microsoft Visual Studio.png
2020-04-27 09_35_14-VPF Xsharp test app 2 - Microsoft Visual Studio.png (118.84 KiB) Viewed 299 times

Error XS0656 Missing compiler required member

Posted: Mon Apr 27, 2020 2:53 pm
by robert
Matt,
As interesting all of this is, it still does not explain the error.
Did you have the "enable late binding" compiler option selected ?

Robert

Error XS0656 Missing compiler required member

Posted: Mon Apr 27, 2020 3:15 pm
by FoxProMatt
At first I did not have Allow Late Bind enabled...

But then I enabled it, and now I don't get any compiler errors or even any run-time errors.

So this is REALLY BAD...

I have code that references a non-existing property on an object reference, and at run-time it does not even give an error and Text/EndText generated a text string while totally skipping over the referenced (bad/missing) property. This can certainly lead to big problems in a running app.

See below I attached a full Solution to demonstrate this problem.
2020-04-27 10_10_19-VPF Xsharp test app 2 (Running) - Microsoft Visual Studio.png
2020-04-27 10_10_19-VPF Xsharp test app 2 (Running) - Microsoft Visual Studio.png (83.12 KiB) Viewed 299 times

Error XS0656 Missing compiler required member

Posted: Mon Apr 27, 2020 3:39 pm
by robert
Matt,
You should have seen a runtime error.
I'll check why that does not happen.
And w.r.t the compile time errors:
I'll discuss with the guys what we can do. Maybe can change the compiler to allow undeclared variables for certain class and their subclasses, such as the Empty class, but still generate compiler errors/warnings for other classes.

Robert