elringus / bootsharp

Compile C# solution into single-file ES module with auto-generated JavaScript bindings and type definitions

Home Page:https://bootsharp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow generating of non-auto-implemented properties

promontis opened this issue · comments

From what I can see here https://github.com/Elringus/DotNetJS/blob/17c169b58bd6e66fbba0d54c690f5ca9c2cc9742/DotNet/Packer/DeclarationGenerator/TypeDeclarationGenerator.cs#L129 we currently only generate auto-implemented properties.

Is there any reason to restrict generating only those instead of all properties like get-only, set-only, or get-set-properties with implemented bodies (not auto-implemented)?

It should work with get-only. Other cases are irrelevant, as the types used for interop should be immutable POCOs.

I can imagine that we most likely want to use immutable POCOs. What do you think of the following code?

public string FirstName { get; set; }
public string LastName { get; set; }
public string FullName
{
    get { return $"{FirstName} {LastName}"; }
}

This currently does not generate FullName.

Not sure what you expect to be generated for FullName; it's basically a method.

Ok, let me just use an extra interop layer with C# Records.