Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools
This repository now also contains the code that was previously in the XSharpDev repository.
Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools.
License: Apache License 2.0
Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools
This repository now also contains the code that was previously in the XSharpDev repository.
Create a new winforms project
Edit the form.prg and designer.prg files and remove the BEGIN...END
NAMESPACE declarations, so the form is now created in the default namespace
Building and running the project should still work fine.
Open form.prg in the editor and add some comments before the form
declaration and after the form declaration as in the attached sample.
Open the form in the designer (it opens fine), make some dummy change
and save.
Open form.prg in the editor again, now the comments at the end of the
file are missing and the comments before the class declaration are
duplicated in the beginning of the file.
From Trevor:
More info: with the Solution Explorer being laggy when scrolling when a
branch with a number of sub-branches is expanded - I just tested now and
we have some with lots of subbranches, but I just opened on with 30
sub-branches and it had the same issue.
This happens consistently is in our largest project which I believe I
have sent to you before for testing - if you cant replicate it let me
know and I am happy to resend that to you if you need as that one,
though not a show stopper is the biggest issue we have as far as day to
day operating goes.
Raffaele,
You are right. Some XPP class elements, such as the Inline method are not properly supported for intellisense inside VS. We will try to add that for the next build.
From Raffaele:
Xbase++ has a Var2Bin and Bin2Var functions that trasforms vars/object to/from binary
So it is possible to save an object to disk
Lmemowrit( "myobject.bin", Var2bin(myobject) )
Restore an object
myobject:=Bin2Var( MemoRead("myobject.bin") )
Deep copy
obj2:= Bin2Var(Var2Bin(obj1))
It would be possible something similar ?
The #else is not put at the same level as the #ifdef and #endif.
From Otto:
How to reproduce: The solution is under TFS source control. I added a XSharp MsUnit project directly from the solution explorer. I tryed to rename the standard prg. (Same issue occures when adding a new prg file and try to rename that from the solution treeview) This resulted in messages "The item -old filename- was not renamed in the source controld atabase because there is already an item with this name in the destination folder." This can be repeated. It even resulted in crashes of Visual Studio. At reopening the solution the project refered to the old file name. The new file was in the folder on disk. I finally edited the project on disk by hand to fix this.
Add a context option to the solution explorer tree to migrate a project (or all projects in a solution ?) to the X# runtime. This should at least do:
Working with VFP a function that is used quite frequently is FileToStr.
This is implemented as MemoRead in X#.
Can the following be added to the RunTime functions?
FUNCTION FileToStr(cFileName AS STRING) AS STRING
RETURN MemoRead(cFileName)
Form does not open when it references an enum in the same project
LOCAL o AS OBJECT
o := 123 // no problem
o := WindowsFormsApplication37.TestEnum.Something // this causes the
form to not open
o := ClassLibrary1.LibraryEnum.MyMember // surprisingly, there's no
problem with this one!
An example of a missing define is MAX_ALLOC.
Suggest:
write a small tool that reads the Vulcan (or other dialects) VH files and checks a specific X# runtime DLL for the presence of the defines as fields in the Functions class (using reflection).
Add an option to the Solution Explorer context menu to split a windows from in a form.prg and form.designer.prg
Create a new WinForms project
Try to set any "image" property of the form or a control, a dialog
opens for selecting teh image from disc and it has two options, "Local
Resource" and "Project resource file"
Default selected option is "Project resource file", so select "Import"
and pick an image file. This works and the image appears on the
form/control in the designer.
Save and close form.
Build, compiler error is reported : error XS0234: The type or
namespace name 'Resources' does not exist in the namespace
'WindowsFormsApplication23' (are you missing an assembly reference?)
Try to open the form in the designer again, it does not open with an
error message "The designer could not be shown for this file because
none of the classes within it can be designed"
Note that by selecting the "Local Resource" option before importing an
image, it all works correctly.
// error XS9008: Untyped arrays are not available in the selected dialect 'Core'
USING System.Collections.Generic
FUNCTION Start() AS VOID
VAR l := List{} {1,2,3} // ok
? l[1]
VAR s := SortedList{} {{1,2},{3,4}} // error 9008
? s[1]
RETURN
The attached solution has a form.prg with a region:
#region TEstRegion
METHOD MethodInsideRegion() AS INT
RETURN 0
#endregion
After making a change to the form in the designer, the #region
directives disappear from the .prg file.
WindowsFormsApplication27.zip
More and more users are installing VS without the local help context.
Therefore it is a good idea to add a menu option to the Help menu to show the local (CHM) help for X#.
The following code creates a dbf and applies an order scope, then does some seeks. Problems:
After setting the scope, DBOrderInfo( DBOI_KEYCOUNT ) returns a
negative value, -2, for both drivers (DBFNTX and DBFCDX). Interestingly,
also VO returns -2 for NTX! But for CDX, VO returns the correct value, 4.
When using DFBCDX, after setting the scope, a DBSeek("G") returns TRUE, but a DBSeek("GOLD") returns FALSE, which is wrong. With DBFNTX, both Seeks return TRUE. Also VO always returns TRUE
Interestingly, after claring the scope and setting the same again, now both seeks return TRUE in X# for both drivers.
FUNCTION Start() AS VOID
LOCAL cDBF,cPath AS STRING
LOCAL aFields, aValues AS ARRAY
LOCAL i AS DWORD
// RDDSetDefault("DBFNTX")
RDDSetDefault("DBFCDX")
cDbf := "C:\test\mycdx"
FErase(cDbf + ".ntx")
FErase(cDbf + ".cdx")
aValues := {"Gas" , "Abc", "Golden" , "Guru" , "Ddd" , "Aaa" , "Ggg"}
aFields := { {"CFIELD" , "C" , 10 , 0} }
DBCreate(cDbf , aFields)
DBUseArea(,,cDBF)
DBCreateIndex(cDbf , "Upper(CFIELD)")
FOR i := 1 UPTO ALen(aValues)
DBAppend()
FieldPut(1, aValues[i])
NEXT
DBGoTop()
? DBOrderInfo( DBOI_KEYCOUNT ) // 7, correct
? "Setting order scope"
OrdScope(TOPSCOPE, "G")
OrdScope(BOTTOMSCOPE, "G")
DBGoTop()
// X#: -2 with both CDX and NTX
// VO: -2 with NTX, 4 with CDX
? DBOrderInfo( DBOI_KEYCOUNT )
? DBSeek("G") // TRUE, correct
? DBSeek("GOLD") // TRUE with NTX, FALSE with CDX. VO TRUE in both
? "Clearing order scope"
OrdScope(TOPSCOPE, NIL)
OrdScope(BOTTOMSCOPE, NIL)
? DBOrderInfo( DBOI_KEYCOUNT )
? DBSeek("G")
? DBSeek("GOLD")
? "Setting order scope again"
OrdScope(TOPSCOPE, "G")
OrdScope(BOTTOMSCOPE, "G")
DBGoTop()
? DBOrderInfo( DBOI_KEYCOUNT )
? DBSeek("G")
? DBSeek("GOLD")
DBCloseArea()
RETURN
Otto:
When we try to debug a 64 bit xsharp project and then hit a breakpoint we get popups from Visual Studio: An error occurred while attempting to load an expression evaluator dll. Please restart Visual Studio. If the problem continues, please try to repair your installation. We didn't have this problem with the 32 bit application We tried to reproduce this on another machine with an simple hello world application and that triggered the same result on a breakpoint.
When debugging a 64 bit app en error occurs in the expression evaluator dll
Got the callstack below when trying to investigate a user report on WPF.
Error happened while I had opened the .xaml file in the editor. I am
including both the .xml file and the project.
System.ArgumentException: Absolute path expected.
Parameter name: path
at Roslyn.Utilities.CompilerPathUtilities.RequireAbsolutePath(String
path, String argumentName)
at Microsoft.CodeAnalysis.FileTextLoader..ctor(String path, Encoding
defaultEncoding)
at
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DocumentProvider.StandardTextDocument..ctor(DocumentProvider
documentProvider, AbstractProject project, DocumentKey documentKey,
Func2 getFolderNames, SourceCodeKind sourceCodeKind, IVsFileChangeEx fileChangeService, ITextBuffer openTextBuffer, DocumentId id, EventHandler updatedOnDiskHandler, EventHandler
1 openedHandler,
EventHandler1 closingHandler) at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DocumentProvider.TryGetDocumentForFile(AbstractProject hostProject, String filePath, SourceCodeKind sourceCodeKind, Func
2
canUseTextBuffer, Func2 getFolderNames, EventHandler updatedOnDiskHandler, EventHandler
1 openedHandler, EventHandler`1
closingHandler)
at
Microsoft.VisualStudio.LanguageServices.Xaml.XamlTextViewCreationListener.TryCreateXamlDocument(AbstractProject
project, String filePath, IVisualStudioHostDocument& vsDocument)
at
Microsoft.VisualStudio.LanguageServices.Xaml.XamlTextViewCreationListener.VsTextViewCreated(IVsTextView
vsTextView)
at
Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.<>c__DisplayClass423_0.b__0()
at
Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object
errorSource, Action call)
--- End of stack trace from previous location where exception was thrown ---
at
Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception
exceptionObject)
WpfMapUserControl-1.zip
ActivityLog.zip
When typing a LINQ expression in Visual Studio in a function def inside a PRG, I expect to get Intellisense on property names from the typed objects referenced in the expression. All the type data is present in the variable declarations and assignments, and the code compiles and runs fine when I manually type the properties name in the code, so it should be popping up a list of properties on that object type when I type "o:"
Function Start() As Void Strict
Local cFilename As String
Local deserializer As XmlSerializer
Local vcxRepo As VcxRepoModel
cFilename := "h:\work\repos\xsharp.vfp\samples\scx form sample 1\vfp_form_sample_1.scx.xml"
Var streamReader := StreamReader{cFilename};
deserializer := XmlSerializer{typeof(VcxRepoModel)}
vcxRepo := (VcxRepoModel) deserializer:Deserialize(streamReader)
Var oClasses := From o In vcxRepo:Records Where o:IsClassDef == 1 Select o
Add support for the FoxPro DBF Field types:
For DBFs with header byte:
0x30 Visual FoxPro
0x31 Visual FoxPro, autoincrement enabled
0x32 Visual FoxPro, Varchar, Varbinary, or Blob-enabled
Other header bytes:
28 | Table flags:
0x01 file has a structural .cdx
0x02 file has a Memo field
0x04 file is a database (.dbc) This byte can contain the sum of any of the above values. For example, the value 0x03 indicates the table has a structural .cdx and a Memo field.
29 | Code page mark
30 – 31 | Reserved, contains 0x00
32 – n | Field subrecords The number of fields determines the number of field subrecords. One field subrecord exists for each field in the table.
n+1 | Header record terminator (0x0D)
n+2 to n+264 | A 263-byte range that contains the backlink, which is the relative path of an associated database (.dbc) file, information. If the first byte is 0x00, the file is not associated with a database. Therefore, database files always contain 0x00.
FoxPro Field types
W - Blob
C – Character (binary)
Y – Currency
B – Double
T – DateTime
F – Float
G – General
I – Integer
M – Memo
M – Memo (binary)
P – Picture
Q - Varbinary
V - Varchar
V - Varchar (binary)
See FoxPro docs for full documentation.
Also add:
Pos
12 – 15 | Displacement of field in record
16 | Length of field (in bytes)
17 | Number of decimal places
18 | Field flags:
0x01 System Column (not visible to user)
0x02 Column can store null values
0x04 Binary column (for CHAR and MEMO only)
0x06 (0x02+0x04) When a field is NULL and binary (Integer, Currency, and Character/Memo fields)
0x0C Column is autoincrementing
19 - 22 | Value of autoincrement Next value
23 | Value of autoincrement Step value
Also check FoxPro codepages
437 | U.S. MS-DOS | x01
620 * | Mazovia (Polish) MS-DOS | x69
737 * | Greek MS-DOS (437G) | x6A
850 | International MS-DOS | x02
852 | Eastern European MS-DOS | x64
857 | Turkish MS-DOS | x6B
861 | Icelandic MS-DOS | x67
865 | Nordic MS-DOS | x66
866 | Russian MS-DOS | x65
874 | Thai Windows | x7C
895 * | Kamenicky (Czech) MS-DOS | x68
932 | Japanese Windows | x7B
936 | Chinese Simplified (PRC, Singapore) Windows | x7A
949 | Korean Windows | x79
950 | Traditional Chinese (Hong Kong SAR, Taiwan) Windows | x78
1250 | Eastern European Windows | xC8
1251 | Russian Windows | xC9
1252 | Windows ANSI | x03
1253 | Greek Windows | xCB
1254 | Turkish Windows | xCA
1255 | Hebrew Windows | x7D
1256 | Arabic Windows | x7E
10000 | Standard Macintosh | x04
10006 | Greek Macintosh | x98
10007 * | Russian Macintosh | x96
10029 | Macintosh EE | x97
In the following code, calling a method with a [ParamArray] parameter by
passing it a (string inside a) USUAL works fine at runtime. But when
using the same exact code for calling a constructor with the exact same
parameters causes a runtime exception.
Both cases did work without errors in vulcan and I have a LOT of
existing code which makes use of that.
FUNCTION Start() AS VOID
LOCAL u AS USUAL
u := "asd"
DoTest(u)
RETURN
PROCEDURE DoTest(u AS USUAL)
TestClass.Test(u) // ok
LOCAL o AS TestClass
o := TestClass{u} // runtime exception
CLASS TestClass
CONSTRUCTOR([ParamArray] s AS STRING[])
? s:Length
? s[1]
RETURN
STATIC METHOD Test([ParamArray] s AS STRING[]) AS VOID
? s:Length
? s[1]
RETURN
END CLASS
System.InvalidCastException
Unable to cast object of type 'System.String' to type 'System.String[]'.
Callstack :
static System.Void xRutnime.Exe.Functions.DoTest(XSharp.__Usual u)() :
C:\VIDE\Projects\TestProject\Applications\xRutnime\Prg\xRuntime.prg : 10
xRutnime.Exe.Functions+>c.System.Void
xRutnime.Exe.Functions+>c.b__2_0()() :
C:\VIDE\Projects\TestProject\Applications\xRutnime\Prg\xRuntime.prg : 4
static System.Void xRutnime.Exe.Functions.Start()() :
C:\VIDE\Projects\TestProject\Applications\xRutnime\Prg\xRuntime.prg : 1
From the visual designer of a User Control or a Form, every time you double-click on a control it creates a stub method in the code behind prg (not the .Designer file). Great, that's what it's supposed to do. However, in adding the code for the stub method, it also alters the existing code in the code behind (not talking about the .Designer file), and it should not destroy any code changes that I have placed there. (BTW, this issue does not happen in a C# .Net Winforms app, it only happens in X# WinForms app)
The specific things are altered:
Any [Attributes] I added to the class are removed
Any #region/#endregion markers I added are stripped away (not really sure X# claims to support this, but hopefully it can)
One new blank line is added between the Properties each time a double-click on a control is performed, so the spacing grows every time.
The Function class for Static functions and globals should be internal
Regarding DBReindex(), the VO docs say that it can be used no matter if
the dbf is opened shared or not:
"Although this operation will work in both shared and exclusive mode,
exclusive mode is highly recommended. See both SetExclusive() and
"Concurrency Control" in the Programmer's Guide for more information."
But that´s not correct (as usual...). If a dbf is opened shared VO
throws an "Shared error" Error Code: 37[EXCLUSIVE REQUIRED]
X# allows a DBReindex() in both modes. Not sure what we should do with
that, but at least without a full file lock, a shared file reindex
sounds a bit dangerous?
FUNCTION Start() AS VOID
LOCAL cDBF, cPfad, cIndex, cDriver AS STRING
LOCAL aFields, aValues AS ARRAY
LOCAL i AS DWORD
LOCAL lSHared AS LOGIC
lSHared := TRUE
cDriver := RDDSetDefault ( "DBFCDX" )
aFields := { { "LAST" , "C" , 20 , 0 }}
aValues := { "b" , "d" , "c", "e" , "a" }
cPfad := "C:\test\"
cDBF := cPfad + "Foo"
cIndex := cPfad + "Foox"
FErase ( cIndex + IndexExt() )
DBCreate( cDBF , AFields)
DBUseArea(,"DBFCDX",cDBF , , lSHared )
FOR i := 1 UPTO ALen ( aValues )
DBAppend()
FieldPut ( 1 , aValues [ i ] )
NEXT
? DBCreateOrder ( "ORDER1" , cIndex , "upper(LAST)" , { || Upper (
_Field->LAST) } )
? DBSetOrder ( 1 )
// DBReindex()
//
// When the DBF is opened shared VO throws an "Shared error",
// while X# seems to allow a reindex , no matter if the DBF is opened
shared or not.
? "Reindex", DBReindex()
DBCloseAll()
RETURN
The form cannot be opened in the designer because of this line:
SELF:BackgroundImage := WindowsFormsApplication38.Properties.Resources.Image1
the project does build and run fine.
As per title
For assignment lines like:
SELF:_globalClassName := SELF:GetPropertySafe(type, custAttr, "globalclassname")
the debugger puts the breakpoint on the SELF keyword.
That should be the whole line, or at least the first statement / expression on the line
We can use the IVsXMLMemberIndexService interface for that
testcase C675
From Trevor:
Winform Editor – when creating the controls click event method by
double clicking on the control from the winform – it creates the method
declaration but has no RETURN statement by default. Not a big issue but
would be good to have this as an option as Vulcan worked that way. (I
mentioned this one previously I think)
From a customer:
since I’m preparing my code already in the VO version, sometimes I would
like Xporter would not touch some parts of my code.
Therefore IMHO the xPorter/VO should recognize
#ifdef __XSHARP__
#else
#endif
and
#ifndef __XSHARP__
#else
#endif
And let untouched all the code that is defined for X#, as it is already in X# syntax.
This would save a lot of time during the migration.
Thank you very much!
LOCAL o AS List<int>
o[1]:
displays the same members of the List Of T type, while it should display members of the INT type.
We should use the taskprovider for this.
After lexing the buffer we should be able to detect "special tokens" in the comment text
I just got an exception on this:
class Parent
constructor(n as int)
end class
class Child inherit Parent
constructor()
super(
end class
got the exception when I typed the "super(". I think before it was just not showing the correct parameter tip.
The following code stops responding at the VoDbOrderInfo(), when a
descending order is used. This happens because of an endless loop
between lines 522 and 525 in _getRecPos() of CdxTag.prg:
DO WHILE recno != 0 .AND. recno != oldRec
count++
recno := SELF:_ScopeSkip(1)
ENDDO
repro code:
FUNCTION Start() AS VOID
LOCAL cPath AS STRING
LOCAL cDbf AS STRING
cPath := "C:\test\"
cDbf := "mydbf"
? FErase ( cPath + cDbf + ".dbf" )
? FErase ( cPath + cDbf + ".cdx" )
RddSetDefault ( "DBFCDX" )
DbCreate(cPath + cDbf,{{"LAST" , "C" , 10,0}})
DbUseArea(,"DBFCDX" , cPath + cDbf)
DbAppend()
FieldPut(1,"Karl-Heinz")
DbAppend()
FieldPut(1,"Robert")
DbAppend()
FieldPut(1,"Chris")
DbAppend()
FieldPut(1,"Karl")
DbGoTop()
? OrdCondSet(,,,,,,,,,,TRUE) // descending
? DbCreateOrder( "ORDER1" , cDbf + ".cdx" , "upper(LAST)" , { || Upper (
_Field->LAST) } )
DbSetOrder(1)
DbGoTop()
DbSetFilter(,"upper(LAST) = '" + "K" + "'" )
DbGoTop()
LOCAL uRetVal AS USUAL
// program freeze here:
? VoDbOrderInfo( DBOI_POSITION, "", NIL, @uRetVal )
RETURN
When a UC or Form does not directly inherit from UserControl or Form then thes Subtype Designer is not set when it is added to a project
From Trevor:
Win32 window editor – sometimes when we add controls and double click
on them to generate the controls click event method, it either creates
the method declaration and return statement in the middle of other code
or outside of the END CLASS declaration. We then undo and try again and
it normally works the second time. This also doesn’t happen all the time
– so not easy to replicate but thought I should mention it
If you have a Winforms app Project in Visual Studio, and you have a UserControl UI component that you have coded out manually in prg files, then you right click on the Project in VS, and click "Add Exiting Item", when you choose MyControl.prg, well, the first issue is that it does not automatically add the MyControl.Designer.prg file along with it, like it does when you add an existing Form to a project. Okay, no big deal, so I go back and click Add Existing Item again, and choose the Designer file, and it gets added as well, and VS now sees the relationship between these two files, and displays the Designer file under the prg file, so it look mostly correct, but notice the icon for the Existing Item I just added does look like the other icon for the UserControl2 which as added as a New Item action earlier in my app design.
Since VS does not recognize these two "Existing Item" files as a proper User Control, when you double-click on it, it does not open the Visual Designer like it should.
Again, this process works fine when adding an Existing Form, just not when adding an Existing UserControl.
So, I have discovered the reason for this the icon is not correct and the reasons the Visual Designer does not open when you double-click, and it has to do with a missing element in the xsproj xml... If I manually add the missing xml markup tag to xsproj, everything begins to work as it should! see screenshots below.
This feature of adding an Existing Item works properly for Forms, but does not work properly for User Controls:
After adding files to Project:
Missing XML:
So this is what it should look like:
Fixed in Visual Studio:
Now you can double click on it, and VS will open the Visual Designer for the user control:
VS wants to add the nuget packages to TFS for XSharp projects and ignores the settings we provided. Other c# projects don't have this problem. .nuget\nuget.config packages.tfignore # Ignore all files in this folder and in all subfolders .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.