0.3.3 • Published 2 years ago

ts-csharp v0.3.3

Weekly downloads
60
License
ISC
Repository
github
Last release
2 years ago

ts-csharp

Convert typescript interfaces or classes to csharp classes.

Example usage

import { convertInterfacesToCSharp } from "ts-csharp";

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 {

    [JsonProperty("propOne")]
    public object PropOne;

    [JsonProperty("propTwo")]
    public string PropTwo;

    [JsonProperty("propThree")]
    public IEnumerable<int> PropThree;

    [JsonProperty("propFour")]
    public bool PropFour;

}

public class AnotherTypescriptClass {

    [JsonProperty("nestedObjectsInAList")]
    public IEnumerable<MyTypescriptClass> NestedObjectsInAList;

    [JsonProperty("recursiveObject")]
    public AnotherTypescriptClass RecursiveObject;

    [JsonProperty("isReallyCool")]
    public bool IsReallyCool;

}
0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

3 years ago

0.3.0

4 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago