Skip to content

Primary constructor & interface static constructor#2006

Merged
nvkokkalis merged 3 commits into
X-Sharp:devfrom
dimitrakokkali:primary_ctor
Jul 15, 2026
Merged

Primary constructor & interface static constructor#2006
nvkokkalis merged 3 commits into
X-Sharp:devfrom
dimitrakokkali:primary_ctor

Conversation

@dimitrakokkali

Copy link
Copy Markdown

Adds support for:

  • Primary constructors
  • Interface static constructors

@nvkokkalis
nvkokkalis merged commit 1a29471 into X-Sharp:dev Jul 15, 2026
1 check failed
@RobertvanderHulst

Copy link
Copy Markdown
Member

Nikos,
It looks like this has broken our compiler tests.
I have the impression that somehow 2 parameterless constructors are generated because getParameters() returns an empty parameterlist when there are no parameters.
In this case it should return null.
Maybe we need to add a parameter to getParameters() to tell it when to return an Empty parameter list and when to return null?

@nvkokkalis

Copy link
Copy Markdown
Contributor

Yeah, makes sense!

@nvkokkalis

Copy link
Copy Markdown
Contributor

I'll try reverting to check the workflow too

@RobertvanderHulst

Copy link
Copy Markdown
Member

And maybe you can also add some tests to the test suite to make sure that this works.
I would recommend:

  • class without primary constructor and clipper constructor
  • class with primary constructor and clipper constructor (this should fail), has to go to a different test app
  • class with just a primary constructor
  • class with primary constructor and one or more typed constructors
  • and the same of course for structures
  • and the same for record class and record structure

@nvkokkalis

Copy link
Copy Markdown
Contributor

I was wondering about that... how are the tests organised?

We have Cxxxx and Rxxxx tests in different folders. Is there some structure there or do we just add a new file?

Also, primary constructors in some cases (in records) require dotnet SDK to be supported. Do we support SDK projects in the tests?

@RobertvanderHulst

Copy link
Copy Markdown
Member

The tests that start with 'C' are created by Chris. The ones that start with 'R' by me. I suggest you create tests that start with 'N' or 'D'. And you can create a project that targets .Net 8 or later with XIDE as well.
We try to reference the runtime DLLs from the src\CompilerTests\Runtime folder, so they do not have to be in the GAC.
I suggest you create them and put them in New tree node.
If the tests are ready then we move them to either the Fixed tree node or the "Must Report Error" tree node.
After Chris or I validate them we put them in the right tree node.
To run the tests (after successful compilation) in the suite you reference them in the RuntimeTests.prg . I suspect you cannot do that for .Net 8 tests because that app is .Net Framework.
But we can of course also create a sibling app to run .Net 8 tests. We would have to adjust the batch file that runs the tests to compile and run 2 test-runners.

@cpyrgas

cpyrgas commented Jul 15, 2026

Copy link
Copy Markdown

Also, Nik, in order to run the tests from within XIDE, you need to right click on the "FIXED" node in the Project pad, and select "Rebuild all contained apps" from the context menu. Please make sure you have the XIDE 3 version installed, as it has some project file changes compared to XIDE for X# 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants