Skip to content

Commit

Permalink
0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
pankleks committed Aug 3, 2016
1 parent 82674c9 commit ea16f58
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/Test/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using TypeScriptBuilder;

namespace Test
Expand All @@ -10,7 +9,10 @@ public class Program
public static void Main(string[] args)
{
var
builder = new TypeScriptGenerator().ExcludeType(typeof(Program));
builder = new TypeScriptGenerator(new TypeScriptGeneratorOptions
{
EmitComments = true
}).ExcludeType(typeof(Program));

builder
.AddCSType(typeof(TestA.Employee))
Expand Down
32 changes: 32 additions & 0 deletions src/Test/Test.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,64 @@
namespace TestA
{
// TestA.Entity`1[T]
export interface IFunkyEntity<T>
{
// T
id: T;
// TestB.Pair`2[System.Int32,TestA.Entity`1[System.Int32]]
map1: TestB.IPair<number, IFunkyEntity<number>>;
// TestB.Pair`2[System.String,TestA.Entity`1[System.String]]
map2: TestB.IPair<string, IFunkyEntity<string>>;
// System.DateTimeOffset
testAny: any;
}
// TestA.Equipment
export interface IEquipment
{
// System.Int32
code: number;
// System.Collections.Generic.Dictionary`2[System.Double,System.String]
objectDictionary: {};
// System.Int16
id: number;
// TestB.Pair`2[System.Int32,TestA.Entity`1[System.Int32]]
map1: TestB.IPair<number, IFunkyEntity<number>>;
// TestB.Pair`2[System.String,TestA.Entity`1[System.String]]
map2: TestB.IPair<string, IFunkyEntity<string>>;
// System.DateTimeOffset
testAny: any;
}
// TestA.Employee
export interface IEmployee extends IFunkyEntity<number>
{
// System.String
login: string;
// System.Nullable`1[TestA.EmployeeType]
employeeType?: UserType;
// System.String[]
arrayTest: string[];
// System.Collections.Generic.List`1[System.DateTime]
listTest: Date[];
// System.Collections.Generic.Dictionary`2[System.Int32,System.DateTime]
dictIntTest: { [index: number]: Date };
// System.Collections.Generic.Dictionary`2[System.String,System.DateTime]
dictStringTest: { [index: string]: Date };
// System.Collections.Generic.ICollection`1[TestA.Entity`1[System.DateTime]]
collectionTest: IFunkyEntity<Date>[];
// TestA.Stamp
createdBy: IStamp;
// TestA.Skip
skip: any;
}
// TestA.Stamp
export interface IStamp
{
// System.Int16
userId: number;
// System.String
user: string;
}
// TestA.EmployeeType
export enum UserType
{
Normal = 1,
Expand All @@ -41,14 +67,20 @@ namespace TestA
}
namespace TestB
{
// TestB.Strange`1[T]
export class Strange<T>
{
// System.Collections.Generic.Dictionary`2[System.Int32,TestA.Entity`1[T]]
readonly test: { [index: number]: TestA.IFunkyEntity<T> } = {};
}
// TestB.Pair`2[T1,T2]
export interface IPair<T1, T2>
{
// T1
t1: T1;
// T2
t2: T2;
// System.Int32
testProperty: number;
}
}
9 changes: 2 additions & 7 deletions src/TypeScriptBuilder/TypeScriptGeneratorOptions.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace TypeScriptBuilder
namespace TypeScriptBuilder
{
public class TypeScriptGeneratorOptions
{
public bool UseCamelCase = true; // changes fields names: TestField1 -> testField1
public bool EmitIinInterface = true; // use I in interface names: MyData -> IMyData
public bool EmitReadonly = true; // emits readonly for readonly fields (need TypeScript 2.0)
public bool EmitComments = false; // emits comments with C# type
public bool EmitComments = false; // emits comments with oryginal C# type
}
}

0 comments on commit ea16f58

Please sign in to comment.