Skip to content

Conversation

stealthAngel
Copy link

@stealthAngel stealthAngel commented Nov 18, 2023

This feature allows users to define extra properties for TypeScript classes that are not present in the original C# class. Here is a sample usage in a test scenario:

private class ClassWithAdditionalPropertiesGenerationSpec : GenerationSpec
{
    public ClassWithAdditionalPropertiesGenerationSpec()
    {
        AddClass<ClassWithAdditionalClassProperties>()
            .WithAdditionalProperty("public email", "string")
            .WithAdditionalProperty("greetingMessage", "string", "'Hello, World!'")
            .WithAdditionalProperty("emptyString", "string", "''")
            .WithAdditionalProperty("creationDate", "Date")
            .WithAdditionalProperty("username", "string")
            .WithAdditionalProperty("age", "number")
            .WithAdditionalProperty("status", "'active' | 'inactive' | 'pending'");
    }
}

outputs:

export class ClassWithAdditionalClassProperties {
    // Additional properties
    public email: string;
    greetingMessage: string = 'Hello, World!';
    emptyString: string = '';
    creationDate: Date;
    username: string;
    age: number;
    status: 'active' | 'inactive' | 'pending';
}

The reason i wanted this in the first place is that i want to be able to have a type propeperty so i know what the name of my class is without changing my c# files e.g.

class Person {
public readonly type 'Person';
}

@stealthAngel
Copy link
Author

@jburzynski can you look at this commit please

@stealthAngel
Copy link
Author

@jburzynski Hey can I kindly ask you again to look at this, i'd really appreciate it. I want to use this feature in my project.

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.

1 participant