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.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cskeppstedt committed Jul 15, 2014
1 parent 52155d6 commit 2fa775f
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 20 deletions.
10 changes: 10 additions & 0 deletions T4TS.Build/T4TS.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
46 changes: 36 additions & 10 deletions T4TS.Build/T4TS.tt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ List<TypeScriptModule> 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();
}

Expand All @@ -59,8 +59,7 @@ Project GetProjectContainingT4File(DTE dte) {

return projectItem.ContainingProject;
}

public class InterfaceOutputAppender : OutputAppender<TypeScriptInterface>
public class InterfaceOutputAppender : OutputAppender<TypeScriptInterface>
{
private bool InGlobalModule { get; set; }

Expand Down Expand Up @@ -406,6 +405,33 @@ Project GetProjectContainingT4File(DTE dte) {
}
}

public class SolutionTraverser
{
public Action<CodeNamespace> WithNamespace { get; private set; }

public SolutionTraverser(Solution solution, Action<CodeNamespace> 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; }
Expand Down Expand Up @@ -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;
}

Expand All @@ -549,7 +575,7 @@ Project GetProjectContainingT4File(DTE dte) {
var typeContext = new TypeContext(this.Settings);
var partialClasses = new Dictionary<string, CodeClass>();

new ProjectTraverser(this.Project, (ns) =>
new SolutionTraverser(this.Solution, (ns) =>
{
new NamespaceTraverser(ns, (codeClass) =>
{
Expand All @@ -574,7 +600,7 @@ Project GetProjectContainingT4File(DTE dte) {
var byModuleName = new Dictionary<string, TypeScriptModule>();
var tsMap = new Dictionary<CodeClass, TypeScriptInterface>();

new ProjectTraverser(this.Project, (ns) =>
new SolutionTraverser(this.Solution, (ns) =>
{
new NamespaceTraverser(ns, (codeClass) =>
{
Expand Down
Binary file modified build/T4TS.Attributes.dll
Binary file not shown.
46 changes: 36 additions & 10 deletions build/T4TS.tt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ List<TypeScriptModule> 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();
}

Expand All @@ -59,8 +59,7 @@ Project GetProjectContainingT4File(DTE dte) {

return projectItem.ContainingProject;
}

public class InterfaceOutputAppender : OutputAppender<TypeScriptInterface>
public class InterfaceOutputAppender : OutputAppender<TypeScriptInterface>
{
private bool InGlobalModule { get; set; }

Expand Down Expand Up @@ -406,6 +405,33 @@ Project GetProjectContainingT4File(DTE dte) {
}
}

public class SolutionTraverser
{
public Action<CodeNamespace> WithNamespace { get; private set; }

public SolutionTraverser(Solution solution, Action<CodeNamespace> 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; }
Expand Down Expand Up @@ -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;
}

Expand All @@ -549,7 +575,7 @@ Project GetProjectContainingT4File(DTE dte) {
var typeContext = new TypeContext(this.Settings);
var partialClasses = new Dictionary<string, CodeClass>();

new ProjectTraverser(this.Project, (ns) =>
new SolutionTraverser(this.Solution, (ns) =>
{
new NamespaceTraverser(ns, (codeClass) =>
{
Expand All @@ -574,7 +600,7 @@ Project GetProjectContainingT4File(DTE dte) {
var byModuleName = new Dictionary<string, TypeScriptModule>();
var tsMap = new Dictionary<CodeClass, TypeScriptInterface>();

new ProjectTraverser(this.Project, (ns) =>
new SolutionTraverser(this.Solution, (ns) =>
{
new NamespaceTraverser(ns, (codeClass) =>
{
Expand Down

0 comments on commit 2fa775f

Please sign in to comment.