0.0.1 • Published 3 years ago

ts2csharp-auto v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

ts2csharp-auto

Convert typescript interfaces or classes to csharp classes.

Example usage

import { convertInterfacesToCSharp } from "ts2csharp-auto";

const myTypescriptClassString = `
interface MyTypescriptClass {
    propOne : any;
    propTwo : string;
    propThree : number[];
    propFour : boolean;
}

interface AnotherTypescriptClass {
    nestedObjectsInAList : MyTypescriptClass[];
    recursiveObject : AnotherTypescriptClass;
    isReallyCool : boolean;
}
`;

const myCsharpClass = convertInterfacesToCSharp(myTypescriptClassString);

console.log(myCsharpClass);

Generates the following code:

public class MyTypescriptClass {
    
    public object PropOne {get;set;}
    
    public string PropTwo {get;set;}
    
    public IEnumerable<int> PropThree {get;set;}
    
    public bool PropFour {get;set;}

}

public class AnotherTypescriptClass {

    public IEnumerable<MyTypescriptClass> NestedObjectsInAList {get;set;}

    public AnotherTypescriptClass RecursiveObject {get;set;}

    public bool IsReallyCool {get;set;}

}