From 60a76e1d354b5f64d27b62de763d6301aac8d511 Mon Sep 17 00:00:00 2001 From: Christoffer Skeppstedt Date: Tue, 14 Apr 2015 21:27:44 +0200 Subject: [PATCH] Building version 2.3.0 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 --- build/T4TS.Attributes.dll | Bin 5632 -> 5632 bytes build/T4TS.tt | 68 +++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/build/T4TS.Attributes.dll b/build/T4TS.Attributes.dll index fa18380133ac2410fece24e9a453d781afa36930..b10634ad47f51d6f3ede336b0488c576f658047b 100644 GIT binary patch delta 53 zcmZqBY0#O_!SXj3A`GNESo!d G%Q*mQv=vMM delta 53 zcmZqBY0#O_!Qz#CHh5!C54XT6*BkPG#J9U_eR3A`GN%$qxT G%Q*mC78JDr diff --git a/build/T4TS.tt b/build/T4TS.tt index 3f60c58..cbc856d 100644 --- a/build/T4TS.tt +++ b/build/T4TS.tt @@ -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) @@ -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)) @@ -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); @@ -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); @@ -639,8 +651,11 @@ Project GetProjectContainingT4File(DTE dte) { private void Traverse(CodeElements members) { - foreach (var property in members.OfType()) - WithProperty(property); + foreach (var property in members) + { + if (property is CodeProperty) + WithProperty((CodeProperty)property); + } } } @@ -664,8 +679,11 @@ Project GetProjectContainingT4File(DTE dte) { private void Traverse(CodeElements members) { - foreach (var codeClass in members.OfType()) - WithCodeClass(codeClass); + foreach (object elem in members) + { + if (elem is CodeClass) + WithCodeClass((CodeClass)elem); + } } } @@ -694,8 +712,12 @@ Project GetProjectContainingT4File(DTE dte) { if (pi.FileCodeModel != null) { var codeElements = pi.FileCodeModel.CodeElements; - foreach (var ns in codeElements.OfType()) - WithNamespace(ns); + + foreach (object elem in codeElements) + { + if (elem is CodeNamespace) + WithNamespace((CodeNamespace)elem); + } } if (pi.ProjectItems != null) @@ -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; @@ -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; } } @@ -1045,4 +1059,4 @@ Project GetProjectContainingT4File(DTE dte) { } } -#> +#> \ No newline at end of file