BUG - VS intellisense causes hard freeeeeeze...

This forum is meant for questions about the Visual FoxPro Language support in X#.

FoxProMatt

BUG - VS intellisense causes hard freeeeeeze...

Post by FoxProMatt »

Robert - I found this issue...

It turns out that I must add a USING statement to get intellisense to work. See image below.

Is it always the case that we must add Using statements to reference NameSpaces used in preceding code, even when the code itself makes explicit reference to the the namespace when defining the object instance?

I had to add

Code: Select all

Using myNS
2019-10-21_8-20-21.png
2019-10-21_8-20-21.png (42.79 KiB) Viewed 476 times
User avatar
robert
Posts: 4540
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

BUG - VS intellisense causes hard freeeeeeze...

Post by robert »

Matt,

If your class in a namespace that is not "default" then indeed you must add a using statement.
So if the default namespace of your app had also been MyNs then this was not necessary.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
FoxProMatt

BUG - VS intellisense causes hard freeeeeeze...

Post by FoxProMatt »

Where does one set the default namespace in a VS solution?
User avatar
robert
Posts: 4540
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

BUG - VS intellisense causes hard freeeeeeze...

Post by robert »

You set it at the project level. Project properties, first tab page
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

BUG - VS intellisense causes hard freeeeeeze...

Post by Chris »

Matt,

Your original code is

Local oObject = myNS.MyFirstClass{} As MyFirstClass

so you are using the namespace part when instantiating the object (myNS.MyFirstClass{}), but you are not using the namespace part when declaring it (As MyFirstClass).

Does the compiler accept this code when you build with no errors? If it accepts it,it means that the namespace part is not needed in this case, so it is a bug in intellisense that it does not show the members.

But if the compiler complains, it means that indeed the LOCAL statement is incomplete, so intelisense correctly does not so anything.

Note that you can have 3 classes in your code, named myNS1.MyFirstClass, myNS2.MyFirstClass and myNS3.MyFirstClass and those are all considered completely different by the .compiler, intellisense and .Net framework itself.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
FoxProMatt

BUG - VS intellisense causes hard freeeeeeze...

Post by FoxProMatt »

Chris - the code compiles and runs fine even when I do not specify the namespace prefix when creating the object instance and do not include a Using statement.

I tested what you said and added namespace prefix when creating the object, then intellisense does work without having to add a Using statement:

Code: Select all

Local oObject = myNS.MyFirstClass{} As myNS.MyFirstClass

Here is the complete code (without the Using statement), which compiles and runs just fine, but does not give intellisense unless I add the "Using myNS" statement, or add the namespace prefix when creating the object.


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

#include "dbcmd.xh"

Function Start() As Void Strict
	
	Field cType, cKey
	Field cFilename
	
	Local oObject = myNS.MyFirstClass{} As MyFirstClass
	
		
	Local lFound = File(oObject.cDbfName)
		
	Select 0
	Use (oObject:cDbfName) Alias WA1 Shared
	Set Order To "cKey"
	
	Local cChildTable = "C:Worklm5AppDataxSharp_Test_Child.dbf"
	Use (cChildTable) Alias WA2 New Shared
	Set Order To "cFkey"
	
	Select WA1
	Set Relation To cKey Into WA2
		
	Scan For cType = "I"
		? cFilename
		? "  " + WA2->MoreData
	Endscan
	
	Wait

End Function




Begin Namespace myNS

	//==============================================================
	Define Public Class MyFirstClass As Custom

		Public cDbfName = "C:Worklm5AppDataxSharp_Test_Parent.dbf"

		
	End Define
	

End Namespace




User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

BUG - VS intellisense causes hard freeeeeeze...

Post by Chris »

Hi Matt,

Thanks for the sample! Actually this should throw a compiler error, because the class name is not correctly specified in the declaration, unless as Robert said the Default Namespace is specified in the Project properties as "MyNS". In which case the instellisense is wrong, because apparently it does not take this setting into account. Thanks, will create a full solution sample and will will log this.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
FoxProMatt

BUG - VS intellisense causes hard freeeeeeze...

Post by FoxProMatt »

No, the default namespace is not set to "myNS".
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

BUG - VS intellisense causes hard freeeeeeze...

Post by Chris »

Hi Matt,

Thanks, i see it, it looks like a bug in the compiler. The intellisense is right, the type of the class is not correctly specified, so it cannot find it. But the compiler somehow gets confused with the namespace declaration below and thinks you are already "inside" that namespace. if you move the lines from BEGIN NAMESPACE to END NAMESPACE to another .prg file of the same app, now the compiler will complain as well. Thanks for reporting, will log this.

So you just need to either use a USING statement, or fully qualify your class names including the namespace, for both intellisense and also for the compiler (excluding this bug). Or if you like you can declare your classes not inside a BEGIN ..END DNAMESPACEto leave them with a small short name, there's nothing wrong with that, especially in small samples.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply