{"id":28265609,"url":"https://github.com/jvorssel/sushi","last_synced_at":"2026-04-01T17:17:51.632Z","repository":{"id":65163152,"uuid":"122117293","full_name":"jvorssel/Sushi","owner":"jvorssel","description":"Converting C# classes to Javascript \u0026 Typescript classes in different scopes.","archived":false,"fork":false,"pushed_at":"2024-12-02T18:58:57.000Z","size":2049,"stargazers_count":3,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-17T01:32:32.728Z","etag":null,"topics":["c-sharp","c-sharp-library","code-generation","code-generator","compiler","ecmascript","ecmascript6","extension-methods","framework","javascript","model","typescript","unit-test","validation","validator"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jvorssel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-02-19T20:34:57.000Z","updated_at":"2024-12-02T18:58:57.000Z","dependencies_parsed_at":"2024-03-24T13:48:27.836Z","dependency_job_id":null,"html_url":"https://github.com/jvorssel/Sushi","commit_stats":{"total_commits":76,"total_committers":1,"mean_commits":76.0,"dds":0.0,"last_synced_commit":"3792dbb2096df5abc2e0d7c3237ffc168dd81ed1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jvorssel/Sushi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvorssel%2FSushi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvorssel%2FSushi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvorssel%2FSushi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvorssel%2FSushi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jvorssel","download_url":"https://codeload.github.com/jvorssel/Sushi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvorssel%2FSushi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270796221,"owners_count":24647319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","c-sharp-library","code-generation","code-generator","compiler","ecmascript","ecmascript6","extension-methods","framework","javascript","model","typescript","unit-test","validation","validator"],"created_at":"2025-05-20T12:17:14.721Z","updated_at":"2026-03-27T06:02:07.094Z","avatar_url":"https://github.com/jvorssel.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"-# SushiScript Library for converting .NET classes to script language classes.\n\n**Currently supports**\n\n- **[TypeScript](https://github.com/jvorssel/Sushi/tree/master/TestResults)**\n- **[ECMAScript 5](https://github.com/jvorssel/Sushi/tree/master/TestResults)** \n- **[ECMAScript 6](https://github.com/jvorssel/Sushi/tree/master/TestResults)**\n\n\n**Author**\n\nJeroen Vorsselman @ 2024\n\n**[GitHub](https://github.com/jvorssel)**\n\n**[NuGet](https://www.nuget.org/packages/SushiScriptCore/1.0.0)**\n\n---\n\n## Features\n- Converts .NET classes to script languages (typescript / ECMAScript)\n- Compiled using **[.NET Standard 2.0](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0)**\n- Supports native types, type inheritance, generics and enum types\n- Adds documentation using the generated MS build XML file\n- 95% Code coverage\n---\n## About\n``` \nstring xmlDocPath =  Path.Combine(Environment.CurrentDirectory, \"Sushi.tests.xml\");\n\n// Specify the types to convert using a Type[] or Assembly.ExportedTypes.\nAssembly assembly = typeof(PersonViewModel).Assembly;\nSushiConverter converter = new SushiConverter(assembly).UseDocumentation(xmlDocPath);\n\n// Specify the script language and convert by invoking ToString().\nConverterOptions options = new ConverterOptions(excludeComments: true);\nstring result = converter.TypeScript(options).ToString();\n```\n\nCreate a new `SushiConverter` instance with the given `Assembly` or `Type[]` that contain the types you want to convert.  \nThese classes must be decorated with the `ConvertToScriptAttribute` or inherit the `IScriptModel` interface. Classes can be excluded using the `IgnoreForScriptAttribute`.\nThe converter contains a collection of type- and enum-descriptors. These are used to generate script models.  \n\n\n## Helpers\nYou can check if a type exists using: \n`IsSushiType(IConvertModels converter, Type type, out Type resolvedType) : boolean`\n\nYou can convert types using:\n`TypeScriptConverter.ResolveScriptType(Type type, string prefix = \"\") : string`\n\nYou can get the script default value using:\n`TypeScriptConverter.ResolveDefaultValue(IPropertyDescriptor prop) : string`\n\n## Conversion result\n### C# class\n```\n/// \u003csummary\u003e\n///     Simple model to verify complex types.\n/// \u003c/summary\u003e\npublic sealed class TypeModel : ViewModel\n{\n  /// \u003csummary\u003e\n  ///     A nullable boolean.\n  /// \u003c/summary\u003e\n  public bool? NullableBool { get; set; } = null;\n  \n  /// \u003csummary\u003e\n  ///     A nullable string, defaults to null.\n  /// \u003c/summary\u003e\n  public string? NullableString { get; set; } = null;\n  \n  /// \u003csummary\u003e\n  ///     A readonly string.\n  /// \u003c/summary\u003e\n  public readonly string ReadonlyString = \"readonly\";\n  \n  /// \u003cinheritdoc cref=\"Guid\" /\u003e\n  public new Guid Guid { get; set; } = Guid.NewGuid();\n  \n  /// \u003csummary\u003e\n  ///     A DateTime instance.\n  /// \u003c/summary\u003e\n  public DateTime Date{get;set;} = DateTime.Now;\n  \n  public StudentViewModel Student { get; set; } = new StudentViewModel();\n  \n  public List\u003cStudentViewModel\u003e Students { get; set; }\n  \n  public Dictionary\u003cstring, StudentViewModel[]\u003e StudentPerClass { get; set; } = new ();\n}\n```\n### Typescript class\n\n```\n/**\n * Simple model to verify complex types.\n * Sushi.Tests.Models.TypeModel\n * @extends ViewModel\n */\nexport class TypeModel extends ViewModel {\n\n    /**\n     * A nullable boolean.\n     * @type (boolean | null)\n     */\n    nullableBool: boolean | null = null;\n\n    /**\n     * A nullable string, defaults to null.\n     * @type (string | null)\n     */\n    nullableString: string | null = null;\n\n    /**\n     * .\n     * @type (string)\n     */\n    override guid: string = \"f64db319-ebb2-4b6d-89f4-18abbb2604e7\";\n\n    /**\n     * A DateTime instance.\n     * @type (Date | string | null)\n     */\n    date!: Date | string | null;\n    student: StudentViewModel = new StudentViewModel();\n    students: Array\u003cStudentViewModel\u003e = [];\n    studentPerClass: { [key: string]: Array\u003cStudentViewModel\u003e } = {};\n\n    /**\n     * A readonly string.\n     * @type (string)\n     */\n    static readonly readonlyString: string = \"readonly\";\n\n    constructor(value: Partial\u003cTypeModel\u003e = {}) {\n        super(value);\n\n        if (value.nullableBool !== undefined) this.nullableBool = value.nullableBool;\n        if (value.nullableString !== undefined) this.nullableString = value.nullableString;\n        if (value.guid !== undefined) this.guid = value.guid;\n        if (value.date !== undefined) this.date = value.date;\n        if (value.student !== undefined) this.student = value.student;\n        if (value.students !== undefined) this.students = value.students;\n        if (value.studentPerClass !== undefined) this.studentPerClass = value.studentPerClass;\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvorssel%2Fsushi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjvorssel%2Fsushi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvorssel%2Fsushi/lists"}