No SCAN/ENDSCAN support yet?
On 7/29/2020 11:56 AM, Johan Nel wrote:
Hi all VFPers,
Well have not posted much lately about X# here due to some other issues I have to attend to, but good progress are made with support for the VFP dialect.
As per the message regarding .NET Core, I would also like to share progress with X# regarding .NET Core support.
Attached the link and posting by Robert today.
Hope it is of interest to (most) some.
Johan Nel George, South Africa.
https://www.xsharp.info/forum/public-product/2069-xsharp-builds-on-net-core
I would like to share some progress that I made today. I have changed the X# build system to support building for .Net Core. Consider an app that has one PRG file and a XSPROJ file. The contents of the XSProj file looks like this:
<Project Sdk="Microsoft.NET.Sdk"> <Import Project="$(XSharpMsBuildDir)\XSharp.NET.Sdk.props" /> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp5.0</TargetFramework> <ins>true</ins> <dialect>vo</dialect> </PropertyGroup> <ItemGroup> <Reference Include="XSharp.Core" /> <Reference Include="XSharp.RT" /> <Reference Include="XSharp.RDD" /> <Reference Include="XSharp.MacroCompiler" /> </ItemGroup> <Import Project="$(XSharpMsBuildDir)\XSharp.NET.Sdk.targets" /> <ItemGroup> <PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.1" /> </ItemGroup> </Project>
As you can see we are compiling for .Net Core 5.0 and for the VO dialect. I have included the XSharp assemblies needed to open a DBF file. The only "strange" thing in here is the package references to the System.Text.Encoding.CodePages package, because by default .Net Core does not have support for Codepage 1252 which I am using. Unlike traditional project files there are no items included. By default .Net Core includes all source code items in the folder.
The code looks like this:
USING System.Text
FUNCTION Start() AS VOID FIELD CUSTNUM, LASTNAME, FIRSTNAME Encoding.RegisterProvider(CodePagesEncodingProvider.Instance) ? "Hello from X#" ? "OS :",OS(TRUE) ? "Framework:", System.Environment.Version:ToString() ? "Xsharp : version", Version(), "dialect", RuntimeState.Dialect:ToString() ? "Datetime :", DateTime() ? "Program :", ExecName(TRUE) ? "Workdir :", WorkDir() ? "Curdir :", System.IO.Directory.GetCurrentDirectory()
? "Opening, Indexing and listing a DBF with .Net Core" ? USE Customer INDEX ON LASTNAME TO LASTNAME DO WHILE ! EOF() ? Str(CUSTNUM,2) , LASTNAME, FIRSTNAME SKIP ENDDO ? "Press any key" Console.ReadLine() RETURN
As you can see I am calling a function in the Encoding class to link the package that has the codepage support. The rest is a normal mixture of Xbase code and .Net code. To compile and run the program I type
dotnet run
on the command line. The result is this:
Hello from X# OS : Windows 10 Enterprise (x64) ( Version 10.0, Build 18363 ) Framework: 5.0.0 Xsharp : version XSharp 2.5.2.0 dialect VO Datetime : 29-07-2020 16:10:58 Program : C:\test\bin\Debug\netcoreapp5.0\test.dll Workdir : C:\test\bin\Debug\netcoreapp5.0\ Curdir : C:\test Opening, Indexing and listing a DBF with .Net Core
6 Baker James 2 Borne Maria 15 Chandler Walter 3 Cooper Elizabeth 12 Cusumano Karen 5 Dougherty Janet . . 14 Walsh Gloria 19 Zimmerman Carla Press any key
As you can see the runtime, RDD system and Macro compiler all work on .Net Core 5.0 ! You can deploy this app with all support DLLs in one single Exe and 2 small DLLs by calling:
dotnet publish --self-contained true -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true
This creates the following files, which make up the whole program:
29-07-2020 16:13 28.955.153 test.exe 28-05-2020 08:26 500.608 hostfxr.dll 28-05-2020 08:26 506.248 hostpolicy.dll
Even the XSharp DLLs are included in test,exe. The total size is 29 Mb.
You can also prepare an image for Linux by replacing win-x64 with linux-x64 and then the output is:
29-07-2020 16:16 44.552.454 test 28-05-2020 07:54 563.728 libhostfxr.so 28-05-2020 07:54 532.408 libhostpolicy.so
A self contained .Net app for Linux in 44 Mb !
I hope you find this interesting.
Robert
And yes this will be included in the next build. Not with the VS project system, that will take a bit longer.
[excessive quoting removed by server]