From 9b7875d904456c34c3698d7fc569078f99ed5187 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 19 Apr 2020 23:12:56 +0300 Subject: Scripting refactoring. --- .../Scripting/Tango.Scripting/Parsing/ScriptParser.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting/Parsing/ScriptParser.cs') diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting/Parsing/ScriptParser.cs b/Software/Visual_Studio/Scripting/Tango.Scripting/Parsing/ScriptParser.cs index 15760c950..7accdbb83 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting/Parsing/ScriptParser.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting/Parsing/ScriptParser.cs @@ -258,7 +258,21 @@ namespace Tango.Scripting.Parsing { SyntaxTree tree = CSharpSyntaxTree.ParseText(code); CompilationUnitSyntax root = tree.GetCompilationUnitRoot(); - return root.DescendantNodes().OfType().FirstOrDefault(); + var creationSyntax = root.DescendantNodes().OfType().FirstOrDefault(); + return creationSyntax; + } + + public MethodDeclarationSyntax GetCurrentConstructionExpressionAlt(String code) + { + if (code.Contains("=") && code.Contains("new")) + { + SyntaxTree tree = CSharpSyntaxTree.ParseText(code); + CompilationUnitSyntax root = tree.GetCompilationUnitRoot(); + var creationSyntax = root.DescendantNodes().OfType().FirstOrDefault(); + return creationSyntax; + } + + return null; } public T GetExpressionFirst(String line) where T : CSharpSyntaxNode -- cgit v1.3.1 From 405f1ac07d78468c3e1a0ef1c0dc8956635c8677 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 22 Apr 2020 07:01:05 +0300 Subject: FSE work + fixed issue with personal access token on MS and PPC. --- .../Dialogs/AddReferenceAssemblyView.xaml | 36 ++++++++ .../Dialogs/AddReferenceAssemblyView.xaml.cs | 28 ++++++ .../Dialogs/AddReferenceAssemblyViewVM.cs | 63 +++++++++++++ .../FSE/Modules/Tango.FSE.Stubs/ITestContext.cs | 2 + .../FSE/Modules/Tango.FSE.Stubs/ProjectRunner.cs | 4 + .../Tango.FSE.Stubs/Resources/main_template.csx | 2 + .../Modules/Tango.FSE.Stubs/Tango.FSE.Stubs.csproj | 8 ++ .../FSE/Modules/Tango.FSE.Stubs/TestContext.cs | 13 ++- .../ViewModels/TestDesignerViewVM.cs | 98 ++++++++++++++++++--- .../Tango.FSE.Stubs/Views/TestDesignerView.xaml | 59 ++++++++++++- .../FSE/Tango.FSE.UI/Dialogs/BugReportView.xaml | 4 +- .../TFS/TeamFoundationServiceExtendedClient.cs | 18 ++-- .../Tango.MachineStudio.UI/ViewModelLocator.cs | 2 +- .../TFS/TeamFoundationServicePPCClient.cs | 18 ++-- .../Tango.PPC.BugReporting/ViewModelLocator.cs | 2 +- .../Scripting/Tango.Scripting.Basic/Project.cs | 12 +-- .../Tango.Scripting.Basic/ReferenceAssembly.cs | 22 ++++- .../Tango.Scripting/Parsing/ScriptParser.cs | 91 +++++++++++++++++-- .../Tango.Core/Helpers/AssemblyHelper.cs | 9 ++ .../Tango.Stubs/Images/PinClose_Black.png | Bin 0 -> 1230 bytes .../Visual_Studio/Tango.Stubs/Images/pubclass.gif | Bin 0 -> 290 bytes .../Visual_Studio/Tango.Stubs/Images/pubevent.gif | Bin 0 -> 365 bytes .../Visual_Studio/Tango.Stubs/Images/pubmethod.gif | Bin 0 -> 599 bytes .../Tango.Stubs/Images/pubproperty.gif | Bin 0 -> 435 bytes .../Visual_Studio/Tango.Stubs/Tango.Stubs.csproj | 17 +++- .../Controllers/FSEController.cs | 4 +- .../Tango.MachineService/MachineServiceConfig.cs | 4 +- .../Web/Tango.MachineService/Web.config | 4 +- 28 files changed, 459 insertions(+), 61 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyViewVM.cs create mode 100644 Software/Visual_Studio/Tango.Stubs/Images/PinClose_Black.png create mode 100644 Software/Visual_Studio/Tango.Stubs/Images/pubclass.gif create mode 100644 Software/Visual_Studio/Tango.Stubs/Images/pubevent.gif create mode 100644 Software/Visual_Studio/Tango.Stubs/Images/pubmethod.gif create mode 100644 Software/Visual_Studio/Tango.Stubs/Images/pubproperty.gif (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting/Parsing/ScriptParser.cs') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyView.xaml new file mode 100644 index 000000000..7ae84ff9e --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyView.xaml @@ -0,0 +1,36 @@ + + + + + + Reference Assemblies + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyView.xaml.cs new file mode 100644 index 000000000..5bfd20b5f --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.Stubs.Dialogs +{ + /// + /// Interaction logic for AddReferenceAssemblyView.xaml + /// + public partial class AddReferenceAssemblyView : UserControl + { + public AddReferenceAssemblyView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyViewVM.cs new file mode 100644 index 000000000..0f79da8d6 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/Dialogs/AddReferenceAssemblyViewVM.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.Core.Helpers; +using Tango.FSE.Common; +using Tango.FSE.Common.FSEApplication; +using Tango.Scripting.Basic; +using Tango.SharedUI.Components; + +namespace Tango.FSE.Stubs.Dialogs +{ + public class AddReferenceAssemblyViewVM : FSEDialogViewVM + { + [TangoInject] + private IFSEApplicationManager ApplicationManager { get; set; } + + public SelectedObjectCollection ReferenceAssemblies { get; set; } + + public AddReferenceAssemblyViewVM(List existing) + { + OKText = "ADD"; + + TangoIOC.Default.Inject(this); + + List source = new List(); + + var startPath = ApplicationManager.StartPath; + + foreach (var file in Directory.GetFiles(startPath, "*.dll")) + { + source.Add(ReferenceAssembly.FromFile(Path.GetFileName(file))); + } + + String dotNetVersion = AssemblyHelper.GetTargetFrameworkVersion(Assembly.GetExecutingAssembly()).ToString(); + String dotNetPath = $@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v{dotNetVersion}"; + + foreach (var file in Directory.GetFiles(dotNetPath, "*.dll")) + { + source.Add(ReferenceAssembly.FromFile(Path.GetFileName(file))); + } + + source = source.DistinctBy(x => x.Name).ToList(); + + List existingReferences = new List(); + + foreach (var asm in source) + { + if (existing.Exists(x => x.Name == asm.Name)) + { + existingReferences.Add(asm); + } + } + + ReferenceAssemblies = new SelectedObjectCollection(source.ToObservableCollection(), existingReferences.ToObservableCollection()); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ITestContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ITestContext.cs index 41b13f2d2..9b8eb6f06 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ITestContext.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ITestContext.cs @@ -18,7 +18,9 @@ namespace Tango.FSE.Stubs void RemoveResult(Result result); void ClearResults(); IMessage Run(String stubName, params Object[] args); + T Run(String stubName, params Object[] args) where T : class, IMessage; IMessage Run(IMessage stub); + T Run(IMessage stub) where T : class, IMessage; void RunContinuous(T stub, Action callback) where T : class, IMessage; void RunContinuous(String stubName, Action callback, params Object[] args) where T : class, IMessage; void WriteLine(Object obj); 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 de93305d8..3e3bddece 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProjectRunner.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/ProjectRunner.cs @@ -12,6 +12,8 @@ namespace Tango.FSE.Stubs { private ProjectSession _currentSession; + public event EventHandler StateChanged; + private ProjectRunnerState _state; public ProjectRunnerState State { @@ -24,6 +26,8 @@ namespace Tango.FSE.Stubs RaisePropertyChanged(nameof(IsCompiling)); RaisePropertyChanged(nameof(CanRun)); RaisePropertyChanged(nameof(CanCompile)); + + StateChanged?.Invoke(this, value); } } 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 c50f70c5f..56f1974ff 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 @@ -5,6 +5,8 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using Google.Protobuf; +using Tango.PMR.Stubs; using Tango.FSE.Stubs; public class Program 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 faf3615be..54d6f3507 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 @@ -97,6 +97,10 @@ + + AddReferenceAssemblyView.xaml + + @@ -211,6 +215,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/TestContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/TestContext.cs index 83823a27c..909b026d6 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/TestContext.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Stubs/TestContext.cs @@ -23,7 +23,7 @@ namespace Tango.FSE.Stubs private ITestLogger _logger; [TangoInject] - private IMachineProvider MachineProvider; + private IMachineProvider MachineProvider { get; set; } [TangoInject] private INotificationProvider NotificationProvider { get; set; } @@ -37,6 +37,7 @@ namespace Tango.FSE.Stubs { _logger = logger; Results = new ReadOnlyCollection(new List()); + TangoIOC.Default.Inject(this); } public IMessage Run(string stubName, params object[] args) @@ -83,11 +84,21 @@ namespace Tango.FSE.Stubs return Run(request as IMessage); } + public T Run(string stubName, params object[] args) where T : class, IMessage + { + return Run(stubName, args) as T; + } + public IMessage Run(IMessage stub) { return MachineProvider.MachineOperator.SendRequest(stub, new Transport.TransportRequestConfig()).Result; } + public T Run(IMessage stub) where T : class, IMessage + { + return Run(stub) as T; + } + public void RunContinuous(T stub, Action callback) where T : class, IMessage { Type stubType = stub.GetType(); 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 d87fe0ff3..a63469f14 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 @@ -10,6 +10,7 @@ using Tango.Core; using Tango.Core.Commands; using Tango.Core.ExtensionMethods; using Tango.FSE.Common; +using Tango.FSE.Stubs.Dialogs; using Tango.Integration.Operation; using Tango.Scripting.Basic; using Tango.Scripting.Editors; @@ -28,6 +29,8 @@ namespace Tango.FSE.Stubs.ViewModels Results } + #region Properties + private ToolWindows _selectedToolWindow; public ToolWindows SelectedToolWindow { @@ -56,6 +59,13 @@ namespace Tango.FSE.Stubs.ViewModels set { _compilationErrors = value; RaisePropertyChangedAuto(); } } + private List _results; + public List Results + { + get { return _results; } + set { _results = value; RaisePropertyChangedAuto(); } + } + public ObservableCollection