.NET bindings to the Haiku API

It looks already promising, doesn’t it? :grinning:

4 Likes

The syntax highlighting looks great! If only we could port OmniSharp and some kind of .NET Core debugger…

I’ll try with Omnisharp later tonight… :hand_with_index_finger_and_thumb_crossed:

Maybe you know how to solve this:

dotnet build .build/.build.csproj /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
/boot/system/non-packaged/bin/dotnet/sdk/8.0.101-servicing.23631.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(154,5): error NETSDK1084: There is no application host available for the specified RuntimeIdentifier 'haiku-x64'. [/boot/home/workspace/csharp-language-server-protocol/.build/.build.csproj]
/boot/system/non-packaged/bin/dotnet/sdk/8.0.101-servicing.23631.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(154,5): error NETSDK1084: There is no application host available for the specified RuntimeIdentifier 'haiku-x64'. [/boot/home/workspace/csharp-language-server-protocol/.build/.build.csproj]
/boot/system/non-packaged/bin/dotnet/sdk/8.0.101-servicing.23631.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(154,5): error NETSDK1084: There is no application host available for the specified RuntimeIdentifier 'haiku-x64'. [/boot/home/workspace/csharp-language-server-protocol/.build/.build.csproj]
/boot/system/non-packaged/bin/dotnet/sdk/8.0.101-servicing.23631.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(154,5): error NETSDK1084: There is no application host available for the specified RuntimeIdentifier 'haiku-x64'. [/boot/home/workspace/csharp-language-server-protocol/.build/.build.csproj]

First time seeing this error. Unfortunately, without further logs, I really don’t know. --verbosity detailed might help.

Getting more detailed logs shows a number of problems that occur with every single project I try to compile (for example Omnisharp and ILSpyCmd).

These occur trying to install packages via nuget under the form of:

error NU3037: The author primary signature validity period has expired.

and

error NU3028: The author primary signature's timestamping certificate is not trusted by the trust provider.

here’s an excerpt of the build log of ILSpyCmd:

~/workspace/ILSpy/ICSharpCode.ILSpyCmd> dotnet build
MSBuild version 17.9.0-ci-23631-01+66ed1d8e7 for .NET
  Determining projects to restore...
  Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json': 
  Signature type: Author
  Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json':   Subject Name: CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
  Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json':   SHA256 hash: AA12DA22A49BCE7D5C1AE64CC1F3D892F150DA76140F210ABD2CBFFCA2C18A27
  Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json':   Valid from: 9/30/2020 12:00:00 AM to 10/5/2023 12:00:00 PM
/boot/home/workspace/ILSpy/ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj : error NU3037: Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json': The author primary signature validity period has expired. [/boot/home/workspace/ILSpy/ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj]
/boot/home/workspace/ILSpy/ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj : error NU3028: Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json': The author primary signature's timestamping certificate is not trusted by the trust provider. [/boot/home/workspace/ILSpy/ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj]
  Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json': 
  Signature type: Repository
  Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json':   Subject Name: CN=NuGet.org Repository by Microsoft, O=NuGet.org Repository by Microsoft, L=Redmond, S=Washington, C=US
  Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json':   SHA256 hash: 5A2901D6ADA3D18260B9C6DFE2133C95D74B9EEF6AE0E5DC334C8454D1477DF4
  Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json':   Valid from: 2/16/2021 12:00:00 AM to 5/15/2024 11:59:59 PM
/boot/home/workspace/ILSpy/ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj : error NU3028: Package 'System.Collections.Immutable 6.0.0' from source 'https://api.nuget.org/v3/index.json': The repository countersignature's timestamping certificate is not trusted by the trust provider. [/boot/home/workspace/ILSpy/ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj]

I’ve found tons of posts around but none clarifies why this is happening. Is there an issue with the certificate validation in our .NET custom build?

I’ve actually encountered that error when trying to build dotnet from source on Haiku.

To be fair, the posts are not really related, but they did help me solve the problem.

No, this is an issue with the certificates that come with Haiku. You will need to add this certificate:

to the system certificate repository. I don’t remember the exact folder as it has been quite a long time.

I guess it worked but I need to make further tests. Thanks!

On another topic… It seems that the layout family of classes have been produced in Haiku.dll but they do not have a public constructor (BLayout, BGroupLayout, BLayoutItem, etc.). Have these been disabled/not published for a reason?

That seems sus, can you check if they even have private/protected constructors at all?

The Interface Kit has surely been generated, and these classes don’t seem to have been treated specially in any way.

This is the code:

	public readonly BButton fButton;
	public readonly BStringView fStringView;
	private readonly uint kMsgButtonClick = 1;

    public MainWindow()
        : base(new BRect(), "Main Window", WindowType.TitledWindow, B_QUIT_ON_WINDOW_CLOSE)
    {
        MoveTo(100, 100);
        ResizeTo(400, 400);

		fStringView = new BStringView(new BRect(10, 10, 400 ,30), null, "BStringView");
		fButton = new BButton(new BRect(10, 50, 200, 30), null, "BButton", new BMessage(kMsgButtonClick));

		BGroupLayout group = new BGroupLayout(B_VERTICAL);
		SetLayout(group);
		group.AddView(fStringView);
		group.AddView(fButton);
    }

And here’s the build log:

--------------------------------   Build HaikuApp (Release) started   --------------------------------
MSBuild version 17.9.0-ci-23631-01+66ed1d8e7 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
/boot/system/non-packaged/bin/dotnet/sdk/8.0.101-servicing.23631.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(311,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [/boot/home/workspace/dotnet/HaikuApp/HaikuApp.csproj]
/boot/home/workspace/dotnet/HaikuApp/MainWindow.cs(23,28): error CS1729: 'BGroupLayout' does not contain a constructor that takes 1 arguments [/boot/home/workspace/dotnet/HaikuApp/HaikuApp.csproj]
/boot/home/workspace/dotnet/HaikuApp/MainWindow.cs(24,13): error CS1503: Argument 1: cannot convert from 'Haiku.Interface.BGroupLayout' to 'Haiku.Interface.BLayout' [/boot/home/workspace/dotnet/HaikuApp/HaikuApp.csproj]
/boot/home/workspace/dotnet/HaikuApp/MainWindow.cs(25,9): error CS1061: 'BGroupLayout' does not contain a definition for 'AddView' and no accessible extension method 'AddView' accepting a first argument of type 'BGroupLayout' could be found (are you missing a using directive or an assembly reference?) [/boot/home/workspace/dotnet/HaikuApp/HaikuApp.csproj]
/boot/home/workspace/dotnet/HaikuApp/MainWindow.cs(26,9): error CS1061: 'BGroupLayout' does not contain a definition for 'AddView' and no accessible extension method 'AddView' accepting a first argument of type 'BGroupLayout' could be found (are you missing a using directive or an assembly reference?) [/boot/home/workspace/dotnet/HaikuApp/HaikuApp.csproj]

Build FAILED.

/boot/home/workspace/dotnet/HaikuApp/MainWindow.cs(23,28): error CS1729: 'BGroupLayout' does not contain a constructor that takes 1 arguments [/boot/home/workspace/dotnet/HaikuApp/HaikuApp.csproj]
/boot/home/workspace/dotnet/HaikuApp/MainWindow.cs(24,13): error CS1503: Argument 1: cannot convert from 'Haiku.Interface.BGroupLayout' to 'Haiku.Interface.BLayout' [/boot/home/workspace/dotnet/HaikuApp/HaikuApp.csproj]
/boot/home/workspace/dotnet/HaikuApp/MainWindow.cs(25,9): error CS1061: 'BGroupLayout' does not contain a definition for 'AddView' and no accessible extension method 'AddView' accepting a first argument of type 'BGroupLayout' could be found (are you missing a using directive or an assembly reference?) [/boot/home/workspace/dotnet/HaikuApp/HaikuApp.csproj]
/boot/home/workspace/dotnet/HaikuApp/MainWindow.cs(26,9): error CS1061: 'BGroupLayout' does not contain a definition for 'AddView' and no accessible extension method 'AddView' accepting a first argument of type 'BGroupLayout' could be found (are you missing a using directive or an assembly reference?) [/boot/home/workspace/dotnet/HaikuApp/HaikuApp.csproj]
    0 Warning(s)
    4 Error(s)

Time Elapsed 00:00:02.22
--------------------------------   Build HaikuApp (Release) ended   ----------------------------------

Here’s what ILSpy detects:

You can clearly see that there are no public constructors, only private and protected.
I don’t expect to see the layout builders being them C++ templates, but BLayout related classes are plain C++ classes and should be definitely there, I think

Don’t have my dev machine right now so I can’t run a full local build and debug stuff, but looking at the build logs, I can see the issue:

Incomplete class BLayout has no complete definition
[...]
Incomplete class BGroupLayout has no complete definition
[...]
Incomplete class BLayoutItem has no complete definition

This log is created here:

FindCompleteClass is a helper function provided by CppSharp:

To properly debug this, one would need to run the generator on Linux. To run this, you will need to export the HAIKU_API_GENERATOR_ROOT_DIR variable to some cross-compile rootfs, such as the one provided by jessicah’s script. If you are already cross-compiling .NET or having HyClone, no additional configuration is needed, the generator will make use of these prefixes.

After running the project, we would need to inspect the syntax tree. Somehow, the generators missed the definitions, or maybe I have missed a few headers?

I don’t have access to a linux machine and honestly don’t plan to fire one up.
What about MacOS instead? Do you think it would be a viable solution?

No, you have not.
The problem is more deep, the generator completely missed other classes: BLayoutContextListener, BAbstractLayout, BAbstractLayoutItem, BTwoDimensionalLayout, and many more.

CppSharp should support macOS (as long as you’re not running M1). Browsing through the source code, I guess CppSharp should be built with ELF binaries support even on macOS.

The hard part for now would be getting a rootfs, though unlike HyClone, you won’t need everything: Just the system include and system library directories are enough. It should be possible to copy these using an scp from your Haiku setup.

OMNISHARP

I’ve managed to build and run OmniSharp not without a number of dirty hacks, but this is another story…

Now the problem is that MSBuildLocator fails in locating MSBuild although in theory OmniSharp should locate it automatically via SdkResolver. There are fallback options for VSStudio and Mono but they are not applicable.
Any thoughts why the SDK can’t resolve this path?

1 Like

What I understand from the logs is that the SDK is resolved, but the MSBuild version is wrongly detected.

How does OmniSharp detect the MSBuild version, and what did it discover?

I solved this and now Omnisharp runs well (only the stdio server, the http flavour does not compile for some reason).
Unfortunately the LSP mode does not work, apparently there is a bug never fixed due to a lock in an async/await cal.
The version that comes with the vscode C# extension works though.
I’ll keep investigating…

I think this deserves a bit of celebration :confetti_ball:
OmniSharp up and running in LSP mode communicating with Genio!
They talk but don’t understand each other quite well at the moment. But we’ll get there!

15 Likes

For those interested in the progress with Genio + OmniSharp, I’ve managed to get Completion, Hover and SignatureHelp work. Plus “Problems” and some formatting warnings.

20 Likes

I’ve seen people use InteliJ, I wonder if Rider will run? I have a license. I just have no hardware to use currently as I’m between main machines awaiting a new main to free up my MacMini again.