-
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
17 changed files
with
178 additions
and
80 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
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
19 changes: 19 additions & 0 deletions
19
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
export type SimpleNullableRootType = { | ||
long?: null | string; | ||
uLong?: null | string; | ||
int?: null | number; | ||
uInt?: null | number; | ||
short?: null | number; | ||
uShort?: null | number; | ||
bool?: null | boolean; | ||
double?: null | number; | ||
decimal?: null | number; | ||
float?: null | number; | ||
byte?: null | number; | ||
sByte?: null | number; | ||
char?: null | string; | ||
dateTime?: null | (Date | string); | ||
timeSpan?: null | string; | ||
guid?: null | string; | ||
}; |
19 changes: 19 additions & 0 deletions
19
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
export type SimpleNullableRootType = { | ||
long?: null | string; | ||
uLong?: null | string; | ||
int?: null | number; | ||
uInt?: null | number; | ||
short?: null | number; | ||
uShort?: null | number; | ||
bool?: null | boolean; | ||
double?: null | number; | ||
decimal?: null | number; | ||
float?: null | number; | ||
byte?: null | number; | ||
sByte?: null | number; | ||
char?: null | string; | ||
dateTime?: null | (Date | string); | ||
timeSpan?: null | string; | ||
guid?: null | string; | ||
}; |
20 changes: 20 additions & 0 deletions
20
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
export type SimpleRootType = { | ||
long: string; | ||
uLong: string; | ||
int: number; | ||
uInt: number; | ||
short: number; | ||
uShort: number; | ||
bool: boolean; | ||
double: number; | ||
float: number; | ||
decimal: number; | ||
byte: number; | ||
sByte: number; | ||
char: string; | ||
string?: null | string; | ||
dateTime: (Date | string); | ||
timeSpan: string; | ||
guid: string; | ||
}; |
20 changes: 20 additions & 0 deletions
20
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
export type SimpleRootType = { | ||
long: string; | ||
uLong: string; | ||
int: number; | ||
uInt: number; | ||
short: number; | ||
uShort: number; | ||
bool: boolean; | ||
double: number; | ||
float: number; | ||
decimal: number; | ||
byte: number; | ||
sByte: number; | ||
char: string; | ||
string?: null | string; | ||
dateTime: (Date | string); | ||
timeSpan: string; | ||
guid: string; | ||
}; |
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
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
21 changes: 19 additions & 2 deletions
21
TypeScript.ContractGenerator/TypeBuilders/ArrayTypeBuildingContext.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
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