xsharp.eu • Xbase++ forum - Page 2
Page 2 of 3

Re: Xbase++ forum

Posted: Tue Dec 19, 2023 12:34 pm
by DenGhostYY
Error XS0579 Duplicate 'global::XSharp.Internal.ClassLibraryAttribute' attribute

AssemblyInfo.prg

Code: Select all

USING System.Reflection
USING System.Runtime.CompilerServices
USING System.Runtime.InteropServices
USING XSharp.Internal

//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("SandBoxXSharp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SandBoxXSharp")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ClassLibrary("XbTools", "XbTools")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components.  If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(FALSE)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9c904023-2d57-4483-99c1-ca750397563b")]

//
// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.0.*")]
What am I doing wrong?

Re: Xbase++ forum

Posted: Tue Dec 19, 2023 2:48 pm
by robert
When compiling with X# you do not add the ClassLibrary Attribute yourself. The compiler does that for you and includes the name of the class that it generated that contains all the functions in your assembly.
Only if you code in C# then you have to add this attribute.
If you want to tell the compiler about additional namespaces, then you should use the ImplicitNamespace attribute. There can be more than one of this attribute.

Robert

Re: Xbase++ forum

Posted: Tue Dec 19, 2023 5:50 pm
by DenGhostYY
Yes, I want to use a class library written in C# in an X# project. Unfortunately, applying the specified attributes does not allow me to compile the X# console application. Can I see such examples or send you my solution (.sln) that doesn't work?

Re: Xbase++ forum

Posted: Tue Dec 19, 2023 7:13 pm
by wriedmann
Hi,
to use a C# library in an X# project you don't need anything - just add it in the references and use it.
Wolfgang

Re: Xbase++ forum

Posted: Tue Dec 19, 2023 7:43 pm
by DenGhostYY
How to make it so that there is no need to write

Code: Select all

using static XbTools.XbTools
in prg file?

Re: Xbase++ forum

Posted: Tue Dec 19, 2023 8:27 pm
by robert
DenGhostYY wrote: Tue Dec 19, 2023 7:43 pm How to make it so that there is no need to write

Code: Select all

using static XbTools.XbTools
in prg file?
If you write the code as a function then the compiler generates the ClassLibrary attribute.
There is no easy way to automatically add USING STATIC commands to a project.
If you want to centralize code in a class, you can also create a function that calls that method.
We have done that on several locations in the runtime too:
For example:

Code: Select all

FUNCTION MemVarGet(cVarName AS STRING) AS USUAL
    RETURN XSharp.MemVar.Get(cVarName)
We are planning support for GLOBAL USING and GLOBAL USING STATIC in a future release.
When that is available then you can add this in one location and it will work in the whole project.

Robert

Re: Xbase++ forum

Posted: Thu Mar 28, 2024 1:24 pm
by robert
Den,

To make the X# compiler automatically recognize your C# static method as a function, you will have to add an attribute to the C# assembly (and not the X# assembly)
The code below assumes that the functions are in the XbTools.XbTools class, and that the namespace XbTools may contain classes that you want the compiler to automatically recognize.

Code: Select all

using XSharp;
using XSharp.Internal;
[assembly: ClassLibrary("XbTools.XbTools", "XbTools")]
The ClassLibrary attribute can only appear once.

If you have more namespaces that you want the compiler to automatically include when searching for class you can add the ImplicitNamespace attribute as well

Code: Select all

[assembly: ImplicitNamespace("XbTools.Data")]
[assembly: ImplicitNamespace("XbTools.Support")]
The ImplicitNamespace attribute can be added more than once.

Robert

Re: Xbase++ forum

Posted: Fri Apr 26, 2024 4:29 am
by DenGhostYY
Hello. I'm trying to set up a compatible string comparison using the X# compiler flag -vo13 and functions SetInternational, SetCollation, SetNatDll. The following code:

Code: Select all

procedure Main()
#ifdef __XSHARP__
    SetInternational(#CLIPPER)
    SetCollation("CLIPPER")
    SetNatDll("RUSSIAN.DLL")
#endif
    ? asc("C"), asc("b"), "C" < "b"
    wait
    return
in Alaska outputs:
67 98 Y
in XSharp outputs:
67 98 .F.

That is, despite calling functions in the block #ifdef __XSHARP__, there is still a comparison "C" < "b" returned false. What am I doing wrong?

X# Compiler version 2.19.0.2 (release)
-dialect:xBase++
-codepage:866
-lb -enforceself -memvar -xpp1 -vo1 -vo3 -vo4 -vo5 -vo9 -vo10 -vo12 -vo13 -vo14 -vo15 -vo16 -vo17

Re: Xbase++ forum

Posted: Fri Apr 26, 2024 7:25 am
by Chris
Den,

Is Alaska always ignoring the case when doing string comparisons, or is this behavior based on a setting?

Re: Xbase++ forum

Posted: Fri Apr 26, 2024 7:48 am
by robert
Den,
The sort order is controlled by the russian collation. I would have to check what the contents of that collation is.
We extracted that sort order from the clipper / vo collation table

Robert