Xbase++ forum

This forum is meant for questions about the XBase++ Language support in X#.

User avatar
DenGhostYY
Posts: 15
Joined: Fri Sep 16, 2022 8:23 am

Re: Xbase++ forum

Post 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?
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Xbase++ forum

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
DenGhostYY
Posts: 15
Joined: Fri Sep 16, 2022 8:23 am

Re: Xbase++ forum

Post 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?
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Xbase++ forum

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
DenGhostYY
Posts: 15
Joined: Fri Sep 16, 2022 8:23 am

Re: Xbase++ forum

Post by DenGhostYY »

How to make it so that there is no need to write

Code: Select all

using static XbTools.XbTools
in prg file?
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Xbase++ forum

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Xbase++ forum

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
DenGhostYY
Posts: 15
Joined: Fri Sep 16, 2022 8:23 am

Re: Xbase++ forum

Post 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
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Xbase++ forum

Post by Chris »

Den,

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

XSharp Development Team
chris(at)xsharp.eu
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Xbase++ forum

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply