Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a feature to support additional class properties in TypeGen #181

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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