From 2fa775f908a1ec5206f6ad030572e3c13b48ed42 Mon Sep 17 00:00:00 2001 From: Christoffer Skeppstedt Date: Tue, 15 Jul 2014 21:59:15 +0200 Subject: [PATCH] Building version 2.2.0 --- T4TS.Build/T4TS.d.ts | 10 +++++++++ T4TS.Build/T4TS.tt | 46 +++++++++++++++++++++++++++++--------- build/T4TS.Attributes.dll | Bin 5632 -> 5632 bytes build/T4TS.tt | 46 +++++++++++++++++++++++++++++--------- 4 files changed, 82 insertions(+), 20 deletions(-) diff --git a/T4TS.Build/T4TS.d.ts b/T4TS.Build/T4TS.d.ts index 96450d6..a976d64 100644 --- a/T4TS.Build/T4TS.d.ts +++ b/T4TS.Build/T4TS.d.ts @@ -12,6 +12,13 @@ } // -- End global interfaces +declare module External { + /** Generated from T4TS.Example.Models.ModelFromDifferentProject **/ + export interface ModelFromDifferentProject { + Id: number; + } +} + declare module Fooz { /** Generated from T4TS.Example.Models.Foobar **/ export interface IFoobar { @@ -50,6 +57,9 @@ declare module T4TS { SomeString4: string; Recursive4: Fooz.IFoobar; } + /** Generated from T4TS.Example.Models.InheritanceTestExternal **/ + export interface InheritanceTestExternal extends External.ModelFromDifferentProject { + } /** Generated from T4TS.Example.Models.Inherited **/ export interface OverridenName { OtherName?: string; diff --git a/T4TS.Build/T4TS.tt b/T4TS.Build/T4TS.tt index 1628642..20ca884 100644 --- a/T4TS.Build/T4TS.tt +++ b/T4TS.Build/T4TS.tt @@ -39,7 +39,7 @@ List GetDataToRender() { if (project == null) throw new Exception("Could not find the VS project containing the T4TS file."); - var generator = new CodeTraverser(project, GetSettings()); + var generator = new CodeTraverser(dte.Solution, GetSettings()); return generator.GetAllInterfaces().ToList(); } @@ -59,8 +59,7 @@ Project GetProjectContainingT4File(DTE dte) { return projectItem.ContainingProject; } - - public class InterfaceOutputAppender : OutputAppender +public class InterfaceOutputAppender : OutputAppender { private bool InGlobalModule { get; set; } @@ -406,6 +405,33 @@ Project GetProjectContainingT4File(DTE dte) { } } + public class SolutionTraverser + { + public Action WithNamespace { get; private set; } + + public SolutionTraverser(Solution solution, Action withNamespace) + { + if (solution == null) + throw new ArgumentNullException("solution"); + + if (withNamespace == null) + throw new ArgumentNullException("withNamespace"); + + WithNamespace = withNamespace; + + if (solution.Projects != null) + Traverse(solution.Projects); + } + + private void Traverse(Projects projects) + { + foreach (Project project in projects) + { + new ProjectTraverser(project, WithNamespace); + } + } + } + public class ArrayType: TypescriptType { public TypescriptType ElementType { get; set; } @@ -526,21 +552,21 @@ Project GetProjectContainingT4File(DTE dte) { public class CodeTraverser { - public Project Project { get; private set; } + public Solution Solution { get; private set; } public Settings Settings { get; private set; } private static readonly string InterfaceAttributeFullName = "T4TS.TypeScriptInterfaceAttribute"; private static readonly string MemberAttributeFullName = "T4TS.TypeScriptMemberAttribute"; - public CodeTraverser(Project project, Settings settings) + public CodeTraverser(Solution solution, Settings settings) { - if (project == null) - throw new ArgumentNullException("project"); + if (solution == null) + throw new ArgumentNullException("solution"); if (settings == null) throw new ArgumentNullException("settings"); - this.Project = project; + Solution = solution; this.Settings = settings; } @@ -549,7 +575,7 @@ Project GetProjectContainingT4File(DTE dte) { var typeContext = new TypeContext(this.Settings); var partialClasses = new Dictionary(); - new ProjectTraverser(this.Project, (ns) => + new SolutionTraverser(this.Solution, (ns) => { new NamespaceTraverser(ns, (codeClass) => { @@ -574,7 +600,7 @@ Project GetProjectContainingT4File(DTE dte) { var byModuleName = new Dictionary(); var tsMap = new Dictionary(); - new ProjectTraverser(this.Project, (ns) => + new SolutionTraverser(this.Solution, (ns) => { new NamespaceTraverser(ns, (codeClass) => { diff --git a/build/T4TS.Attributes.dll b/build/T4TS.Attributes.dll index 6bebbb45cdcedaeb731a26b67dbc5cfc6558ad9c..404d1fcf9aba658c253aca92271807b8752b2d7b 100644 GIT binary patch delta 66 zcmZqBY0#O_!5q+ZbYpifx4`@vtoOanWw_7p>&@HtWGmZd4IUFlknH4mUP*z^OU|>b WTzJ7_kB GetDataToRender() { if (project == null) throw new Exception("Could not find the VS project containing the T4TS file."); - var generator = new CodeTraverser(project, GetSettings()); + var generator = new CodeTraverser(dte.Solution, GetSettings()); return generator.GetAllInterfaces().ToList(); } @@ -59,8 +59,7 @@ Project GetProjectContainingT4File(DTE dte) { return projectItem.ContainingProject; } - - public class InterfaceOutputAppender : OutputAppender +public class InterfaceOutputAppender : OutputAppender { private bool InGlobalModule { get; set; } @@ -406,6 +405,33 @@ Project GetProjectContainingT4File(DTE dte) { } } + public class SolutionTraverser + { + public Action WithNamespace { get; private set; } + + public SolutionTraverser(Solution solution, Action withNamespace) + { + if (solution == null) + throw new ArgumentNullException("solution"); + + if (withNamespace == null) + throw new ArgumentNullException("withNamespace"); + + WithNamespace = withNamespace; + + if (solution.Projects != null) + Traverse(solution.Projects); + } + + private void Traverse(Projects projects) + { + foreach (Project project in projects) + { + new ProjectTraverser(project, WithNamespace); + } + } + } + public class ArrayType: TypescriptType { public TypescriptType ElementType { get; set; } @@ -526,21 +552,21 @@ Project GetProjectContainingT4File(DTE dte) { public class CodeTraverser { - public Project Project { get; private set; } + public Solution Solution { get; private set; } public Settings Settings { get; private set; } private static readonly string InterfaceAttributeFullName = "T4TS.TypeScriptInterfaceAttribute"; private static readonly string MemberAttributeFullName = "T4TS.TypeScriptMemberAttribute"; - public CodeTraverser(Project project, Settings settings) + public CodeTraverser(Solution solution, Settings settings) { - if (project == null) - throw new ArgumentNullException("project"); + if (solution == null) + throw new ArgumentNullException("solution"); if (settings == null) throw new ArgumentNullException("settings"); - this.Project = project; + Solution = solution; this.Settings = settings; } @@ -549,7 +575,7 @@ Project GetProjectContainingT4File(DTE dte) { var typeContext = new TypeContext(this.Settings); var partialClasses = new Dictionary(); - new ProjectTraverser(this.Project, (ns) => + new SolutionTraverser(this.Solution, (ns) => { new NamespaceTraverser(ns, (codeClass) => { @@ -574,7 +600,7 @@ Project GetProjectContainingT4File(DTE dte) { var byModuleName = new Dictionary(); var tsMap = new Dictionary(); - new ProjectTraverser(this.Project, (ns) => + new SolutionTraverser(this.Solution, (ns) => { new NamespaceTraverser(ns, (codeClass) => {