4

I'd like to give user the opportunity to do its own report based on my class hierarchy (object in memory). A scripting language like VBA: Visual Basic for Application. Something that would be evaluated at runtime.

I'd like the user to be able to dynamically create its own report based on some available restricted objects marked with specific attributes only. Give user possibility to create macro where he have similar model as in VBA-Excel : Application/Workbook/WorkSheet/Range/... but with my specific selected objects instead.

Then, he would have been able to use intellisense and add its own functionality to its application.

Update: There is something very important that appears to me. The editor should be preferably part of the application itself in order for the script to know all the environment (namespace, objects, ...) it should interact with. Otherwise, having a scripting engine/editor in a separate process would force the application to be either a "single-instance" app or to create a tricky way to hook the script to a specific running application process.

Does it exists and how to plug it to a .net app?

4 solutions have been proposed:

  1. IronRuby
  2. CsScript
  3. WinWrap
  4. Windows Scripting Host (WSH)

I also found:

  1. ScriptCs
  2. RoslynPad
  3. Code Project - Anoop Madhusudanan article: C# as a Scripting Language in Your .NET Applications Using Roslyn

But I wonder which one could fits every needs (or most of them):

  1. Editor with Intellisense
  2. User have access the currently running process object model (Application as global and all its related objects accessed through application properties). Optional but very nice to have: not necessarily every public properties, only marked ones with specific attributes.
  3. Interactive environment enabling step by step, debugging, breakpoints, ...
  4. Editor/debugger Licensed for free redistribution
  5. Not required, but preferably use C# language

Actual testing:

  • I tried to evaluate #2 but there is no VS project sample with all modules working together (which seems a little bit complex to assemble).
  • I currently evaluate #6 which seems to work fine (I corrected a minor bug). It seems to fits most points but #3. But it seems to be the closest to my needs yet. It also uses Roslyn which appears to me a positive aspect because it is the Microsoft compiler which should always be up to date.

I'm still waiting to see any feedback from anybody with either other better solutions or any advise to help me take a better decision.

Eric Ouellet
  • 10,996
  • 11
  • 84
  • 119
  • Do you want VBA in particular? – Maz Oct 16 '14 at 14:32
  • @Maz, no, not necessarily, anything equivalent would be good. – Eric Ouellet Oct 16 '14 at 14:33
  • I would look at embedding ironpython. There are many tutorials on that subject, and it should do what you want – Maz Oct 16 '14 at 14:37
  • @Maz, it sounds great, I just found http://www.csscript.net/index.html also. Could you turn your comment to an answer? I'm still not sure if CS-Script is not preferable because it would look like more C#, I'm looking for advise... :-) – Eric Ouellet Oct 16 '14 at 14:42
  • you can also take a look at http://www.winwrap.com – Sorceri Oct 16 '14 at 15:17
  • 1
    Windows Scripting Host would allow you to use VBScript/JScript with directly exported object instances with fixed names into a script file at runtime in C# (its trivial to do this using ComVisible() to show hide members). There is no integrated IDE but I mention it as VBScript is really simple for novices to play with. – Alex K. Oct 16 '14 at 15:54
  • @Alex K, thanks a lot. I already did a lots of VBA. I also did some .vbs where I think it is executed but the WSH engine. If I'm right, there is no intellisense, no syntax hilight, and could be hard to add additional functionality (which could be good for security reasons) but is less flexible. – Eric Ouellet Oct 17 '14 at 12:51
  • Yes, you would need an external editor like NPP which comes with script highlighting and allows custom auto-completes – Alex K. Oct 17 '14 at 12:54
  • @Alex K. I just added a new comment (in bold). I just realized that a separate process would make things more complex or to make it simple, there should be a way for the editor to know the application it is hooked which is far than being standard. – Eric Ouellet Oct 17 '14 at 13:30

1 Answers1

0

After some thought, trials and errors. My needs become clearer and my understanding of to current state about Roslyn development was also better.

I realized that Oleg Shilo (Author of CS-Script) was right about the fact that Roslyn is not ready (2014-10-21) to help me for intellisense. But I think it should happen relatively soon. I think it should worth the wait. But it can compile and run code into the same running app I would like to run tested in.

Although any other approach could have probably work better right now. I think that a solution like RoslynPad would be closer to the ideal solution for my needs. Most other proposed solution where nice for general scripting but not as good as RoslynPad for inside app own scripting... at least according to my opinion.

I then fixed some little issues in RoslynPad and hook it to the newest AvalonEdit which also fixes some other issues with auto-completion (but still with few bugs).

I now get needs filled up as this:

  • #1 Partial (ready for full when Roslyn will supported and documented it)
  • #2 Full
  • #3 No (ready for full when Roslyn will supported and documented it)
  • #4 Full
  • #5 Full

Thanks a lots to all people giving me ideas, links and very nice advise.

Eric Ouellet
  • 10,996
  • 11
  • 84
  • 119