├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── baufile.csx ├── build.bat ├── how_to_build.md ├── scriptcs_packages.config └── src ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── CommonAssemblyInfo.cs ├── ScriptCs.CSharp ├── CSharpModule.cs ├── CSharpPersistentEngine.cs ├── CSharpReplEngine.cs ├── CSharpScriptCompilerEngine.cs ├── CSharpScriptEngine.cs ├── CSharpScriptInMemoryEngine.cs ├── Properties │ └── AssemblyInfo.cs ├── ScriptCs.CSharp.csproj ├── ScriptCs.CSharp.nuspec ├── app.config └── packages.config ├── ScriptCs.Engine.Common ├── CommonScriptEngine.cs ├── Properties │ └── AssemblyInfo.cs ├── ReplEngineExtensions.cs ├── ScriptCs.Engine.Common.csproj ├── ScriptCs.Engine.Common.nuspec ├── app.config └── packages.config ├── ScriptCs.Engines.sln ├── ScriptCs.VisualBasic ├── Properties │ └── AssemblyInfo.cs ├── ScriptCs.VisualBasic.csproj ├── ScriptCs.VisualBasic.nuspec ├── VisualBasicModule.cs ├── VisualBasicNamespaceLineProcessor.cs ├── VisualBasicReplEngine.cs ├── VisualBasicScriptEngine.cs ├── app.config └── packages.config └── nuget.config /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | [Rr]eleases/ 14 | x64/ 15 | x86/ 16 | build/ 17 | bld/ 18 | [Bb]in/ 19 | [Oo]bj/ 20 | 21 | # Roslyn cache directories 22 | *.ide/ 23 | 24 | # MSTest test Results 25 | [Tt]est[Rr]esult*/ 26 | [Bb]uild[Ll]og.* 27 | 28 | #NUNIT 29 | *.VisualState.xml 30 | TestResult.xml 31 | 32 | # Build Results of an ATL Project 33 | [Dd]ebugPS/ 34 | [Rr]eleasePS/ 35 | dlldata.c 36 | 37 | *_i.c 38 | *_p.c 39 | *_i.h 40 | *.ilk 41 | *.meta 42 | *.obj 43 | *.pch 44 | *.pdb 45 | *.pgc 46 | *.pgd 47 | *.rsp 48 | *.sbr 49 | *.tlb 50 | *.tli 51 | *.tlh 52 | *.tmp 53 | *.tmp_proj 54 | *.log 55 | *.vspscc 56 | *.vssscc 57 | .builds 58 | *.pidb 59 | *.svclog 60 | *.scc 61 | 62 | # Chutzpah Test files 63 | _Chutzpah* 64 | 65 | # Visual C++ cache files 66 | ipch/ 67 | *.aps 68 | *.ncb 69 | *.opensdf 70 | *.sdf 71 | *.cachefile 72 | 73 | # Visual Studio profiler 74 | *.psess 75 | *.vsp 76 | *.vspx 77 | 78 | # TFS 2012 Local Workspace 79 | $tf/ 80 | 81 | # Guidance Automation Toolkit 82 | *.gpState 83 | 84 | # ReSharper is a .NET coding add-in 85 | _ReSharper*/ 86 | *.[Rr]e[Ss]harper 87 | *.DotSettings.user 88 | 89 | # JustCode is a .NET coding addin-in 90 | .JustCode 91 | 92 | # TeamCity is a build add-in 93 | _TeamCity* 94 | 95 | # DotCover is a Code Coverage Tool 96 | *.dotCover 97 | 98 | # NCrunch 99 | _NCrunch_* 100 | .*crunch*.local.xml 101 | 102 | # MightyMoose 103 | *.mm.* 104 | AutoTest.Net/ 105 | 106 | # Web workbench (sass) 107 | .sass-cache/ 108 | 109 | # Installshield output folder 110 | [Ee]xpress/ 111 | 112 | # DocProject is a documentation generator add-in 113 | DocProject/buildhelp/ 114 | DocProject/Help/*.HxT 115 | DocProject/Help/*.HxC 116 | DocProject/Help/*.hhc 117 | DocProject/Help/*.hhk 118 | DocProject/Help/*.hhp 119 | DocProject/Help/Html2 120 | DocProject/Help/html 121 | 122 | # Click-Once directory 123 | publish/ 124 | 125 | # Publish Web Output 126 | *.[Pp]ublish.xml 127 | *.azurePubxml 128 | # TODO: Comment the next line if you want to checkin your web deploy settings 129 | # but database connection strings (with potential passwords) will be unencrypted 130 | *.pubxml 131 | *.publishproj 132 | 133 | # NuGet Packages 134 | *.nupkg 135 | # The packages folder can be ignored because of Package Restore 136 | **/packages/* 137 | # except build/, which is used as an MSBuild target. 138 | !**/packages/build/ 139 | # If using the old MSBuild-Integrated Package Restore, uncomment this: 140 | #!**/packages/repositories.config 141 | 142 | # Windows Azure Build Output 143 | csx/ 144 | *.build.csdef 145 | 146 | # Windows Store app package directory 147 | AppPackages/ 148 | 149 | # Others 150 | sql/ 151 | *.Cache 152 | ClientBin/ 153 | [Ss]tyle[Cc]op.* 154 | ~$* 155 | *~ 156 | *.dbmdl 157 | *.dbproj.schemaview 158 | *.pfx 159 | *.publishsettings 160 | node_modules/ 161 | 162 | # RIA/Silverlight projects 163 | Generated_Code/ 164 | 165 | # Backup & report files from converting an old project file 166 | # to a newer Visual Studio version. Backup files are not needed, 167 | # because we have git ;-) 168 | _UpgradeReport_Files/ 169 | Backup*/ 170 | UpgradeLog*.XML 171 | UpgradeLog*.htm 172 | 173 | # SQL Server files 174 | *.mdf 175 | *.ldf 176 | 177 | # Business Intelligence projects 178 | *.rdl.data 179 | *.bim.layout 180 | *.bim_*.settings 181 | 182 | # Microsoft Fakes 183 | FakesAssemblies/ 184 | 185 | # scriptcs Packages 186 | scriptcs_packages/ 187 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # scriptcs-engines 2 | 3 | ## Build 4 | 5 | git clone https://github.com/scriptcs/scriptcs-engines.git 6 | cd scriptcs-engines 7 | 8 | build.bat 9 | 10 | ### Build Prerequisites 11 | 12 | Install [scriptcs](http://scriptcs.net/). 13 | 14 | ### Artifacts 15 | 16 | Located in `/artifacts/`. 17 | -------------------------------------------------------------------------------- /baufile.csx: -------------------------------------------------------------------------------- 1 | // parameters 2 | var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX"); 3 | versionSuffix = string.IsNullOrWhiteSpace(versionSuffix) ? "-beta" : versionSuffix; 4 | var msBuildFileVerbosity = (Verbosity)Enum.Parse(typeof(Verbosity), Environment.GetEnvironmentVariable("MSBUILD_FILE_VERBOSITY") ?? "detailed", true); 5 | var nugetVerbosity = Environment.GetEnvironmentVariable("NUGET_VERBOSITY") ?? "quiet"; 6 | 7 | // solution specific variables 8 | var version = File.ReadAllText("src/CommonAssemblyInfo.cs").Split(new[] { "AssemblyInformationalVersion(\"" }, 2, StringSplitOptions.None).ElementAt(1).Split(new[] { '"' }).First(); 9 | var nugetCommand = "scriptcs_packages/NuGet.CommandLine.2.8.3/tools/NuGet.exe"; 10 | var solution = "src/ScriptCs.Engines.sln"; 11 | var output = "artifacts/output"; 12 | var logs = "artifacts/logs"; 13 | var packs = new[] 14 | { 15 | "src/ScriptCs.Engine.Common/ScriptCs.Engine.Common", 16 | "src/ScriptCs.CSharp/ScriptCs.CSharp", 17 | "src/ScriptCs.VisualBasic/ScriptCs.VisualBasic", 18 | }; 19 | 20 | // solution agnostic tasks 21 | var bau = Require(); 22 | 23 | bau 24 | .Task("default").DependsOn("pack") 25 | 26 | .Task("logs").Do(() => CreateDirectory(logs)) 27 | 28 | .MSBuild("clean").DependsOn("logs").Do(msb => Configure(msb, "Clean")) 29 | 30 | .Task("clobber").DependsOn("clean").Do(() => DeleteDirectory(output)) 31 | 32 | .Exec("restore").Do(exec => exec.Run(nugetCommand).With("restore", solution)) 33 | 34 | .MSBuild("build").DependsOn("clean", "restore", "logs").Do(msb => Configure(msb, "Build")) 35 | 36 | .Task("output").Do(() => CreateDirectory(output)) 37 | 38 | .Task("pack").DependsOn("build", "clobber", "output").Do(() => 39 | { 40 | foreach (var pack in packs) 41 | { 42 | File.Copy(pack + ".nuspec", pack + ".nuspec.original", true); 43 | } 44 | 45 | try 46 | { 47 | foreach (var pack in packs) 48 | { 49 | File.WriteAllText(pack + ".nuspec", File.ReadAllText(pack + ".nuspec").Replace("0.0.0", version + versionSuffix)); 50 | 51 | var project = pack + ".csproj"; 52 | bau.CurrentTask.LogInfo("Packing '" + project + "'..."); 53 | 54 | new Exec { Name = "pack " + project } 55 | .Run(nugetCommand) 56 | .With( 57 | "pack", project, 58 | "-OutputDirectory", output, 59 | "-Properties", "Configuration=Release", 60 | "-IncludeReferencedProjects", 61 | "-Verbosity " + nugetVerbosity) 62 | .Execute(); 63 | } 64 | } 65 | finally 66 | { 67 | foreach (var pack in packs) 68 | { 69 | File.Copy(pack + ".nuspec.original", pack + ".nuspec", true); 70 | File.Delete(pack + ".nuspec.original"); 71 | } 72 | } 73 | }) 74 | 75 | .Run(); 76 | 77 | void Configure(MSBuild msb, string target) 78 | { 79 | msb.MSBuildVersion = "net45"; 80 | msb.Solution = solution; 81 | msb.Targets = new[] { target, }; 82 | msb.Properties = new { Configuration = "Release" }; 83 | msb.MaxCpuCount = -1; 84 | msb.NodeReuse = false; 85 | msb.Verbosity = Verbosity.Minimal; 86 | msb.NoLogo = true; 87 | msb.FileLoggers.Add( 88 | new FileLogger 89 | { 90 | FileLoggerParameters = new FileLoggerParameters 91 | { 92 | PerformanceSummary = true, 93 | Summary = true, 94 | Verbosity = msBuildFileVerbosity, 95 | LogFile = logs + "/" + target + ".log", 96 | } 97 | }); 98 | } 99 | 100 | void CreateDirectory(string name) 101 | { 102 | if (!Directory.Exists(name)) 103 | { 104 | Directory.CreateDirectory(name); 105 | System.Threading.Thread.Sleep(100); // HACK (adamralph): wait for the directory to be created 106 | } 107 | } 108 | 109 | void DeleteDirectory(string name) 110 | { 111 | if (Directory.Exists(name)) 112 | { 113 | Directory.Delete(name, true); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | scriptcs baufile.csx -- %* 4 | -------------------------------------------------------------------------------- /how_to_build.md: -------------------------------------------------------------------------------- 1 | ### Prerequisites 2 | 3 | Install [scriptcs](http://scriptcs.net/). 4 | 5 | ### Building 6 | 7 | Execute `build.bat`. 8 | 9 | ### Artifacts 10 | 11 | Located in `/artifacts/`. 12 | -------------------------------------------------------------------------------- /scriptcs_packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scriptcs/scriptcs-engines/b427a0ea33661f6dd1ac080eb12413be5411d517/src/.nuget/NuGet.exe -------------------------------------------------------------------------------- /src/.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | true 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 31 | 32 | 33 | 34 | 35 | $(SolutionDir).nuget 36 | 37 | 38 | 39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config 40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config 41 | 42 | 43 | 44 | $(MSBuildProjectDirectory)\packages.config 45 | $(PackagesProjectConfig) 46 | 47 | 48 | 49 | 50 | $(NuGetToolsPath)\NuGet.exe 51 | @(PackageSource) 52 | 53 | "$(NuGetExePath)" 54 | mono --runtime=v4.0.30319 "$(NuGetExePath)" 55 | 56 | $(TargetDir.Trim('\\')) 57 | 58 | -RequireConsent 59 | -NonInteractive 60 | 61 | "$(SolutionDir) " 62 | "$(SolutionDir)" 63 | 64 | 65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) 66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols 67 | 68 | 69 | 70 | RestorePackages; 71 | $(BuildDependsOn); 72 | 73 | 74 | 75 | 76 | $(BuildDependsOn); 77 | BuildPackage; 78 | 79 | 80 | 81 | 82 | 83 | 84 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 99 | 100 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /src/CommonAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyConfiguration("")] 6 | [assembly: AssemblyCompany("scriptcs contributors")] 7 | [assembly: AssemblyCopyright("Copyright (c) scriptcs contributors.")] 8 | [assembly: AssemblyTrademark("")] 9 | [assembly: AssemblyCulture("")] 10 | [assembly: AssemblyProduct("scriptcs")] 11 | 12 | // NOTE (adamralph): the assembly versions are fixed at 0.0.0.0 - only NuGet package versions matter 13 | [assembly: AssemblyVersion("0.0.0.0")] 14 | [assembly: AssemblyFileVersion("0.0.0.0")] 15 | 16 | // NOTE (adamralph): this is used for the NuGet package version 17 | [assembly: AssemblyInformationalVersion("0.2.0")] 18 | 19 | [assembly: ComVisible(false)] 20 | [assembly: CLSCompliant(false)] 21 | -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/CSharpModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ScriptCs.Contracts; 3 | 4 | namespace ScriptCs.CSharp 5 | { 6 | [Module("csharp")] 7 | public class CSharpModule : IModule 8 | { 9 | public void Initialize(IModuleConfiguration config) 10 | { 11 | if (config == null) 12 | { 13 | throw new ArgumentNullException("config"); 14 | } 15 | 16 | var engineType = config.Cache ? typeof(CSharpPersistentEngine) : typeof(CSharpScriptEngine); 17 | engineType = config.Debug ? typeof(CSharpScriptInMemoryEngine) : engineType; 18 | engineType = config.IsRepl ? typeof(CSharpReplEngine) : engineType; 19 | config.Overrides[typeof(IScriptEngine)] = engineType; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/CSharpPersistentEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Reflection; 5 | using Common.Logging; 6 | using ScriptCs.Contracts; 7 | 8 | namespace ScriptCs.CSharp 9 | { 10 | public class CSharpPersistentEngine : CSharpScriptCompilerEngine 11 | { 12 | private readonly IFileSystem _fileSystem; 13 | private const string RoslynAssemblyNameCharacter = "ℛ"; 14 | 15 | public CSharpPersistentEngine(IScriptHostFactory scriptHostFactory, ILog logger, IFileSystem fileSystem) 16 | : base(scriptHostFactory, logger) 17 | { 18 | _fileSystem = fileSystem; 19 | } 20 | 21 | protected override bool ShouldCompile() 22 | { 23 | var dllPath = GetDllTargetPath(); 24 | 25 | return !_fileSystem.FileExists(dllPath); 26 | } 27 | 28 | protected override Assembly LoadAssembly(byte[] exeBytes, byte[] pdbBytes) 29 | { 30 | this.Logger.DebugFormat("Writing assembly to {0}.", FileName); 31 | 32 | if (!_fileSystem.DirectoryExists(CacheDirectory)) 33 | { 34 | _fileSystem.CreateDirectory(CacheDirectory, true); 35 | } 36 | 37 | var dllPath = GetDllTargetPath(); 38 | _fileSystem.WriteAllBytes(dllPath, exeBytes); 39 | 40 | Logger.DebugFormat("Loading assembly {0}.", dllPath); 41 | 42 | // the assembly is automatically loaded into the AppDomain when compiled 43 | // just need to find and return it 44 | return AppDomain.CurrentDomain.GetAssemblies().LastOrDefault(x => x.FullName.StartsWith(RoslynAssemblyNameCharacter)); 45 | } 46 | 47 | protected override Assembly LoadAssemblyFromCache() 48 | { 49 | var dllPath = GetDllTargetPath(); 50 | return Assembly.LoadFrom(dllPath); 51 | } 52 | 53 | private string GetDllTargetPath() 54 | { 55 | var dllName = FileName.Replace(Path.GetExtension(FileName), ".dll"); 56 | var dllPath = Path.Combine(CacheDirectory, dllName); 57 | return dllPath; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/CSharpReplEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Common.Logging; 3 | using Microsoft.CodeAnalysis.Scripting; 4 | using ScriptCs.Contracts; 5 | using ScriptCs.Engine.Common; 6 | 7 | namespace ScriptCs.CSharp 8 | { 9 | public class CSharpReplEngine : CSharpScriptEngine, IReplEngine 10 | { 11 | public CSharpReplEngine(IScriptHostFactory scriptHostFactory, ILog logger) 12 | : base(scriptHostFactory, logger) 13 | { 14 | } 15 | 16 | public ICollection GetLocalVariables(ScriptPackSession scriptPackSession) 17 | { 18 | return this.GetLocalVariables(SessionKey, scriptPackSession); 19 | } 20 | 21 | protected override ScriptResult Execute(string code, object globals, SessionState sessionState) 22 | { 23 | return string.IsNullOrWhiteSpace(FileName) && !IsCompleteSubmission(code) 24 | ? ScriptResult.Incomplete 25 | : base.Execute(code, globals, sessionState); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/CSharpScriptCompilerEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Reflection; 5 | using Common.Logging; 6 | using Microsoft.CodeAnalysis.Scripting; 7 | using Microsoft.CodeAnalysis.Scripting.CSharp; 8 | using ScriptCs.Contracts; 9 | using ScriptCs.Engine.Common; 10 | using ScriptCs.Exceptions; 11 | 12 | namespace ScriptCs.CSharp 13 | { 14 | public abstract class CSharpScriptCompilerEngine : CommonScriptEngine 15 | { 16 | private const string CompiledScriptClass = "Submission#0"; 17 | 18 | private const string CompiledScriptMethod = ""; 19 | 20 | protected CSharpScriptCompilerEngine(IScriptHostFactory scriptHostFactory, ILog logger) 21 | : base(scriptHostFactory, logger) 22 | { 23 | } 24 | 25 | protected abstract bool ShouldCompile(); 26 | 27 | protected abstract Assembly LoadAssembly(byte[] exeBytes, byte[] pdbBytes); 28 | 29 | protected abstract Assembly LoadAssemblyFromCache(); 30 | 31 | protected override ScriptResult Execute(string code, object globals, SessionState sessionState) 32 | { 33 | return ShouldCompile() 34 | ? CompileAndExecute(code, globals) 35 | : InvokeEntryPointMethod(globals, LoadAssemblyFromCache()); 36 | } 37 | 38 | protected override ScriptState GetScriptState(string code, object globals) 39 | { 40 | return null; 41 | } 42 | 43 | protected ScriptResult CompileAndExecute(string code, object globals) 44 | { 45 | try 46 | { 47 | var script = CSharpScript.Create(code, ScriptOptions); 48 | var compilation = script.GetCompilation(); 49 | 50 | using (var exeStream = new MemoryStream()) 51 | using (var pdbStream = new MemoryStream()) 52 | { 53 | var result = compilation.Emit(exeStream, pdbStream: pdbStream); 54 | 55 | if (result.Success) 56 | { 57 | Logger.Debug("Compilation was successful."); 58 | 59 | var assembly = LoadAssembly(exeStream.ToArray(), pdbStream.ToArray()); 60 | return InvokeEntryPointMethod(globals, assembly); 61 | } 62 | 63 | var errors = string.Join(Environment.NewLine, result.Diagnostics.Select(x => x.ToString())); 64 | 65 | Logger.ErrorFormat("Error occurred when compiling: {0})", errors); 66 | 67 | return new ScriptResult(compilationException: new ScriptCompilationException(errors)); 68 | } 69 | } 70 | catch (Exception compileException) 71 | { 72 | //we catch Exception rather than CompilationErrorException because there might be issues with assembly loading too 73 | return new ScriptResult(compilationException: new ScriptCompilationException(compileException.Message, compileException)); 74 | } 75 | } 76 | 77 | private ScriptResult InvokeEntryPointMethod(object globals, Assembly assembly) 78 | { 79 | Logger.Debug("Retrieving compiled script class (reflection)."); 80 | 81 | // the following line can throw NullReferenceException, if that happens it's useful to notify that an error ocurred 82 | var type = assembly.GetType(CompiledScriptClass); 83 | Logger.Debug("Retrieving compiled script method (reflection)."); 84 | var method = type.GetMethod(CompiledScriptMethod, BindingFlags.Static | BindingFlags.Public); 85 | 86 | try 87 | { 88 | Logger.Debug("Invoking method."); 89 | var submissionStates = new object[2]; 90 | submissionStates[0] = globals; 91 | return new ScriptResult(returnValue: method.Invoke(null, new[] { submissionStates })); 92 | } 93 | catch (Exception executeException) 94 | { 95 | Logger.Error("An error occurred when executing the scripts."); 96 | 97 | var ex = executeException.InnerException ?? executeException; 98 | 99 | return new ScriptResult(executionException: ex); 100 | } 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/CSharpScriptEngine.cs: -------------------------------------------------------------------------------- 1 | using Common.Logging; 2 | using Microsoft.CodeAnalysis; 3 | using Microsoft.CodeAnalysis.CSharp; 4 | using Microsoft.CodeAnalysis.Scripting; 5 | using Microsoft.CodeAnalysis.Scripting.CSharp; 6 | using ScriptCs.Contracts; 7 | using ScriptCs.Engine.Common; 8 | 9 | namespace ScriptCs.CSharp 10 | { 11 | public class CSharpScriptEngine : CommonScriptEngine 12 | { 13 | public CSharpScriptEngine(IScriptHostFactory scriptHostFactory, ILog logger) : base(scriptHostFactory, logger) 14 | { 15 | } 16 | 17 | protected override ScriptState GetScriptState(string code, object globals) 18 | { 19 | return CSharpScript.Run(code, ScriptOptions, globals); 20 | } 21 | 22 | protected bool IsCompleteSubmission(string code) 23 | { 24 | //invalid REPL command 25 | if (code.StartsWith(":")) 26 | { 27 | return true; 28 | } 29 | 30 | var options = new CSharpParseOptions(LanguageVersion.CSharp6, DocumentationMode.Parse, 31 | SourceCodeKind.Interactive, null); 32 | 33 | var syntaxTree = SyntaxFactory.ParseSyntaxTree(code, options: options); 34 | return SyntaxFactory.IsCompleteSubmission(syntaxTree); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/CSharpScriptInMemoryEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Common.Logging; 4 | using ScriptCs.Contracts; 5 | 6 | namespace ScriptCs.CSharp 7 | { 8 | public class CSharpScriptInMemoryEngine : CSharpScriptCompilerEngine 9 | { 10 | public CSharpScriptInMemoryEngine(IScriptHostFactory scriptHostFactory, ILog logger) 11 | : base(scriptHostFactory, logger) 12 | { 13 | } 14 | 15 | protected override bool ShouldCompile() 16 | { 17 | return true; 18 | } 19 | 20 | protected override Assembly LoadAssemblyFromCache() 21 | { 22 | throw new NotImplementedException("Reaching this point indicates a bug. The RoslynScriptInMemoryEngine should never load the assembly from the cache."); 23 | } 24 | 25 | protected override Assembly LoadAssembly(byte[] exeBytes, byte[] pdbBytes) 26 | { 27 | this.Logger.Debug("Loading assembly from memory."); 28 | 29 | // this is required for debugging. otherwise, the .dll is not related to the .pdb 30 | // there might be ways of doing this without "loading", haven't found one yet 31 | return AppDomain.CurrentDomain.Load(exeBytes, pdbBytes); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("ScriptCs.CSharp")] 4 | [assembly: AssemblyDescription( 5 | "ScriptCs.CSharp provides a Microsoft.CodeAnalysis-based C# script engine for scriptcs.")] 6 | -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/ScriptCs.CSharp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B} 8 | Library 9 | ScriptCs.CSharp 10 | ScriptCs.CSharp 11 | Properties 12 | 512 13 | v4.5 14 | 15 | ..\..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | ..\..\..\scriptcs\src\Scriptcs\bin\debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll 38 | 39 | 40 | False 41 | ..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.dll 42 | 43 | 44 | False 45 | ..\packages\Microsoft.CodeAnalysis.CSharp.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll 46 | 47 | 48 | False 49 | ..\packages\Microsoft.CodeAnalysis.CSharp.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.CSharp.Desktop.dll 50 | 51 | 52 | False 53 | ..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.Desktop.dll 54 | 55 | 56 | False 57 | ..\packages\Microsoft.CodeAnalysis.Scripting.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.Scripting.dll 58 | 59 | 60 | False 61 | ..\packages\Microsoft.CodeAnalysis.Scripting.CSharp.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.Scripting.CSharp.dll 62 | 63 | 64 | False 65 | ..\packages\ScriptCs.Contracts.0.14.1\lib\net45\ScriptCs.Contracts.dll 66 | 67 | 68 | False 69 | ..\packages\ScriptCs.Core.0.14.1\lib\net45\ScriptCs.Core.dll 70 | 71 | 72 | 73 | False 74 | ..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 75 | 76 | 77 | 78 | 79 | ..\packages\System.Reflection.Metadata.1.0.18-beta\lib\portable-net45+win8\System.Reflection.Metadata.dll 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Properties\CommonAssemblyInfo.cs 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | Designer 102 | 103 | 104 | 105 | 106 | 107 | 108 | {38a12481-8652-4a9c-9d90-1c15043efee5} 109 | ScriptCs.Engine.Common 110 | 111 | 112 | 113 | 114 | 115 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/ScriptCs.CSharp.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ScriptCs.CSharp 5 | 6 | 0.0.0 7 | ScriptCs.CSharp 8 | Glenn Block, Filip Wojcieszyn, Justin Rusbatch, Kristian Hellang, Damian Schenkelman, Adam Ralph 9 | ScriptCs.CSharp provides a Microsoft.CodeAnalysis-based C# script engine for scriptcs. 10 | http://scriptcs.net 11 | http://www.gravatar.com/avatar/5c754f646971d8bc800b9d4057931938.png?s=120 12 | https://github.com/scriptcs/scriptcs/blob/master/LICENSE.md 13 | false 14 | roslyn csx script scriptcs 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/ScriptCs.CSharp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/ScriptCs.Engine.Common/CommonScriptEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Common.Logging; 5 | using Microsoft.CodeAnalysis.Scripting; 6 | using ScriptCs.Contracts; 7 | 8 | namespace ScriptCs.Engine.Common 9 | { 10 | public abstract class CommonScriptEngine : IScriptEngine 11 | { 12 | protected ScriptOptions ScriptOptions; 13 | private readonly IScriptHostFactory _scriptHostFactory; 14 | 15 | public const string SessionKey = "Session"; 16 | 17 | protected CommonScriptEngine(IScriptHostFactory scriptHostFactory, ILog logger) 18 | { 19 | ScriptOptions = new ScriptOptions().WithReferences(typeof(ScriptExecutor).Assembly, typeof(Object).Assembly); 20 | _scriptHostFactory = scriptHostFactory; 21 | Logger = logger; 22 | } 23 | 24 | protected ILog Logger { get; private set; } 25 | 26 | public string BaseDirectory 27 | { 28 | get { return ScriptOptions.BaseDirectory; } 29 | set { ScriptOptions = ScriptOptions.WithBaseDirectory(value); } 30 | } 31 | 32 | public string CacheDirectory { get; set; } 33 | 34 | public string FileName { get; set; } 35 | 36 | public ScriptResult Execute(string code, string[] scriptArgs, AssemblyReferences references, IEnumerable namespaces, ScriptPackSession scriptPackSession) 37 | { 38 | if (scriptPackSession == null) 39 | { 40 | throw new ArgumentNullException("scriptPackSession"); 41 | } 42 | 43 | if (references == null) 44 | { 45 | throw new ArgumentNullException("references"); 46 | } 47 | 48 | Logger.Debug("Starting to create execution components"); 49 | Logger.Debug("Creating script host"); 50 | 51 | var executionReferences = new AssemblyReferences(references.Assemblies, references.Paths); 52 | executionReferences.Union(scriptPackSession.References); 53 | 54 | ScriptResult scriptResult; 55 | SessionState sessionState; 56 | 57 | var isFirstExecution = !scriptPackSession.State.ContainsKey(SessionKey); 58 | 59 | var host = _scriptHostFactory.CreateScriptHost(new ScriptPackManager(scriptPackSession.Contexts), scriptArgs); 60 | Logger.Debug("Creating session"); 61 | 62 | var hostType = host.GetType(); 63 | 64 | if (isFirstExecution) 65 | { 66 | ScriptOptions = ScriptOptions.AddReferences(hostType.Assembly); 67 | 68 | var allNamespaces = namespaces.Union(scriptPackSession.Namespaces).Distinct(); 69 | 70 | foreach (var reference in executionReferences.Paths) 71 | { 72 | Logger.DebugFormat("Adding reference to {0}", reference); 73 | ScriptOptions = ScriptOptions.AddReferences(reference); 74 | } 75 | 76 | foreach (var assembly in executionReferences.Assemblies) 77 | { 78 | Logger.DebugFormat("Adding reference to {0}", assembly.FullName); 79 | ScriptOptions = ScriptOptions.AddReferences(assembly); 80 | } 81 | 82 | foreach (var @namespace in allNamespaces) 83 | { 84 | Logger.DebugFormat("Importing namespace {0}", @namespace); 85 | ScriptOptions = ScriptOptions.AddNamespaces(@namespace); 86 | } 87 | 88 | sessionState = new SessionState { References = executionReferences, Namespaces = new HashSet(allNamespaces) }; 89 | scriptPackSession.State[SessionKey] = sessionState; 90 | 91 | scriptResult = Execute(code, host, sessionState); 92 | } 93 | else 94 | { 95 | Logger.Debug("Reusing existing session"); 96 | sessionState = (SessionState)scriptPackSession.State[SessionKey]; 97 | 98 | if (sessionState.References == null) 99 | { 100 | sessionState.References = new AssemblyReferences(); 101 | } 102 | 103 | if (sessionState.Namespaces == null) 104 | { 105 | sessionState.Namespaces = new HashSet(); 106 | } 107 | 108 | var newReferences = executionReferences.Except(sessionState.References); 109 | 110 | foreach (var reference in newReferences.Paths) 111 | { 112 | Logger.DebugFormat("Adding reference to {0}", reference); 113 | ScriptOptions.AddReferences(reference); 114 | sessionState.References = sessionState.References.Union(new[] { reference }); 115 | } 116 | 117 | foreach (var assembly in newReferences.Assemblies) 118 | { 119 | Logger.DebugFormat("Adding reference to {0}", assembly.FullName); 120 | ScriptOptions.AddReferences(assembly); 121 | sessionState.References = sessionState.References.Union(new[] { assembly }); 122 | } 123 | 124 | var newNamespaces = namespaces.Except(sessionState.Namespaces); 125 | 126 | foreach (var @namespace in newNamespaces) 127 | { 128 | Logger.DebugFormat("Importing namespace {0}", @namespace); 129 | ScriptOptions.AddNamespaces(@namespace); 130 | sessionState.Namespaces.Add(@namespace); 131 | } 132 | 133 | if (string.IsNullOrWhiteSpace(code)) 134 | { 135 | return ScriptResult.Empty; 136 | } 137 | 138 | scriptResult = Execute(code, sessionState.Session, sessionState); 139 | } 140 | 141 | return scriptResult; 142 | 143 | //todo handle namespace failures 144 | //https://github.com/dotnet/roslyn/issues/1012 145 | } 146 | 147 | protected virtual ScriptResult Execute(string code, object globals, SessionState sessionState) 148 | { 149 | try 150 | { 151 | Logger.Debug("Starting execution"); 152 | var result = GetScriptState(code, globals); 153 | Logger.Debug("Finished execution"); 154 | sessionState.Session = result; 155 | return new ScriptResult(returnValue: result.ReturnValue); 156 | } 157 | catch (AggregateException ex) 158 | { 159 | return new ScriptResult(executionException: ex.InnerException); 160 | } 161 | catch (CompilationErrorException ex) 162 | { 163 | return new ScriptResult(compilationException: ex); 164 | } 165 | catch (Exception ex) 166 | { 167 | return new ScriptResult(executionException: ex); 168 | } 169 | } 170 | 171 | protected abstract ScriptState GetScriptState(string code, object globals); 172 | 173 | } 174 | } -------------------------------------------------------------------------------- /src/ScriptCs.Engine.Common/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("ScriptCs.Engines.Common")] 4 | [assembly: AssemblyDescription( 5 | "ScriptCs.Engine.Common provides common types for Microsoft.CodeAnalysis-based script engines for scriptcs.")] 6 | -------------------------------------------------------------------------------- /src/ScriptCs.Engine.Common/ReplEngineExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Microsoft.CodeAnalysis.Scripting; 4 | using ScriptCs.Contracts; 5 | 6 | namespace ScriptCs.Engine.Common 7 | { 8 | public static class ReplEngineExtensions 9 | { 10 | public static ICollection GetLocalVariables(this IReplEngine replEngine, string sessionKey, 11 | ScriptPackSession scriptPackSession) 12 | { 13 | if (scriptPackSession != null && scriptPackSession.State.ContainsKey(sessionKey)) 14 | { 15 | var sessionState = (SessionState)scriptPackSession.State[sessionKey]; 16 | return sessionState.Session.Variables.Select(x => string.Format("{0} {1}", x.Type, x.Name)).ToArray(); 17 | } 18 | 19 | return new string[0]; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/ScriptCs.Engine.Common/ScriptCs.Engine.Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {38A12481-8652-4A9C-9D90-1C15043EFEE5} 8 | Library 9 | Properties 10 | ScriptCs.Engine.Common 11 | ScriptCs.Engine.Common 12 | v4.5 13 | 512 14 | ..\ 15 | true 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | False 38 | ..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll 39 | 40 | 41 | False 42 | ..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.dll 43 | 44 | 45 | False 46 | ..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.Desktop.dll 47 | 48 | 49 | False 50 | ..\packages\Microsoft.CodeAnalysis.Scripting.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.Scripting.dll 51 | 52 | 53 | False 54 | ..\packages\ScriptCs.Contracts.0.14.1\lib\net45\ScriptCs.Contracts.dll 55 | 56 | 57 | False 58 | ..\packages\ScriptCs.Core.0.14.1\lib\net45\ScriptCs.Core.dll 59 | 60 | 61 | 62 | True 63 | ..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 64 | 65 | 66 | 67 | 68 | ..\packages\System.Reflection.Metadata.1.0.18-beta\lib\portable-net45+win8\System.Reflection.Metadata.dll 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | Properties\CommonAssemblyInfo.cs 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 94 | 95 | 96 | 97 | 104 | -------------------------------------------------------------------------------- /src/ScriptCs.Engine.Common/ScriptCs.Engine.Common.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ScriptCs.Engine.Common 5 | 6 | 0.0.0 7 | ScriptCs.Engine.Common 8 | Glenn Block, Filip Wojcieszyn, Justin Rusbatch, Kristian Hellang, Damian Schenkelman, Adam Ralph 9 | ScriptCs.Engine.Common provides common types for Microsoft.CodeAnalysis-based script engines for scriptcs. 10 | http://scriptcs.net 11 | http://www.gravatar.com/avatar/5c754f646971d8bc800b9d4057931938.png?s=120 12 | https://github.com/scriptcs/scriptcs/blob/master/LICENSE.md 13 | false 14 | roslyn script scriptcs 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/ScriptCs.Engine.Common/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/ScriptCs.Engine.Common/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/ScriptCs.Engines.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.CSharp", "ScriptCs.CSharp\ScriptCs.CSharp.csproj", "{E79EC231-E27D-4057-91C9-2D001A3A8C3B}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{17604CB7-1E38-4755-ADAE-3E292492E678}" 9 | ProjectSection(SolutionItems) = preProject 10 | .nuget\NuGet.Config = .nuget\NuGet.Config 11 | .nuget\NuGet.exe = .nuget\NuGet.exe 12 | .nuget\NuGet.targets = .nuget\NuGet.targets 13 | EndProjectSection 14 | EndProject 15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Engine.Common", "ScriptCs.Engine.Common\ScriptCs.Engine.Common.csproj", "{38A12481-8652-4A9C-9D90-1C15043EFEE5}" 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.VisualBasic", "ScriptCs.VisualBasic\ScriptCs.VisualBasic.csproj", "{4C68DC34-60AB-405B-878F-377CF6C4336C}" 18 | EndProject 19 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DC4B1FD2-A3F5-4A0B-9A08-1993AC1E83CC}" 20 | ProjectSection(SolutionItems) = preProject 21 | CommonAssemblyInfo.cs = CommonAssemblyInfo.cs 22 | nuget.config = nuget.config 23 | EndProjectSection 24 | EndProject 25 | Global 26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 27 | Debug|Any CPU = Debug|Any CPU 28 | Debug|AnyCPU = Debug|AnyCPU 29 | Debug|Mixed Platforms = Debug|Mixed Platforms 30 | Release|Any CPU = Release|Any CPU 31 | Release|AnyCPU = Release|AnyCPU 32 | Release|Mixed Platforms = Release|Mixed Platforms 33 | EndGlobalSection 34 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 35 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU 38 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|AnyCPU.Build.0 = Debug|Any CPU 39 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 40 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 41 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|AnyCPU.ActiveCfg = Release|Any CPU 44 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|AnyCPU.Build.0 = Release|Any CPU 45 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 46 | {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|Mixed Platforms.Build.0 = Release|Any CPU 47 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 48 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Debug|Any CPU.Build.0 = Debug|Any CPU 49 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU 50 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Debug|AnyCPU.Build.0 = Debug|Any CPU 51 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 52 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 53 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Release|Any CPU.ActiveCfg = Release|Any CPU 54 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Release|Any CPU.Build.0 = Release|Any CPU 55 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Release|AnyCPU.ActiveCfg = Release|Any CPU 56 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Release|AnyCPU.Build.0 = Release|Any CPU 57 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 58 | {38A12481-8652-4A9C-9D90-1C15043EFEE5}.Release|Mixed Platforms.Build.0 = Release|Any CPU 59 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 60 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Debug|Any CPU.Build.0 = Debug|Any CPU 61 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU 62 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Debug|AnyCPU.Build.0 = Debug|Any CPU 63 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 64 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 65 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Release|Any CPU.ActiveCfg = Release|Any CPU 66 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Release|Any CPU.Build.0 = Release|Any CPU 67 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Release|AnyCPU.ActiveCfg = Release|Any CPU 68 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Release|AnyCPU.Build.0 = Release|Any CPU 69 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 70 | {4C68DC34-60AB-405B-878F-377CF6C4336C}.Release|Mixed Platforms.Build.0 = Release|Any CPU 71 | EndGlobalSection 72 | GlobalSection(SolutionProperties) = preSolution 73 | HideSolutionNode = FALSE 74 | EndGlobalSection 75 | EndGlobal 76 | -------------------------------------------------------------------------------- /src/ScriptCs.VisualBasic/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("ScriptCs.VisualBasic")] 4 | [assembly: AssemblyDescription( 5 | "ScriptCs.VisualBasic provides a Microsoft.CodeAnalysis-based VisualBasic script engine for scriptcs.")] 6 | -------------------------------------------------------------------------------- /src/ScriptCs.VisualBasic/ScriptCs.VisualBasic.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4C68DC34-60AB-405B-878F-377CF6C4336C} 8 | Library 9 | Properties 10 | ScriptCs.VisualBasic 11 | ScriptCs.VisualBasic 12 | v4.5 13 | 512 14 | ..\ 15 | true 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll 38 | 39 | 40 | False 41 | ..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.dll 42 | 43 | 44 | False 45 | ..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.Desktop.dll 46 | 47 | 48 | False 49 | ..\packages\Microsoft.CodeAnalysis.Scripting.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.Scripting.dll 50 | 51 | 52 | False 53 | ..\packages\Microsoft.CodeAnalysis.Scripting.VisualBasic.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.Scripting.VisualBasic.dll 54 | 55 | 56 | False 57 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.dll 58 | 59 | 60 | False 61 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.Desktop.dll 62 | 63 | 64 | False 65 | ..\packages\ScriptCs.Contracts.0.14.1\lib\net45\ScriptCs.Contracts.dll 66 | 67 | 68 | False 69 | ..\packages\ScriptCs.Core.0.14.1\lib\net45\ScriptCs.Core.dll 70 | 71 | 72 | 73 | True 74 | ..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 75 | 76 | 77 | 78 | 79 | ..\packages\System.Reflection.Metadata.1.0.18-beta\lib\portable-net45+win8\System.Reflection.Metadata.dll 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Properties\CommonAssemblyInfo.cs 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | {38a12481-8652-4a9c-9d90-1c15043efee5} 105 | ScriptCs.Engine.Common 106 | 107 | 108 | 109 | 110 | 111 | 112 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 113 | 114 | 115 | 116 | 123 | -------------------------------------------------------------------------------- /src/ScriptCs.VisualBasic/ScriptCs.VisualBasic.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ScriptCs.VisualBasic 5 | 6 | 0.0.0 7 | ScriptCs.VisualBasic 8 | Glenn Block, Filip Wojcieszyn, Justin Rusbatch, Kristian Hellang, Damian Schenkelman, Adam Ralph 9 | ScriptCs.CSharp provides a Microsoft.CodeAnalysis-based VisualBasic script engine for scriptcs. 10 | http://scriptcs.net 11 | http://www.gravatar.com/avatar/5c754f646971d8bc800b9d4057931938.png?s=120 12 | https://github.com/scriptcs/scriptcs/blob/master/LICENSE.md 13 | false 14 | roslyn vbx script scriptcs 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/ScriptCs.VisualBasic/VisualBasicModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ScriptCs.Contracts; 3 | 4 | namespace ScriptCs.VisualBasic 5 | { 6 | [Module("vb")] 7 | public class VisualBasicModule : IModule 8 | { 9 | public void Initialize(IModuleConfiguration config) 10 | { 11 | if (config == null) 12 | { 13 | throw new ArgumentNullException("config"); 14 | } 15 | 16 | var engineType = config.IsRepl ? typeof(VisualBasicReplEngine) : typeof(VisualBasicScriptEngine); 17 | config.Overrides[typeof (IScriptEngine)] = engineType; 18 | config.LineProcessor(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/ScriptCs.VisualBasic/VisualBasicNamespaceLineProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ScriptCs.Contracts; 3 | 4 | namespace ScriptCs.VisualBasic 5 | { 6 | public class VisualBasicNamespaceLineProcessor : IUsingLineProcessor 7 | { 8 | private const string NamespaceString = "Imports "; 9 | 10 | public bool ProcessLine(IFileParser parser, FileParserContext context, string line, bool isBeforeCode) 11 | { 12 | if (context == null) throw new ArgumentNullException("context"); 13 | 14 | if (!IsUsingLine(line)) 15 | { 16 | return false; 17 | } 18 | 19 | var @namespace = GetNamespace(line); 20 | if (!context.Namespaces.Contains(@namespace)) 21 | { 22 | context.Namespaces.Add(@namespace); 23 | } 24 | 25 | return true; 26 | } 27 | 28 | private static bool IsUsingLine(string line) 29 | { 30 | return line.Trim(' ').StartsWith(NamespaceString); 31 | } 32 | 33 | private static string GetNamespace(string line) 34 | { 35 | return line.Trim(' ') 36 | .Replace(NamespaceString, string.Empty) 37 | .Replace("\"", string.Empty); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/ScriptCs.VisualBasic/VisualBasicReplEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Common.Logging; 3 | using Microsoft.CodeAnalysis.Scripting; 4 | using ScriptCs.Contracts; 5 | using ScriptCs.Engine.Common; 6 | 7 | namespace ScriptCs.VisualBasic 8 | { 9 | public class VisualBasicReplEngine : VisualBasicScriptEngine, IReplEngine 10 | { 11 | public VisualBasicReplEngine(IScriptHostFactory scriptHostFactory, ILog logger) 12 | : base(scriptHostFactory, logger) 13 | { 14 | } 15 | 16 | public ICollection GetLocalVariables(ScriptPackSession scriptPackSession) 17 | { 18 | return this.GetLocalVariables(SessionKey, scriptPackSession); 19 | } 20 | 21 | protected override ScriptResult Execute(string code, object globals, SessionState sessionState) 22 | { 23 | return string.IsNullOrWhiteSpace(FileName) && !IsCompleteSubmission(code) 24 | ? ScriptResult.Incomplete 25 | : base.Execute(code, globals, sessionState); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/ScriptCs.VisualBasic/VisualBasicScriptEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Common.Logging; 3 | using Microsoft.CodeAnalysis; 4 | using Microsoft.CodeAnalysis.Scripting; 5 | using Microsoft.CodeAnalysis.Scripting.VisualBasic; 6 | using Microsoft.CodeAnalysis.VisualBasic; 7 | using ScriptCs.Contracts; 8 | using ScriptCs.Engine.Common; 9 | 10 | namespace ScriptCs.VisualBasic 11 | { 12 | public class VisualBasicScriptEngine : CommonScriptEngine 13 | { 14 | public VisualBasicScriptEngine(IScriptHostFactory scriptHostFactory, ILog logger) 15 | : base(scriptHostFactory, logger) 16 | { 17 | } 18 | 19 | protected override ScriptState GetScriptState(string code, object globals) 20 | { 21 | return VisualBasicScript.Run(code, ScriptOptions, globals); 22 | } 23 | 24 | protected bool IsCompleteSubmission(string code) 25 | { 26 | //invalid REPL command 27 | if (code.StartsWith(":")) 28 | { 29 | return true; 30 | } 31 | 32 | var options = new VisualBasicParseOptions(LanguageVersion.VisualBasic14, DocumentationMode.Parse, SourceCodeKind.Interactive, null); 33 | var syntaxTree = SyntaxFactory.ParseSyntaxTree(code, options); 34 | var diagnostics = syntaxTree.GetDiagnostics(); 35 | return !diagnostics.Any(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/ScriptCs.VisualBasic/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/ScriptCs.VisualBasic/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | --------------------------------------------------------------------------------