diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-04-20 23:28:38 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-04-20 23:28:38 +0300 |
| commit | f06785ae3312a82b8f2237b55e8c4eeb174c3519 (patch) | |
| tree | a69adf9bf83c75f7afb5d9ce282ab20b04f1e7eb | |
| parent | 9f130d933ce847d03efe341dd89b7609c402ac00 (diff) | |
| download | Tango-f06785ae3312a82b8f2237b55e8c4eeb174c3519.tar.gz Tango-f06785ae3312a82b8f2237b55e8c4eeb174c3519.zip | |
Scripting.
15 files changed, 431 insertions, 38 deletions
diff --git a/Software/Experiments/RoslynTest/ConsoleApp8/ConsoleApp8/lib_template.csx b/Software/Experiments/RoslynTest/ConsoleApp8/ConsoleApp8/lib_template.csx new file mode 100644 index 000000000..93c79d32f --- /dev/null +++ b/Software/Experiments/RoslynTest/ConsoleApp8/ConsoleApp8/lib_template.csx @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +public class lib +{ + public void Show(String msg) + { + MessageBox.Show(msg); + } +} diff --git a/Software/Experiments/RoslynTest/ConsoleApp8/ConsoleApp8/main_template.csx b/Software/Experiments/RoslynTest/ConsoleApp8/ConsoleApp8/main_template.csx new file mode 100644 index 000000000..61d086068 --- /dev/null +++ b/Software/Experiments/RoslynTest/ConsoleApp8/ConsoleApp8/main_template.csx @@ -0,0 +1,16 @@ +#load "lib.csx" + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ConsoleApp8; + +public TestResult OnExecute(String msg) +{ + lib l = new lib(); + l.Show(msg); + + return new TestResult() { Value = "This is a return value" }; +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ITestContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ITestContext.cs new file mode 100644 index 000000000..671b2174a --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ITestContext.cs @@ -0,0 +1,26 @@ +using Google.Protobuf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Operation; +using Tango.Scripting.Basic; + +namespace Tango.FSE.Stubs +{ + public interface ITestContext : IContext + { + IMessage Run(String stubName, params Object[] args); + IMessage Run(IMessage stub); + void RunContinuous<T>(T stub, Action<T> callback) where T : class, IMessage; + void RunContinuous<T>(String stubName, Action<T> callback, params Object[] args) where T : class, IMessage; + void WriteLine(Object obj); + void Write(Object obj); + void WriteLineHex(Object number, int digits); + void WriteHex(Object number, int digits); + void Clear(); + void WriteToFile(String filePath, String content); + void AppendToFile(String filePath, String content); + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProjectRunner.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProjectRunner.cs index 0625fa08f..00ab0caca 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProjectRunner.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProjectRunner.cs @@ -35,8 +35,17 @@ namespace Tango.FSE.Stubs { if (State != ProjectRunnerState.Compiling && State != ProjectRunnerState.Running) { - State = ProjectRunnerState.Compiling; - _currentSession = await Project.Run(null); + try + { + State = ProjectRunnerState.Compiling; + _currentSession = await Project.Run(null); + } + catch (Exception ex) + { + State = ProjectRunnerState.None; + throw ex; + } + State = ProjectRunnerState.Running; try @@ -62,7 +71,7 @@ namespace Tango.FSE.Stubs public void Stop() { - _currentSession.Abort(); + _currentSession?.Abort(); State = ProjectRunnerState.Aborted; } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/main_template.csx b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/main_template.csx index 3d6c4f3b9..34604c6d3 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/main_template.csx +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Resources/main_template.csx @@ -7,7 +7,7 @@ using Tango.FSE.Stubs; public class Program { - public Object OnExecute(IContext context) + public Object OnExecute(ITestContext context) { return new diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Tango.FSE.Stubs.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Tango.FSE.Stubs.csproj index 3e495564d..9058bf074 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Tango.FSE.Stubs.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Tango.FSE.Stubs.csproj @@ -61,6 +61,22 @@ <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> + <Reference Include="System.Reactive.Core, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll</HintPath> + </Reference> + <Reference Include="System.Reactive.Interfaces, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll</HintPath> + </Reference> + <Reference Include="System.Reactive.Linq, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\System.Reactive.Linq.3.1.1\lib\net46\System.Reactive.Linq.dll</HintPath> + </Reference> + <Reference Include="System.Reactive.PlatformServices, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\System.Reactive.PlatformServices.3.1.1\lib\net46\System.Reactive.PlatformServices.dll</HintPath> + </Reference> + <Reference Include="System.Reactive.Windows.Threading, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll</HintPath> + </Reference> + <Reference Include="System.Windows" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll</HintPath> </Reference> @@ -80,8 +96,10 @@ <ItemGroup> <Compile Include="Designer\ProjectModel.cs" /> <Compile Include="Designer\ScriptTabModel.cs" /> + <Compile Include="ITestContext.cs" /> <Compile Include="ProjectRunner.cs" /> <Compile Include="ProjectRunnerState.cs" /> + <Compile Include="TestContext.cs" /> <Compile Include="ViewModelLocator.cs" /> <Compile Include="StubsModule.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> @@ -115,7 +133,9 @@ <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> - <None Include="app.config" /> + <None Include="app.config"> + <SubType>Designer</SubType> + </None> <None Include="packages.config" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/TestContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/TestContext.cs new file mode 100644 index 000000000..e40ccebfc --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/TestContext.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Google.Protobuf; +using Tango.Core.DI; +using Tango.FSE.Common.Notifications; +using Tango.FSE.Common.Threading; +using Tango.Integration.Operation; +using Tango.PMR; +using Tango.Scripting.Basic; + +namespace Tango.FSE.Stubs +{ + public class TestContext : ITestContext + { + private IMachineOperator _machineOperator; + private INotificationProvider _notificationProvider; + private IDispatcherProvider _dispatcherProvider; + + public TestContext(IMachineOperator machineOperator, INotificationProvider notificationProvider, IDispatcherProvider dispatcherProvider) + { + _machineOperator = machineOperator; + _notificationProvider = notificationProvider; + _dispatcherProvider = dispatcherProvider; + } + + public IMessage Run(string stubName, params object[] args) + { + var stubType = MessageFactory.GetAvailableRequestStubs().SingleOrDefault(x => x.Name.ToLower() == stubName.ToLower() || x.Name.Replace("Request", "").ToLower() == stubName.ToLower()); + if (stubType == null) + { + throw new ArgumentException("Invalid stub '" + stubName + "'."); + } + + var stubProps = stubType.GetProperties(BindingFlags.Public | BindingFlags.Instance); + + if (stubProps.Length > args.Length) + { + throw new ArgumentOutOfRangeException("Not enough arguments for " + stubType.Name + "."); + } + + Object request = Activator.CreateInstance(stubType); + + int argIndex = 0; + foreach (var prop in stubProps) + { + Object arg = args[argIndex++]; + + if (prop.PropertyType == typeof(UInt32)) + { + prop.SetValue(request, UInt32.Parse(arg.ToString())); + } + else if (prop.PropertyType == typeof(bool)) + { + prop.SetValue(request, bool.Parse(arg.ToString())); + } + else if (prop.PropertyType.IsPrimitive) + { + object converted = Convert.ChangeType(arg, prop.PropertyType); + prop.SetValue(request, converted); + } + else + { + prop.SetValue(request, arg); + } + } + + return Run(request as IMessage); + } + + public IMessage Run(IMessage stub) + { + return _machineOperator.SendRequest(stub, new Transport.TransportRequestConfig()).Result; + } + + public void RunContinuous<T>(T stub, Action<T> callback) where T : class, IMessage + { + Type stubType = stub.GetType(); + + _machineOperator.SendContinuousRequest(stub, new Transport.TransportContinuousRequestConfig()).Subscribe((msg) => + { + callback?.Invoke(msg as T); + + //Next + }, (ex) => + { + //OnFailed(ex); + //Error + }, () => + { + //OnCompleted("Continuous request completed."); + //Completed + }); + } + + public void RunContinuous<T>(string stubName, Action<T> callback, params object[] args) where T : class, IMessage + { + var stubType = MessageFactory.GetAvailableRequestStubs().SingleOrDefault(x => x.Name.ToLower() == stubName.ToLower() || x.Name.Replace("Request", "").ToLower() == stubName.ToLower()); + if (stubType == null) + { + throw new ArgumentException("Invalid stub '" + stubName + "'."); + } + + var stubProps = stubType.GetProperties(BindingFlags.Public | BindingFlags.Instance); + + if (stubProps.Length > args.Length) + { + throw new ArgumentOutOfRangeException("Not enough arguments for " + stubType.Name + "."); + } + + IMessage request = Activator.CreateInstance(stubType) as IMessage; + + int argIndex = 0; + foreach (var prop in stubProps) + { + Object arg = args[argIndex++]; + + if (prop.PropertyType == typeof(UInt32)) + { + prop.SetValue(request, UInt32.Parse(arg.ToString())); + } + else if (prop.PropertyType == typeof(bool)) + { + prop.SetValue(request, bool.Parse(arg.ToString())); + } + else if (prop.PropertyType.IsPrimitive) + { + object converted = Convert.ChangeType(arg, prop.PropertyType); + prop.SetValue(request, converted); + } + else + { + prop.SetValue(request, arg); + } + } + + RunContinuous<IMessage>(request, callback as Action<IMessage>); + } + + public void WriteLine(object obj) + { + throw new NotImplementedException(); + } + + public void Write(object obj) + { + throw new NotImplementedException(); + } + + public void WriteLineHex(object number, int digits) + { + throw new NotImplementedException(); + } + + public void WriteHex(object number, int digits) + { + throw new NotImplementedException(); + } + + public void Clear() + { + throw new NotImplementedException(); + } + + public void WriteToFile(string filePath, string content) + { + throw new NotImplementedException(); + } + + public void AppendToFile(string filePath, string content) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ViewModels/TestDesignerViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ViewModels/TestDesignerViewVM.cs index 6544e643c..6e6873c9a 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ViewModels/TestDesignerViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ViewModels/TestDesignerViewVM.cs @@ -95,7 +95,8 @@ namespace Tango.FSE.Stubs.ViewModels private void CreateNewProject() { - var project = Project.New("test1", Encoding.UTF8.GetString(Properties.Resources.main_template)); + var project = Project.New("test1"); + project.Scripts.Add(Script.New("Program.csx", Encoding.UTF8.GetString(Properties.Resources.main_template), true)); project.Scripts.Add(Script.New("lib.csx", Encoding.UTF8.GetString(Properties.Resources.lib_template))); project.ReferenceAssemblies.Add(new ReferenceAssembly() { FromType = this.GetType() }); project.ReferenceAssemblies.Add(new ReferenceAssembly() { FromType = typeof(PMR.Common.MessageType) }); diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/packages.config b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/packages.config index dd8c723e4..d17a56d7d 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/packages.config +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/packages.config @@ -7,4 +7,10 @@ <package id="MaterialDesignColors" version="1.2.2" targetFramework="net461" /> <package id="MaterialDesignThemes" version="3.0.1" targetFramework="net461" /> <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" /> + <package id="System.Reactive" version="3.1.1" targetFramework="net461" /> + <package id="System.Reactive.Core" version="3.1.1" targetFramework="net461" /> + <package id="System.Reactive.Interfaces" version="3.1.1" targetFramework="net461" /> + <package id="System.Reactive.Linq" version="3.1.1" targetFramework="net461" /> + <package id="System.Reactive.PlatformServices" version="3.1.1" targetFramework="net461" /> + <package id="System.Reactive.Windows.Threading" version="3.1.1" targetFramework="net461" /> </packages>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.config b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.config index 7718ac028..291f23910 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.config +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.config @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> - <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> - </configSections> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections> <appSettings> <add key="GatewayUrl" value="http://localhost:2222" /> </appSettings> @@ -11,7 +11,7 @@ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> </startup> <runtime> - <legacyCorruptedStateExceptionsPolicy enabled="true|false"/> + <legacyCorruptedStateExceptionsPolicy enabled="true|false" /> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> @@ -81,7 +81,7 @@ <dependentAssembly> <assemblyIdentity name="Z.EntityFramework.Extensions" publicKeyToken="59b66d028979105b" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.50.0" newVersion="4.0.50.0" /> - </dependentAssembly> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index 6f37af1a0..72b4bf121 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -68,6 +68,18 @@ <Reference Include="MaterialDesignThemes.Wpf, Version=3.0.1.920, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\MaterialDesignThemes.3.0.1\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath> </Reference> + <Reference Include="Microsoft.CodeAnalysis, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.CodeAnalysis.Common.2.4.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath> + </Reference> + <Reference Include="Microsoft.CodeAnalysis.CSharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.CodeAnalysis.CSharp.2.4.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath> + </Reference> + <Reference Include="Microsoft.CodeAnalysis.CSharp.Scripting, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.CodeAnalysis.CSharp.Scripting.2.4.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Scripting.dll</HintPath> + </Reference> + <Reference Include="Microsoft.CodeAnalysis.Scripting, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.CodeAnalysis.Scripting.Common.2.4.0\lib\netstandard1.3\Microsoft.CodeAnalysis.Scripting.dll</HintPath> + </Reference> <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\WindowsAPICodePack-Core.1.1.1\lib\Microsoft.WindowsAPICodePack.dll</HintPath> </Reference> @@ -78,13 +90,38 @@ <HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> <Reference Include="System" /> + <Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath> + </Reference> + <Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath> + </Reference> + <Reference Include="System.ComponentModel.Composition" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Configuration" /> + <Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath> + </Reference> <Reference Include="System.Data" /> + <Reference Include="System.Diagnostics.FileVersionInfo, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll</HintPath> + </Reference> + <Reference Include="System.Diagnostics.StackTrace, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll</HintPath> + </Reference> <Reference Include="System.Drawing" /> - <Reference Include="System.IO.Compression" /> + <Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath> + </Reference> <Reference Include="System.IO.Compression.FileSystem" /> + <Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath> + </Reference> + <Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath> + </Reference> <Reference Include="System.Management" /> + <Reference Include="System.Numerics" /> <Reference Include="System.Reactive.Core, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> <HintPath>..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll</HintPath> </Reference> @@ -100,6 +137,30 @@ <Reference Include="System.Reactive.Windows.Threading, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> <HintPath>..\..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll</HintPath> </Reference> + <Reference Include="System.Reflection.Metadata, Version=1.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll</HintPath> + </Reference> + <Reference Include="System.Security.Cryptography.Algorithms, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath> + </Reference> + <Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath> + </Reference> + <Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath> + </Reference> + <Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath> + </Reference> + <Reference Include="System.Text.Encoding.CodePages, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll</HintPath> + </Reference> + <Reference Include="System.Threading.Thread, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll</HintPath> + </Reference> + <Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath> + </Reference> <Reference Include="System.Windows" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> @@ -114,6 +175,18 @@ <Reference Include="System.Xaml"> <RequiredTargetFramework>4.0</RequiredTargetFramework> </Reference> + <Reference Include="System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath> + </Reference> + <Reference Include="System.Xml.XmlDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll</HintPath> + </Reference> + <Reference Include="System.Xml.XPath, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll</HintPath> + </Reference> + <Reference Include="System.Xml.XPath.XDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll</HintPath> + </Reference> <Reference Include="WindowsBase" /> <Reference Include="PresentationCore" /> <Reference Include="PresentationFramework" /> @@ -535,15 +608,11 @@ <ItemGroup> <Resource Include="Images\logout.png" /> </ItemGroup> - <ItemGroup /> + <ItemGroup> + <Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" /> + <Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <Import Project="..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets" Condition="Exists('..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" /> - <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> - <PropertyGroup> - <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> - </PropertyGroup> - <Error Condition="!Exists('..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets'))" /> - </Target> <PropertyGroup> <PostBuildEvent>RD /S /Q "$(TargetDir)cs\" RD /S /Q "$(TargetDir)da\" @@ -602,4 +671,11 @@ if $(ConfigurationName) == Release del *.xml if $(ConfigurationName) == Release RD /S /Q "$(TargetDir)ProtoCompilers\" if $(ConfigurationName) == Release RD /S /Q "$(TargetDir)Roslyn\"</PostBuildEvent> </PropertyGroup> + <Import Project="..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets" Condition="Exists('..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> + </PropertyGroup> + <Error Condition="!Exists('..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets'))" /> + </Target> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/packages.config b/Software/Visual_Studio/FSE/Tango.FSE.UI/packages.config index 54a423b24..9bec9f247 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/packages.config +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/packages.config @@ -9,13 +9,61 @@ <package id="MahApps.Metro" version="1.6.5" targetFramework="net461" /> <package id="MaterialDesignColors" version="1.2.2" targetFramework="net461" /> <package id="MaterialDesignThemes" version="3.0.1" targetFramework="net461" /> + <package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net461" /> + <package id="Microsoft.CodeAnalysis.Common" version="2.4.0" targetFramework="net461" /> + <package id="Microsoft.CodeAnalysis.CSharp" version="2.4.0" targetFramework="net461" /> + <package id="Microsoft.CodeAnalysis.CSharp.Scripting" version="2.4.0" targetFramework="net461" /> + <package id="Microsoft.CodeAnalysis.Scripting" version="2.4.0" targetFramework="net461" /> + <package id="Microsoft.CodeAnalysis.Scripting.Common" version="2.4.0" targetFramework="net461" /> <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" /> + <package id="System.AppContext" version="4.3.0" targetFramework="net461" /> + <package id="System.Collections" version="4.3.0" targetFramework="net461" /> + <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" /> + <package id="System.Collections.Immutable" version="1.3.1" targetFramework="net461" /> + <package id="System.Console" version="4.3.0" targetFramework="net461" /> + <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" /> + <package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net461" /> + <package id="System.Diagnostics.StackTrace" version="4.3.0" targetFramework="net461" /> + <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net461" /> + <package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net461" /> + <package id="System.Globalization" version="4.3.0" targetFramework="net461" /> + <package id="System.IO" version="4.3.0" targetFramework="net461" /> + <package id="System.IO.Compression" version="4.3.0" targetFramework="net461" /> + <package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" /> + <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" /> + <package id="System.Linq" version="4.3.0" targetFramework="net461" /> + <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" /> <package id="System.Reactive" version="3.1.1" targetFramework="net461" /> <package id="System.Reactive.Core" version="3.1.1" targetFramework="net461" /> <package id="System.Reactive.Interfaces" version="3.1.1" targetFramework="net461" /> <package id="System.Reactive.Linq" version="3.1.1" targetFramework="net461" /> <package id="System.Reactive.PlatformServices" version="3.1.1" targetFramework="net461" /> <package id="System.Reactive.Windows.Threading" version="3.1.1" targetFramework="net461" /> + <package id="System.Reflection" version="4.3.0" targetFramework="net461" /> + <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net461" /> + <package id="System.Reflection.Metadata" version="1.4.2" targetFramework="net461" /> + <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" /> + <package id="System.Runtime" version="4.3.0" targetFramework="net461" /> + <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" /> + <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" /> + <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net461" /> + <package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" /> + <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" /> + <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" /> + <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" /> + <package id="System.Text.Encoding" version="4.3.0" targetFramework="net461" /> + <package id="System.Text.Encoding.CodePages" version="4.3.0" targetFramework="net461" /> + <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net461" /> + <package id="System.Threading" version="4.3.0" targetFramework="net461" /> + <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net461" /> + <package id="System.Threading.Tasks.Parallel" version="4.3.0" targetFramework="net461" /> + <package id="System.Threading.Thread" version="4.3.0" targetFramework="net461" /> + <package id="System.ValueTuple" version="4.3.0" targetFramework="net461" /> + <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net461" /> + <package id="System.Xml.XDocument" version="4.3.0" targetFramework="net461" /> + <package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="net461" /> + <package id="System.Xml.XPath" version="4.3.0" targetFramework="net461" /> + <package id="System.Xml.XPath.XDocument" version="4.3.0" targetFramework="net461" /> <package id="WindowsAPICodePack-Core" version="1.1.1" targetFramework="net461" /> <package id="WindowsAPICodePack-Shell" version="1.1.1" targetFramework="net461" /> </packages>
\ No newline at end of file diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/IContext.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/IContext.cs index 906047c2a..d817c5d46 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/IContext.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/IContext.cs @@ -8,6 +8,6 @@ namespace Tango.Scripting.Basic { public interface IContext { - void WriteLine(String s); + } } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs index ff7a3acc2..31be3a714 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs @@ -78,7 +78,7 @@ namespace Tango.Scripting.Basic } } - public static Project New(String name, String code) + public static Project New(String name) { Project p = new Project(); @@ -88,14 +88,6 @@ namespace Tango.Scripting.Basic p.ReferenceAssemblies.Add(new ReferenceAssembly() { FromType = typeof(Enumerable) }); p.ReferenceAssemblies.Add(new ReferenceAssembly() { FromType = typeof(Form) }); p.ReferenceAssemblies.Add(new ReferenceAssembly() { FromType = typeof(Project) }); - - p.Scripts.Add(new Script() - { - Name = name, - IsEntryPoint = true, - Code = code, - }); - return p; } @@ -111,6 +103,7 @@ namespace Tango.Scripting.Basic foreach (var script in Scripts) { + script.LoadCount = 0; String code = script.Code; String codeFile = Path.Combine(tempFolder, script.Name); @@ -119,14 +112,14 @@ namespace Tango.Scripting.Basic foreach (var file in Scripts.Where(x => !x.IsEntryPoint && script != x).Select(x => Path.Combine(tempFolder, x.Name))) { loadingString = $"#load \"{file}\"\n"; + script.LoadCount++; } code = loadingString + code; if (!script.IsEntryPoint) { - - + //In case we use #load //foreach (var match in Regex.Matches(code, "#load \".+\"").OfType<Match>()) //{ // String line = match.ToString(); @@ -143,9 +136,6 @@ namespace Tango.Scripting.Basic // } // } //} - - - File.WriteAllText(codeFile, code); } else @@ -162,14 +152,19 @@ namespace Tango.Scripting.Basic var compileResults = s.Compile(); - foreach (var error in compileResults.Where(x => x.Severity == Microsoft.CodeAnalysis.DiagnosticSeverity.Error || x.Severity == Microsoft.CodeAnalysis.DiagnosticSeverity.Warning)) + foreach (var error in compileResults.Where(x => x.Severity == Microsoft.CodeAnalysis.DiagnosticSeverity.Error)) { CompilationError cError = new CompilationError(); cError.File = System.IO.Path.GetFileName(error.Location.SourceTree.FilePath); + if (cError.File == String.Empty) + { + cError.File = Scripts.Single(x => x.IsEntryPoint).Name; + } + Script errorScript = Scripts.Single(x => x.Name == cError.File); cError.Message = error.GetMessage(); cError.Severity = error.Severity; var line = error.Location.GetMappedLineSpan(); - cError.Line = line.StartLinePosition.Line + 1; + cError.Line = line.StartLinePosition.Line + 1 + (errorScript != null ? errorScript.LoadCount : 0); cError.Column = line.StartLinePosition.Character + 1; cError.Length = line.EndLinePosition.Character - line.StartLinePosition.Character; result.Errors.Add(cError); @@ -185,7 +180,7 @@ namespace Tango.Scripting.Basic if (result.Errors.Count > 0) { - throw new InvalidOperationException("There were compilation errors."); + throw new InvalidOperationException($"Cannot run project with the following compilation errors:\n{String.Join(Environment.NewLine, result.Errors.Select(x => x.Message))}"); } Thread scriptThread = null; diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Script.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Script.cs index fce05636d..753026149 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Script.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Script.cs @@ -24,6 +24,8 @@ namespace Tango.Scripting.Basic set { _isSelected = value; RaisePropertyChangedAuto(); } } + [JsonIgnore] + public int LoadCount { get; internal set; } public static Script New(String file) { @@ -34,12 +36,13 @@ namespace Tango.Scripting.Basic }; } - public static Script New(String name, String code) + public static Script New(String name, String code, bool isEntryPoint = false) { return new Script() { Name = name, Code = code, + IsEntryPoint = isEntryPoint, }; } } |
