elringus / bootsharp

Compile C# solution into single-file ES module with auto-generated JavaScript bindings and type definitions
https://sharp.elringus.com
MIT License
673 stars 36 forks source link

TS Enum declarations loose values #113

Closed CADBIMDeveloper closed 1 year ago

CADBIMDeveloper commented 1 year ago

Hi @Elringus ,

There is a problem with exposing .Net enums to the TypeScript. For example, I have an enum in C# code like:

public enum Severity
{
    Warning = 1,

    Error = 2
}

Values are missed when it's translated into TS like:

export enum Severity {
    Warning,
    Error
}

Moreover, when I try to pass this like that:

dotnet.Something.someFunction({ severety: SomeNamespace.Severity.Error });

it fails with serialization exception, so I have to pass it like

dotnet.Something.someFunction({ severety: 2 });

I can try to prepare a PR to fix that, but want to discuss the details first

elringus commented 1 year ago

Check this: https://github.com/Elringus/DotNetJS#json-serializer-options

CADBIMDeveloper commented 1 year ago

Thanks, will take a look

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 14 days with no activity. It will be automatically closed in 7 days.