-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wriring up Reflection to execution layer
Tests added by extending the build task example project. Extended runner in ScriptSharp for keeping into account the assembly. Attention: The runner does not work because the assembly is not loaded into the inspection only context and all reference errors are surfacing. This must be fixed in later pack. Targets #41
- Loading branch information
1 parent
799a169
commit f471095
Showing
17 changed files
with
303 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/// <summary> | ||
/// ProgramWrapper.cs | ||
/// Andrea Tino - 2017 | ||
/// </summary> | ||
|
||
namespace Rosetta.Reflection.ScriptSharp | ||
{ | ||
using System; | ||
using System.Reflection; | ||
|
||
/// <summary> | ||
/// Initiates the translation. | ||
/// </summary> | ||
public class ProgramWrapper : Rosetta.Reflection.ProgramWrapper | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ProgramWrapper"/> class. | ||
/// </summary> | ||
/// <param name="assemblyPath"></param> | ||
public ProgramWrapper(string assemblyPath) | ||
: base(assemblyPath) | ||
{ | ||
} | ||
|
||
protected override IASTBuilder CreateASTBuilder(Assembly assembly) => new ASTBuilder(assembly); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/ScriptSharp.Definition.BuildTask/GenerateBundleWithReflectionTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/// <summary> | ||
/// GenerateBundleWithReflectionTask.cs | ||
/// Andrea Tino - 2016 | ||
/// </summary> | ||
|
||
namespace Rosetta.ScriptSharp.Definition.BuildTask | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Rosetta.Reflection.ScriptSharp; | ||
|
||
/// <summary> | ||
/// The build task. | ||
/// </summary> | ||
public class GenerateBundleWithReflectionTask : GenerateBundleTask | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GenerateBundleWithReflectionTask"/> class. | ||
/// </summary> | ||
/// <param name="outputFolder">The folder where to emit generated files.</param> | ||
/// <param name="assemblyPath">The path to the assembly providing information on symbols in source files.</param> | ||
/// <param name="references">Additional references to add in the emitted bundle.</param> | ||
/// <param name="bundleName">The name of the bundle.</param> | ||
public GenerateBundleWithReflectionTask(string outputFolder, string assemblyPath, IEnumerable<string> references, string bundleName = null) | ||
: base(new string[0], outputFolder, assemblyPath, references, bundleName) | ||
{ | ||
} | ||
|
||
protected override string GenerateOutput() => new ProgramWrapper(this.assemblyPath).Output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/ScriptSharp.Definition.BuildTask/GenerateTaskFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/// <summary> | ||
/// GenerateTaskFactory.cs | ||
/// Andrea Tino - 2016 | ||
/// </summary> | ||
|
||
namespace Rosetta.ScriptSharp.Definition.BuildTask | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using Rosetta.Executable; | ||
|
||
/// <summary> | ||
/// Factory for creating a <see cref="GenerateTaskBase"/>. | ||
/// </summary> | ||
public class GenerateTaskFactory | ||
{ | ||
private readonly IEnumerable<string> sourceFiles; | ||
private readonly string outputFolder; | ||
private readonly string assemblyPath; | ||
private readonly IEnumerable<string> references; | ||
private readonly string bundleName; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GenerateTaskFactory"/> class. | ||
/// </summary> | ||
/// <param name="sourceFiles">The collection of paths to the files to consider.</param> | ||
/// <param name="outputFolder">The folder where to emit generated files.</param> | ||
/// <param name="assemblyPath">The path to the assembly providing information on symbols in source files.</param> | ||
/// <param name="references">Additional references to add in the emitted bundle.</param> | ||
/// <param name="bundleName">The name of the bundle.</param> | ||
public GenerateTaskFactory(IEnumerable<string> sourceFiles, string outputFolder, string assemblyPath, IEnumerable<string> references, string bundleName) | ||
{ | ||
if (outputFolder == null) | ||
{ | ||
throw new ArgumentNullException(nameof(outputFolder)); | ||
} | ||
|
||
this.sourceFiles = sourceFiles; | ||
this.outputFolder = outputFolder; | ||
this.assemblyPath = assemblyPath; | ||
this.references = references; | ||
this.bundleName = bundleName; | ||
} | ||
|
||
/// <summary> | ||
/// Creates the proper <see cref="GenerateTaskBase"/> given the input parameters. | ||
/// </summary> | ||
/// <returns>A <see cref="GenerateTaskBase"/>.</returns> | ||
public GenerateTaskBase Create() | ||
{ | ||
if (this.CreateBundle) | ||
{ | ||
return this.sourceFiles != null | ||
? new GenerateBundleTask(this.sourceFiles, this.outputFolder, this.assemblyPath, this.references, this.bundleName) | ||
: new GenerateBundleWithReflectionTask(this.outputFolder, this.assemblyPath, this.references, this.bundleName); | ||
} | ||
|
||
return new GenerateFilesTask(this.sourceFiles, this.outputFolder, this.assemblyPath, this.references) as GenerateTaskBase; | ||
} | ||
|
||
private bool CreateBundle => this.bundleName != null && this.bundleName.Length > 0; | ||
} | ||
} |
Oops, something went wrong.