-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
251 additions
and
645 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
TypeScript.ContractGenerator.Tests/CustomTypeGenerators/CollectionTypeBuildingContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using SkbKontur.TypeScript.ContractGenerator.CodeDom; | ||
using SkbKontur.TypeScript.ContractGenerator.TypeBuilders; | ||
|
||
namespace SkbKontur.TypeScript.ContractGenerator.Tests.CustomTypeGenerators | ||
{ | ||
public class CollectionTypeBuildingContext : ITypeBuildingContext | ||
{ | ||
public CollectionTypeBuildingContext(Type arrayType) | ||
{ | ||
elementType = arrayType.GetGenericArguments()[0]; | ||
} | ||
|
||
public static bool Accept(Type type) | ||
{ | ||
return type.IsGenericType && | ||
type.GetGenericArguments().Length == 1 && | ||
type.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ICollection<>)); | ||
} | ||
|
||
public bool IsDefinitionBuilt => true; | ||
|
||
public void Initialize(ITypeGenerator typeGenerator) | ||
{ | ||
} | ||
|
||
public void BuildDefinition(ITypeGenerator typeGenerator) | ||
{ | ||
} | ||
|
||
public FlowTypeType ReferenceFrom(FlowTypeUnit targetUnit, ITypeGenerator typeGenerator) | ||
{ | ||
var itemType = typeGenerator.ResolveType(elementType).ReferenceFrom(targetUnit, typeGenerator); | ||
return new FlowTypeArrayType(itemType); | ||
} | ||
|
||
private readonly Type elementType; | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
TypeScript.ContractGenerator.Tests/CustomTypeGenerators/ListTypeBuildingContext.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 10 additions & 41 deletions
51
TypeScript.ContractGenerator.Tests/Files/CustomGenerator/nullable-types.expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,19 @@ | ||
|
||
export type SimpleNullableRootType = { | ||
long?: null | string; | ||
uLong?: null | UInt64; | ||
uLong?: null | string; | ||
int?: null | number; | ||
uInt?: null | UInt32; | ||
short?: null | Int16; | ||
uShort?: null | UInt16; | ||
uInt?: null | number; | ||
short?: null | number; | ||
uShort?: null | number; | ||
bool?: null | boolean; | ||
double?: null | Double; | ||
double?: null | number; | ||
decimal?: null | number; | ||
float?: null | Single; | ||
byte?: null | Byte; | ||
sByte?: null | SByte; | ||
char?: null | Char; | ||
float?: null | number; | ||
byte?: null | number; | ||
sByte?: null | number; | ||
char?: null | string; | ||
dateTime?: null | (Date | string); | ||
timeSpan?: null | TimeSpan; | ||
timeSpan?: null | string; | ||
guid?: null | string; | ||
}; | ||
export type UInt64 = { | ||
}; | ||
export type UInt32 = { | ||
}; | ||
export type Int16 = { | ||
}; | ||
export type UInt16 = { | ||
}; | ||
export type Double = { | ||
}; | ||
export type Single = { | ||
}; | ||
export type Byte = { | ||
}; | ||
export type SByte = { | ||
}; | ||
export type Char = { | ||
}; | ||
export type TimeSpan = { | ||
ticks: string; | ||
days: number; | ||
hours: number; | ||
milliseconds: number; | ||
minutes: number; | ||
seconds: number; | ||
totalDays: Double; | ||
totalHours: Double; | ||
totalMilliseconds: Double; | ||
totalMinutes: Double; | ||
totalSeconds: Double; | ||
}; |
51 changes: 10 additions & 41 deletions
51
TypeScript.ContractGenerator.Tests/Files/CustomGenerator/nullable-types.expected.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,19 @@ | ||
|
||
export type SimpleNullableRootType = { | ||
long?: null | string; | ||
uLong?: null | UInt64; | ||
uLong?: null | string; | ||
int?: null | number; | ||
uInt?: null | UInt32; | ||
short?: null | Int16; | ||
uShort?: null | UInt16; | ||
uInt?: null | number; | ||
short?: null | number; | ||
uShort?: null | number; | ||
bool?: null | boolean; | ||
double?: null | Double; | ||
double?: null | number; | ||
decimal?: null | number; | ||
float?: null | Single; | ||
byte?: null | Byte; | ||
sByte?: null | SByte; | ||
char?: null | Char; | ||
float?: null | number; | ||
byte?: null | number; | ||
sByte?: null | number; | ||
char?: null | string; | ||
dateTime?: null | (Date | string); | ||
timeSpan?: null | TimeSpan; | ||
timeSpan?: null | string; | ||
guid?: null | string; | ||
}; | ||
export type UInt64 = { | ||
}; | ||
export type UInt32 = { | ||
}; | ||
export type Int16 = { | ||
}; | ||
export type UInt16 = { | ||
}; | ||
export type Double = { | ||
}; | ||
export type Single = { | ||
}; | ||
export type Byte = { | ||
}; | ||
export type SByte = { | ||
}; | ||
export type Char = { | ||
}; | ||
export type TimeSpan = { | ||
ticks: string; | ||
days: number; | ||
hours: number; | ||
milliseconds: number; | ||
minutes: number; | ||
seconds: number; | ||
totalDays: Double; | ||
totalHours: Double; | ||
totalMilliseconds: Double; | ||
totalMinutes: Double; | ||
totalSeconds: Double; | ||
}; |
51 changes: 10 additions & 41 deletions
51
TypeScript.ContractGenerator.Tests/Files/CustomGenerator/simple-types.expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,20 @@ | ||
|
||
export type SimpleRootType = { | ||
long: string; | ||
uLong: UInt64; | ||
uLong: string; | ||
int: number; | ||
uInt: UInt32; | ||
short: Int16; | ||
uShort: UInt16; | ||
uInt: number; | ||
short: number; | ||
uShort: number; | ||
bool: boolean; | ||
double: Double; | ||
float: Single; | ||
double: number; | ||
float: number; | ||
decimal: number; | ||
byte: Byte; | ||
sByte: SByte; | ||
char: Char; | ||
byte: number; | ||
sByte: number; | ||
char: string; | ||
string?: null | string; | ||
dateTime: (Date | string); | ||
timeSpan: TimeSpan; | ||
timeSpan: string; | ||
guid: string; | ||
}; | ||
export type UInt64 = { | ||
}; | ||
export type UInt32 = { | ||
}; | ||
export type Int16 = { | ||
}; | ||
export type UInt16 = { | ||
}; | ||
export type Double = { | ||
}; | ||
export type Single = { | ||
}; | ||
export type Byte = { | ||
}; | ||
export type SByte = { | ||
}; | ||
export type Char = { | ||
}; | ||
export type TimeSpan = { | ||
ticks: string; | ||
days: number; | ||
hours: number; | ||
milliseconds: number; | ||
minutes: number; | ||
seconds: number; | ||
totalDays: Double; | ||
totalHours: Double; | ||
totalMilliseconds: Double; | ||
totalMinutes: Double; | ||
totalSeconds: Double; | ||
}; |
51 changes: 10 additions & 41 deletions
51
TypeScript.ContractGenerator.Tests/Files/CustomGenerator/simple-types.expected.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,20 @@ | ||
|
||
export type SimpleRootType = { | ||
long: string; | ||
uLong: UInt64; | ||
uLong: string; | ||
int: number; | ||
uInt: UInt32; | ||
short: Int16; | ||
uShort: UInt16; | ||
uInt: number; | ||
short: number; | ||
uShort: number; | ||
bool: boolean; | ||
double: Double; | ||
float: Single; | ||
double: number; | ||
float: number; | ||
decimal: number; | ||
byte: Byte; | ||
sByte: SByte; | ||
char: Char; | ||
byte: number; | ||
sByte: number; | ||
char: string; | ||
string?: null | string; | ||
dateTime: (Date | string); | ||
timeSpan: TimeSpan; | ||
timeSpan: string; | ||
guid: string; | ||
}; | ||
export type UInt64 = { | ||
}; | ||
export type UInt32 = { | ||
}; | ||
export type Int16 = { | ||
}; | ||
export type UInt16 = { | ||
}; | ||
export type Double = { | ||
}; | ||
export type Single = { | ||
}; | ||
export type Byte = { | ||
}; | ||
export type SByte = { | ||
}; | ||
export type Char = { | ||
}; | ||
export type TimeSpan = { | ||
ticks: string; | ||
days: number; | ||
hours: number; | ||
milliseconds: number; | ||
minutes: number; | ||
seconds: number; | ||
totalDays: Double; | ||
totalHours: Double; | ||
totalMilliseconds: Double; | ||
totalMinutes: Double; | ||
totalSeconds: Double; | ||
}; |
Oops, something went wrong.