diff --git a/build/T4TS.Attributes.dll b/build/T4TS.Attributes.dll index fa18380..b10634a 100644 Binary files a/build/T4TS.Attributes.dll and b/build/T4TS.Attributes.dll differ 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