Skip to content
This repository has been archived by the owner on May 21, 2018. It is now read-only.

Commit

Permalink
Building version 2.3.0
Browse files Browse the repository at this point in the history
In this release:

- #35, #42: Thorough test suite
- #38: C# Nullable is no longer treated as TypeScript optional by
default
- #40: Add support for reserved property names (starting with @)
- #41: Add support for datetime offset
  • Loading branch information
cskeppstedt committed Apr 14, 2015
1 parent 7779816 commit 60a76e1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 27 deletions.
Binary file modified build/T4TS.Attributes.dll
Binary file not shown.
68 changes: 41 additions & 27 deletions build/T4TS.tt
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ Project GetProjectContainingT4File(DTE dte) {
tsMap.Keys.ToList().ForEach(codeClass =>
{
CodeElements baseClasses = codeClass.Bases;
if (baseClasses.Count > 0)
if (baseClasses != null && baseClasses.Count > 0)
{
CodeElement baseClass = baseClasses.Item(1);
if (baseClass != null)
Expand Down Expand Up @@ -459,10 +459,23 @@ Project GetProjectContainingT4File(DTE dte) {
return false;

var values = GetMemberValues(property, typeContext);

string name;
if (values.Name != null)
{
name = values.Name;
}
else
{
name = property.Name;
if (name.StartsWith("@"))
name = name.Substring(1);
}

member = new TypeScriptInterfaceMember
{
Name = values.Name ?? property.Name,
FullName = property.FullName,
Name = name,
//FullName = property.FullName,
Optional = values.Optional,
Ignore = values.Ignore,
Type = (string.IsNullOrWhiteSpace(values.Type))
Expand All @@ -471,9 +484,7 @@ Project GetProjectContainingT4File(DTE dte) {
};

if (member.Ignore)
{
return false;
}

if (values.CamelCase && values.Name == null)
member.Name = member.Name.Substring(0, 1).ToLowerInvariant() + member.Name.Substring(1);
Expand All @@ -493,14 +504,15 @@ Project GetProjectContainingT4File(DTE dte) {
if (TryGetAttribute(property.Attributes, MemberAttributeFullName, out attribute))
{
var values = GetAttributeValues(attribute);
if (values.ContainsKey("Optional"))
attributeOptional = values["Optional"] == "true";
bool parsedProperty;
if (values.ContainsKey("Optional") && bool.TryParse(values["Optional"], out parsedProperty))
attributeOptional = parsedProperty;

if (values.ContainsKey("CamelCase"))
attributeCamelCase = values["CamelCase"] == "true";
if (values.ContainsKey("CamelCase") && bool.TryParse(values["CamelCase"], out parsedProperty))
attributeCamelCase = parsedProperty;

if (values.ContainsKey("Ignore"))
attributeIgnore = values["Ignore"] == "true";
if (values.ContainsKey("Ignore") && bool.TryParse(values["Ignore"], out parsedProperty))
attributeIgnore = parsedProperty;

values.TryGetValue("Name", out attributeName);
values.TryGetValue("Type", out attributeType);
Expand Down Expand Up @@ -639,8 +651,11 @@ Project GetProjectContainingT4File(DTE dte) {

private void Traverse(CodeElements members)
{
foreach (var property in members.OfType<CodeProperty>())
WithProperty(property);
foreach (var property in members)
{
if (property is CodeProperty)
WithProperty((CodeProperty)property);
}
}
}

Expand All @@ -664,8 +679,11 @@ Project GetProjectContainingT4File(DTE dte) {

private void Traverse(CodeElements members)
{
foreach (var codeClass in members.OfType<CodeClass>())
WithCodeClass(codeClass);
foreach (object elem in members)
{
if (elem is CodeClass)
WithCodeClass((CodeClass)elem);
}
}
}

Expand Down Expand Up @@ -694,8 +712,12 @@ Project GetProjectContainingT4File(DTE dte) {
if (pi.FileCodeModel != null)
{
var codeElements = pi.FileCodeModel.CodeElements;
foreach (var ns in codeElements.OfType<CodeNamespace>())
WithNamespace(ns);

foreach (object elem in codeElements)
{
if (elem is CodeNamespace)
WithNamespace((CodeNamespace)elem);
}
}

if (pi.ProjectItems != null)
Expand Down Expand Up @@ -924,14 +946,6 @@ Project GetProjectContainingT4File(DTE dte) {
return GetTypeScriptType(codeType.AsFullName);
}

private ArrayType TryResolveEnumerableType(string typeFullName)
{
return new ArrayType
{
ElementType = GetTypeScriptType(typeFullName)
};
}

public TypescriptType GetTypeScriptType(string typeFullName)
{
InterfaceType interfaceType;
Expand Down Expand Up @@ -1023,7 +1037,7 @@ Project GetProjectContainingT4File(DTE dte) {
public string Name { get; set; }
public TypescriptType Type { get; set; }
public bool Optional { get; set; }
public string FullName { get; set; }
//public string FullName { get; set; }
public bool Ignore { get; set; }
}

Expand All @@ -1045,4 +1059,4 @@ Project GetProjectContainingT4File(DTE dte) {
}
}

#>
#>

0 comments on commit 60a76e1

Please sign in to comment.