Permalink
Browse files

Compiler tests

  • Loading branch information...
nikhilk committed May 28, 2012
1 parent c094d37 commit 69f3999861ac6b880fbc0728874ee2b8304e2984
Showing with 14,358 additions and 0 deletions.
  1. +27 −0 tests/ScriptSharp.testsettings
  2. +125 −0 tests/ScriptSharp/BasicTests.cs
  3. +158 −0 tests/ScriptSharp/Core/Compilation.cs
  4. +58 −0 tests/ScriptSharp/Core/CompilationInput.cs
  5. +55 −0 tests/ScriptSharp/Core/CompilationOutput.cs
  6. +144 −0 tests/ScriptSharp/Core/CompilationTest.cs
  7. +192 −0 tests/ScriptSharp/ExpressionTests.cs
  8. +26 −0 tests/ScriptSharp/LibraryTests.cs
  9. +72 −0 tests/ScriptSharp/MemberTests.cs
  10. +20 −0 tests/ScriptSharp/Properties/AssemblyInfo.cs
  11. +78 −0 tests/ScriptSharp/ScriptSharp.csproj
  12. +78 −0 tests/ScriptSharp/StatementTests.cs
  13. +134 −0 tests/ScriptSharp/TypeTests.cs
  14. +287 −0 tests/ScriptSharp/ValidationTests.cs
  15. +49 −0 tests/ScriptSharpTests.sln
  16. +64 −0 tests/TestCases/Basic/Conditionals/Code.cs
  17. +46 −0 tests/TestCases/Basic/Conditionals/DebugBaseline.txt
  18. +32 −0 tests/TestCases/Basic/Conditionals/TraceBaseline.txt
  19. +294 −0 tests/TestCases/Basic/DocComments/Baseline.txt
  20. +262 −0 tests/TestCases/Basic/DocComments/Code.cs
  21. +213 −0 tests/TestCases/Basic/DocComments/DocComments.xml
  22. +22 −0 tests/TestCases/Basic/Flags/Baseline.txt
  23. +31 −0 tests/TestCases/Basic/Flags/Code.cs
  24. +4,010 −0 tests/TestCases/Basic/Metadata/Baseline.txt
  25. +80 −0 tests/TestCases/Basic/Metadata/Code.cs
  26. +1 −0 tests/TestCases/Basic/Metadata/Sample.bat
  27. +74 −0 tests/TestCases/Basic/Metadata/Sample.cs
  28. BIN tests/TestCases/Basic/Metadata/Sample.dll
  29. +316 −0 tests/TestCases/Basic/Minimization/Baseline.txt
  30. +226 −0 tests/TestCases/Basic/Minimization/Code.cs
  31. +1 −0 tests/TestCases/Basic/Minimization/Lib.bat
  32. +29 −0 tests/TestCases/Basic/Minimization/Lib.cs
  33. BIN tests/TestCases/Basic/Minimization/Lib.dll
  34. +30 −0 tests/TestCases/Basic/Resources/Baseline.txt
  35. +16 −0 tests/TestCases/Basic/Resources/Code.cs
  36. +123 −0 tests/TestCases/Basic/Resources/Strings1.fr-FR.resx
  37. +126 −0 tests/TestCases/Basic/Resources/Strings1.fr.resx
  38. +130 −0 tests/TestCases/Basic/Resources/Strings1.resx
  39. +126 −0 tests/TestCases/Basic/Resources/Strings2.resx
  40. +75 −0 tests/TestCases/Basic/Simple/Baseline.txt
  41. +75 −0 tests/TestCases/Basic/Simple/Code.cs
  42. +22 −0 tests/TestCases/Basic/Template/Baseline.txt
  43. +16 −0 tests/TestCases/Basic/Template/Code.cs
  44. +1 −0 tests/TestCases/Basic/Template/Static.js
  45. +15 −0 tests/TestCases/Basic/Template/Template.js
  46. +66 −0 tests/TestCases/Basic/UnitTest/Code.cs
  47. +38 −0 tests/TestCases/Basic/UnitTest/NonTestBaseline.txt
  48. +122 −0 tests/TestCases/Basic/UnitTest/TestBaseline.txt
  49. +56 −0 tests/TestCases/Expression/AnonymousMethods/Baseline.txt
  50. +60 −0 tests/TestCases/Expression/AnonymousMethods/Code.cs
  51. +18 −0 tests/TestCases/Expression/Arguments/Baseline.txt
  52. +17 −0 tests/TestCases/Expression/Arguments/Code.cs
  53. +39 −0 tests/TestCases/Expression/Base/Baseline.txt
  54. +36 −0 tests/TestCases/Expression/Base/Code.cs
  55. +121 −0 tests/TestCases/Expression/Binary/Baseline.txt
  56. +105 −0 tests/TestCases/Expression/Binary/Code.cs
  57. +37 −0 tests/TestCases/Expression/Cast/Baseline.txt
  58. +45 −0 tests/TestCases/Expression/Cast/Code.cs
  59. +21 −0 tests/TestCases/Expression/Conditional/Baseline.txt
  60. +23 −0 tests/TestCases/Expression/Conditional/Code.cs
  61. +54 −0 tests/TestCases/Expression/Delegates/Baseline.txt
  62. +51 −0 tests/TestCases/Expression/Delegates/Code.cs
  63. +51 −0 tests/TestCases/Expression/Dictionary/Baseline.txt
  64. +62 −0 tests/TestCases/Expression/Dictionary/Code.cs
  65. +44 −0 tests/TestCases/Expression/EnumToString/Code1.cs
  66. +44 −0 tests/TestCases/Expression/EnumToString/Code2.cs
  67. +23 −0 tests/TestCases/Expression/EnumToString/MinBaseline.txt
  68. +63 −0 tests/TestCases/Expression/EnumToString/NormalBaseline.txt
  69. +100 −0 tests/TestCases/Expression/Events/Baseline.txt
  70. +90 −0 tests/TestCases/Expression/Events/Code.cs
  71. +50 −0 tests/TestCases/Expression/Generics/Baseline.txt
  72. +61 −0 tests/TestCases/Expression/Generics/Code.cs
  73. +22 −0 tests/TestCases/Expression/GetType/Baseline.txt
  74. +19 −0 tests/TestCases/Expression/GetType/Code.cs
  75. +25 −0 tests/TestCases/Expression/GlobalMethods/Baseline.txt
  76. +25 −0 tests/TestCases/Expression/GlobalMethods/Code.cs
  77. +21 −0 tests/TestCases/Expression/InlineScript/Baseline.txt
  78. +25 −0 tests/TestCases/Expression/InlineScript/Code.cs
  79. +60 −0 tests/TestCases/Expression/LateBound/Baseline.txt
  80. +74 −0 tests/TestCases/Expression/LateBound/Code.cs
  81. +40 −0 tests/TestCases/Expression/Literals/Baseline.txt
  82. +45 −0 tests/TestCases/Expression/Literals/Code.cs
  83. +31 −0 tests/TestCases/Expression/Locals/Baseline.txt
  84. +33 −0 tests/TestCases/Expression/Locals/Code.cs
  85. +108 −0 tests/TestCases/Expression/Members/Baseline.txt
  86. +103 −0 tests/TestCases/Expression/Members/Code.cs
  87. +62 −0 tests/TestCases/Expression/New/Baseline.txt
  88. +79 −0 tests/TestCases/Expression/New/Code.cs
  89. +19 −0 tests/TestCases/Expression/Number/Baseline.txt
  90. +18 −0 tests/TestCases/Expression/Number/Code.cs
  91. +19 −0 tests/TestCases/Expression/Script/Baseline.txt
  92. +18 −0 tests/TestCases/Expression/Script/Code.cs
  93. +23 −0 tests/TestCases/Expression/String/Baseline.txt
  94. +23 −0 tests/TestCases/Expression/String/Code.cs
  95. +64 −0 tests/TestCases/Expression/Truthy/Baseline.txt
  96. +68 −0 tests/TestCases/Expression/Truthy/Code.cs
  97. +52 −0 tests/TestCases/Expression/Unary/Baseline.txt
  98. +46 −0 tests/TestCases/Expression/Unary/Code.cs
  99. +39 −0 tests/TestCases/Library/jQuery/Baseline.txt
  100. +67 −0 tests/TestCases/Library/jQuery/Code.cs
  101. +47 −0 tests/TestCases/Member/Constructors/Baseline.txt
  102. +44 −0 tests/TestCases/Member/Constructors/Code.cs
  103. +55 −0 tests/TestCases/Member/Events/Baseline.txt
  104. +42 −0 tests/TestCases/Member/Events/Code.cs
  105. +71 −0 tests/TestCases/Member/Fields/Baseline.txt
  106. +66 −0 tests/TestCases/Member/Fields/Code.cs
  107. +207 −0 tests/TestCases/Member/Indexers/Baseline.txt
  108. +173 −0 tests/TestCases/Member/Indexers/Code.cs
  109. +96 −0 tests/TestCases/Member/Methods/Baseline.txt
  110. +94 −0 tests/TestCases/Member/Methods/Code.cs
  111. +34 −0 tests/TestCases/Member/Overloads/Baseline.txt
  112. +51 −0 tests/TestCases/Member/Overloads/Code.cs
  113. +57 −0 tests/TestCases/Member/Properties/Baseline.txt
  114. +51 −0 tests/TestCases/Member/Properties/Code.cs
  115. +39 −0 tests/TestCases/Member/StaticConstructors/Baseline.txt
  116. +45 −0 tests/TestCases/Member/StaticConstructors/Code.cs
  117. +43 −0 tests/TestCases/Statement/Exceptions/Baseline.txt
  118. +46 −0 tests/TestCases/Statement/Exceptions/Code.cs
  119. +19 −0 tests/TestCases/Statement/Expression/Baseline.txt
  120. +19 −0 tests/TestCases/Statement/Expression/Code.cs
  121. +32 −0 tests/TestCases/Statement/For/Baseline.txt
  122. +37 −0 tests/TestCases/Statement/For/Code.cs
  123. +56 −0 tests/TestCases/Statement/Foreach/Baseline.txt
  124. +46 −0 tests/TestCases/Statement/Foreach/Code.cs
  125. +34 −0 tests/TestCases/Statement/IfElse/Baseline.txt
  126. +37 −0 tests/TestCases/Statement/IfElse/Code.cs
  127. +31 −0 tests/TestCases/Statement/Return/Baseline.txt
  128. +31 −0 tests/TestCases/Statement/Return/Code.cs
  129. +59 −0 tests/TestCases/Statement/Switch/Baseline.txt
  130. +50 −0 tests/TestCases/Statement/Switch/Code.cs
  131. +37 −0 tests/TestCases/Statement/Variables/Baseline.txt
  132. +39 −0 tests/TestCases/Statement/Variables/Code.cs
  133. +29 −0 tests/TestCases/Statement/While/Baseline.txt
  134. +32 −0 tests/TestCases/Statement/While/Code.cs
  135. +45 −0 tests/TestCases/Type/Classes/Baseline.txt
  136. +25 −0 tests/TestCases/Type/Classes/Code.cs
  137. +10 −0 tests/TestCases/Type/Delegates/Baseline.txt
  138. +15 −0 tests/TestCases/Type/Delegates/Code.cs
  139. +49 −0 tests/TestCases/Type/Enumerator/Baseline.txt
  140. +38 −0 tests/TestCases/Type/Enumerator/Code.cs
  141. +126 −0 tests/TestCases/Type/Enums/Baseline.txt
  142. +107 −0 tests/TestCases/Type/Enums/Code.cs
  143. +77 −0 tests/TestCases/Type/Globals/Baseline.txt
  144. +39 −0 tests/TestCases/Type/Globals/Code.cs
  145. +16 −0 tests/TestCases/Type/Imported/Baseline.txt
  146. +43 −0 tests/TestCases/Type/Imported/Code.cs
  147. +85 −0 tests/TestCases/Type/Interfaces/Baseline.txt
  148. +45 −0 tests/TestCases/Type/Interfaces/Code.cs
  149. +95 −0 tests/TestCases/Type/Namespaces/Baseline.txt
  150. +76 −0 tests/TestCases/Type/Namespaces/Code.cs
  151. +32 −0 tests/TestCases/Type/Nullable/Baseline.txt
  152. +35 −0 tests/TestCases/Type/Nullable/Code.cs
  153. +147 −0 tests/TestCases/Type/Partials/Baseline.txt
  154. +110 −0 tests/TestCases/Type/Partials/Code1.cs
  155. +26 −0 tests/TestCases/Type/Partials/Code2.cs
  156. +19 −0 tests/TestCases/Type/Records/Baseline.txt
  157. +23 −0 tests/TestCases/Type/Records/Code.cs
  158. +13 −0 tests/TestCases/Type/ScriptNamespaces/AppAssemblyInfo.cs
  159. +65 −0 tests/TestCases/Type/ScriptNamespaces/AppBaseline.txt
  160. +23 −0 tests/TestCases/Type/ScriptNamespaces/AppFeature.cs
  161. +8 −0 tests/TestCases/Type/ScriptNamespaces/AppFoo.1.cs
  162. +10 −0 tests/TestCases/Type/ScriptNamespaces/AppFoo.2.cs
  163. +28 −0 tests/TestCases/Type/ScriptNamespaces/AppMyApp.cs
  164. BIN tests/TestCases/Type/ScriptNamespaces/Lib.dll
  165. +1 −0 tests/TestCases/Type/ScriptNamespaces/Library.bat
  166. +11 −0 tests/TestCases/Type/ScriptNamespaces/LibraryAssemblyInfo.cs
  167. +50 −0 tests/TestCases/Type/ScriptNamespaces/LibraryBaseline.txt
  168. +18 −0 tests/TestCases/Type/ScriptNamespaces/LibraryFeature.cs
  169. +23 −0 tests/TestCases/Type/ScriptNamespaces/LibraryMyLib.cs
  170. +13 −0 tests/TestCases/Type/UsingAlias/Baseline.txt
  171. +19 −0 tests/TestCases/Type/UsingAlias/Code.cs
  172. +17 −0 tests/TestCases/Validation/ConflictingTypes/Code.cs
  173. +41 −0 tests/TestCases/Validation/CreateInstance/Code.cs
  174. +50 −0 tests/TestCases/Validation/Exceptions/Code.cs
  175. +15 −0 tests/TestCases/Validation/ImplicitEnums/Code.cs
  176. +18 −0 tests/TestCases/Validation/InlineScript/Code.cs
  177. +19 −0 tests/TestCases/Validation/Keywords/Code.cs
  178. +18 −0 tests/TestCases/Validation/NestedTypes/Code.cs
  179. +23 −0 tests/TestCases/Validation/Overloads/Code.cs
  180. +16 −0 tests/TestCases/Validation/Properties/Code.cs
  181. +28 −0 tests/TestCases/Validation/Unsupported/Code1.cs
  182. +15 −0 tests/TestCases/Validation/Unsupported/Code2.cs
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestSettings name="ScriptSharp" id="4d943b1b-2d0a-48f4-b3fc-adf2d6a940eb" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
+ <Description>These are default test settings for a local test run.</Description>
+ <Deployment enabled="false" />
+ <NamingScheme baseName="Run" appendTimeStamp="false" useDefault="false" />
+ <Execution>
+ <TestTypeSpecific>
+ <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
+ <AssemblyResolution>
+ <TestDirectory useLoadContext="true" />
+ </AssemblyResolution>
+ </UnitTestRunConfig>
+ <WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
+ <Browser name="Internet Explorer 7.0">
+ <Headers>
+ <Header name="User-Agent" value="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" />
+ <Header name="Accept" value="*/*" />
+ <Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
+ <Header name="Accept-Encoding" value="GZIP" />
+ </Headers>
+ </Browser>
+ </WebTestRunConfiguration>
+ </TestTypeSpecific>
+ <AgentRule name="LocalMachineDefaultRole">
+ </AgentRule>
+ </Execution>
+</TestSettings>
@@ -0,0 +1,125 @@
+// BasicTests.cs
+// Script#/Tests/ScriptSharp
+// This source code is subject to terms and conditions of the Apache License, Version 2.0.
+//
+
+using System;
+using System.IO;
+using System.Reflection;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using ScriptSharp.Tests.Core;
+using ScriptSharp.VisualStudio.Generators;
+
+namespace ScriptSharp.Tests {
+
+ [TestClass]
+ public sealed class BasicTests : CompilationTest {
+
+ [TestMethod]
+ public void TestConditionals() {
+ RunTest((c) => {
+ c.AddSource("Code.cs");
+ c.Options.DebugFlavor = true;
+ c.Options.Defines = new string[] { "DEBUG" };
+ }, "DebugBaseline.txt");
+
+ RunTest((c) => {
+ c.AddSource("Code.cs");
+ c.Options.Defines = new string[] { "TRACE" };
+ }, "TraceBaseline.txt");
+ }
+
+ [TestMethod]
+ public void TestDocComments() {
+ RunTest((c) => {
+ c.AddReference("Script.Web.dll").
+ AddSource("Code.cs").
+ AddComments("DocComments.xml");
+ c.Options.DebugFlavor = true;
+ });
+ }
+
+ [TestMethod]
+ public void TestFlags() {
+ RunTest((c) => {
+ c.AddSource("Code.cs");
+ c.Options.Defines = new string[] { "ABC" };
+ });
+ }
+
+ [TestMethod]
+ public void TestSimple() {
+ RunTest((c) => {
+ c.AddSource("Code.cs");
+ });
+ }
+
+ [TestMethod]
+ public void TestMetadata() {
+ RunTest((c) => {
+ c.AddReference("Lib.dll").
+ AddSource("Code.cs");
+ c.Options.InternalTestType = "metadata";
+ c.Options.DebugFlavor = true;
+ });
+ }
+
+ [TestMethod]
+ public void TestMinimization() {
+ RunTest((c) => {
+ c.AddReference("Script.Web.dll").
+ AddReference("Lib.dll").
+ AddSource("Code.cs");
+ c.Options.Minimize = true;
+ c.Options.InternalTestType = "minimizationMap";
+ });
+ }
+
+ [TestMethod]
+ public void TestResources() {
+ string resource1Path = GetTestFilePath("Strings1.resx");
+ string resource2Path = GetTestFilePath("Strings2.resx");
+
+ string resource1Markup = File.ReadAllText(resource1Path);
+ string resource2Markup = File.ReadAllText(resource2Path);
+
+ string code1 = (new ResXInternalScriptGenerator()).GenerateCode(resource1Path, resource1Markup, "Resources");
+ string code2 = (new ResXPublicScriptGenerator()).GenerateCode(resource2Path, resource2Markup, "Resources");
+
+ RunTest((c) => {
+ c.AddSource("Code.cs").
+ AddCode("Strings1.Designer.cs", code1).
+ AddCode("Strings2.Designer.cs", code2).
+ AddResource("Strings1.resx").
+ AddResource("Strings1.fr.resx").
+ AddResource("Strings1.fr-FR.resx").
+ AddResource("Strings2.resx");
+ c.Options.DebugFlavor = true;
+ c.Options.Defines = new string[] { "DEBUG" };
+ });
+ }
+
+ [TestMethod]
+ public void TestTemplate() {
+ RunTest((c) => {
+ c.AddReference("Script.Web.dll").
+ AddTemplate("Template.js").
+ AddSource("Code.cs");
+ c.Options.DebugFlavor = true;
+ c.Options.Defines = new string[] { "DEBUG" };
+ });
+ }
+
+ [TestMethod]
+ public void TestUnitTest() {
+ RunTest((c) => {
+ c.AddSource("Code.cs");
+ }, "NonTestBaseline.txt");
+
+ RunTest((c) => {
+ c.AddSource("Code.cs");
+ c.Options.IncludeTests = true;
+ }, "TestBaseline.txt");
+ }
+ }
+}
@@ -0,0 +1,158 @@
+// Compilation.cs
+// Script#/Tests/ScriptSharp
+// This source code is subject to terms and conditions of the Apache License, Version 2.0.
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace ScriptSharp.Tests.Core {
+
+ public sealed class Compilation : IErrorHandler {
+
+ private CompilationTest _test;
+
+ private List<string> _references;
+ private List<CompilationInput> _sources;
+ private List<CompilationInput> _resources;
+ private CompilationInput _template;
+ private CompilationInput _comments;
+ private CompilationOutput _output;
+
+ private List<string> _errors;
+
+ private CompilerOptions _options;
+
+ public Compilation(CompilationTest test) {
+ _test = test;
+
+ _references = new List<string>();
+ _sources = new List<CompilationInput>();
+ _resources = new List<CompilationInput>();
+
+ _options = new CompilerOptions();
+ _options.DebugFlavor = false;
+ _options.Minimize = false;
+ _options.InternalTestMode = true;
+ _options.Defines = new string[] { };
+ }
+
+ public string ErrorMessages {
+ get {
+ return String.Join(Environment.NewLine, Errors);
+ }
+ }
+
+ public IEnumerable<string> Errors {
+ get {
+ return _errors;
+ }
+ }
+
+ public bool HasErrors {
+ get {
+ return _errors != null;
+ }
+ }
+
+ public CompilerOptions Options {
+ get {
+ return _options;
+ }
+ }
+
+ public CompilationOutput Output {
+ get {
+ return _output;
+ }
+ }
+
+ public Compilation AddCode(string name, string code) {
+ string sourcePath = _test.GetTestFilePath(name);
+
+ CompilationInput codeInput = new CompilationInput(sourcePath, name, code);
+ _sources.Add(codeInput);
+
+ return this;
+ }
+
+ public Compilation AddComments(string name) {
+ string commentsPath = _test.GetTestFilePath(name);
+
+ _comments = new CompilationInput(commentsPath, name);
+ return this;
+ }
+
+ public Compilation AddReference(string name) {
+ string assemblyPath = _test.GetAssemblyFilePath(name);
+ if (File.Exists(assemblyPath)) {
+ _references.Add(assemblyPath);
+ }
+ else {
+ assemblyPath = _test.GetTestFilePath(name);
+ if (File.Exists(assemblyPath)) {
+ _references.Add(assemblyPath);
+ }
+ }
+
+ return this;
+ }
+
+ public Compilation AddResource(string name) {
+ string resourcesPath = _test.GetTestFilePath(name);
+
+ CompilationInput resourceInput = new CompilationInput(resourcesPath, name);
+ _resources.Add(resourceInput);
+
+ return this;
+ }
+
+ public Compilation AddSource(string name) {
+ string sourcePath = _test.GetTestFilePath(name);
+
+ CompilationInput sourceInput = new CompilationInput(sourcePath, name);
+ _sources.Add(sourceInput);
+
+ return this;
+ }
+
+ public Compilation AddTemplate(string name) {
+ string templatePath = _test.GetTestFilePath(name);
+
+ _template = new CompilationInput(templatePath, name);
+ return this;
+ }
+
+ public bool Execute() {
+ _output = new CompilationOutput(_test.TestContext.TestName);
+
+ _options.References = _references;
+ _options.Sources = _sources.Cast<IStreamSource>().ToList();
+ _options.Resources = _resources.Cast<IStreamSource>().ToList();
+ _options.TemplateFile = _template;
+ _options.DocCommentFile = _comments;
+ _options.ScriptFile = _output;
+
+ ScriptCompiler compiler = new ScriptCompiler(this);
+ return compiler.Compile(_options);
+ }
+
+ #region Implementation of IErrorHandler
+
+ void IErrorHandler.ReportError(string errorMessage, string location) {
+ if (_errors == null) {
+ _errors = new List<string>();
+ }
+
+ string error = errorMessage + " " + location;
+
+ _errors.Add(error);
+ _test.TestContext.WriteLine(error);
+ }
+
+ #endregion
+ }
+}
@@ -0,0 +1,58 @@
+// CompilationInput.cs
+// Script#/Tests/ScriptSharp
+// This source code is subject to terms and conditions of the Apache License, Version 2.0.
+//
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace ScriptSharp.Tests.Core {
+
+ public sealed class CompilationInput : IStreamSource {
+
+ private string _path;
+ private string _name;
+ private string _content;
+
+ public CompilationInput(string path, string name) {
+ _path = path;
+ _name = name;
+ }
+
+ public CompilationInput(string path, string name, string content) {
+ _path = path;
+ _name = name;
+ _content = content;
+ }
+
+ #region Implementation of IStreamSource
+
+ string IStreamSource.FullName {
+ get {
+ return _path;
+ }
+ }
+
+ string IStreamSource.Name {
+ get {
+ return _name;
+ }
+ }
+
+ void IStreamSource.CloseStream(Stream stream) {
+ stream.Close();
+ }
+
+ Stream IStreamSource.GetStream() {
+ if (_content != null) {
+ byte[] data = Encoding.UTF8.GetBytes(_content);
+ return new MemoryStream(data);
+ }
+
+ return File.OpenRead(_path);
+ }
+
+ #endregion
+ }
+}
Oops, something went wrong.

0 comments on commit 69f3999

Please sign in to comment.