I am looking to replace an old control being used for scripting an application. The control used to be called SAX Basic, but is now called WinWrap. It provides us with two primary functions.
It's a scripting engine (VB)
It has a GUI for developing and debugging scripts that get run in the hosting application.
The first feature it provides is actually pretty easy to replace. There are so many great methods of running just about any kind of code at runtime that it's almost a non-issue. Just about any language targeting the .NET runtime will work for us. We've looked at running C#, PowerShell, VB.NET, IronPython, etc. I've also taken a brief look at Lua and F#, but honestly the language isn't the biggest barrier here.
Now, for the hard part that seems to keep getting me stuck. We want a code editor, and debugger. Something simple, not unlike PowerShell's ISE would be fine. Just as long as a file could be created, saved, debugged and executed.
I'm currently looking into Visual Studio 2010 Shell (Isolated) and I'm also looking at the feasibility of embedding PowerShell ISE in my application. Are there any other editors I could embed/use in my application? Purchasing a product is not out of the question. It comes down to a combination of ease of use, how well it meets our needs, and how simple deployment and licensing is for developers.
While I have not used this solution myself, I would recommend that you look into SharpDevelop (OSS .NET IDE) - it has text editor controls that have been embedded in other applications, for instance Kaxaml.
Related
I'd like some help in how to add scripting support to a WPF C# project I'm doing on Visual Studio 2015. One of the things I'd like to do is to be able to change User Control properties within that script. I've being trying Roslyn C#, and I read some stuff about IronPython and PowerShell Tools. But, all that information is not really helping.
So, do you have a simple answer? Like, the easiest way to execute scripts in Visual Studio 2015 C# WPF Application, that are able to change properties of User Controls within the project?
Any help would be appreciated.
Thanks,
Lucas.
T4 templates can help but they are less extensible than lets say Roslyn.
I found a great post on how to easily implement IronPython and how to access User Controls within the scripts in Python, so you can there change different Control properties, and even create them! Here's the link:http://www.codeproject.com/Articles/602112/Scripting-NET-Applications-with-IronPython
I think it should be quite simple to embed powershell or F# interactive in an application and there are lots of examples when we search the web for this. The question is only are we comfortable writing scripts in Powershell and F#?
In my application I provide a C# editor and compile scripts as static methods (which I uses as functions) using the standard .Net compiler API's which are installed with the framework (Microsoft.Csharp, System.CodeDom). This generates a temporary dll and perhaps can not be properly termed a script. The implementation is straight forward and more or less what you expect - I have to provide a way for the users to specify references and namespaces, then generate a source file, compile it to an assembly and then call members of the static class. This above technique works well because the application has extension points that are well adapted to user defined code with a certain well defined structure (you might have similar well defined needs and perhaps full scripting is not necessary).
On the other hand, I am considering providing a "super user" console where the application can be driven by script, and in this case, I will use either Powershell or F-sharp interactive (I'm leaning towards F#). I don't think the implementation is particularly complex, but these are things that can easily bring the application down or corrupt application data if it is not well controlled - and it is unlikely that my users will profit from scripting as it is a programmer environment.
We've got a quite complex deployment scenario and want to make use of continuous deployment. Currently we've got a huge MSBuild script for everything, however, MSBuild is ok for building but not really suitable for deploying.
We'd love it if there would be some kind of C# project where we could write the deploy code directly with C#. Is there some C# scripting language which is suitable especially for deploying applications?
While it's not a C# project, you can use my company's product BuildMaster to handle deployments. It's designed to solve some of the problems you're already having, and some you probably don't realize you have (configuration file deployments, database schema updates, process automation, approvals, etc.)
However, if all you want is to write C# scripts for deployment, there's a tool called con-dep which looks like what you're describing.
Well, with Roslyn now I suppose that you can technically now use C# as a scripting language. I don't know if it would be terrible appropriate to do so...
Depending on your deployment solutions you might want to look into the NAntBuilder IDE. We used this for continuous ddeployment together with SVN server. If you have TFS why don't you just look into the details and many possibilities of Build Process templates?
You can use the .NET integrated C# compiler.
The advantage is that you can use the same DLLs/APIs in a C# 'script' as you do in your own software.
I use it in our production software. Our production engineers are able to write some small programs for special stuff.
See this answer for details.
You may want to look into using a tool that's specifically designed for handling deployments. If you're using Team Foundation Server, Team Build + InRelease provides a well-supported, well-documented way to handle your builds and deployments. Now that Microsoft owns InRelease, it'll be part of Team Foundation Server pretty soon.
If not, you can always write PowerShell scripts to handle your deployments. PowerShell isn't C#, but it's built on top of the .NET framework (so all the framework methods you're familiar with are still available), and the learning curve isn't very steep.
So in Python on a unix environment, for example, we can open up python from terminal, start writing code and immediately run it to test some python library functions. Is there a similar commandline/scripting environment for C# or Java (perhaps a plugin to the IDE?)? Such a tool would seem pretty useful for experimenting with something like the System library.
Relatedly, I read that some versions of Python are compiled into bytecode before being executed by a virtual environment, which sounds like Java and C#. But, the Python program I open up in terminal and start typing code into has to be interpreted, right? So based on principle, it seems like it is possible to write a C# or Java interpreter. So I'm not sure why I just haven't seen anyone interacting with C# or Java on the commandline the way they do with Python.
Thanks.
For .NET there is LINQPad. It supports C#, VB.NET and F#.
The name suggests that it is only for LINQ but you can execute any code in there. There is no need for a database.
For .NET, if LINQPad is overkill for you, try the RunNET command-line package. It requires that you load script files instead of interactive typing, but lets you leverage more languages.
The ability to explore .NET types was one of the reasons I originally started learning F#, since it has an Interactive environment (in Visual Studio, click on View > Other Windows > F# Interactive.) Upon digging deeper into F# I have found it to be one of my favorite programming languages.
Anyways, you may want to look at it. It won't take long to figure out the basic syntax, and once you've got it you can explore various .NET objects in the Interactive Environment, if you don't want to wait for Roslyn.
For a tutorial, check out this page: http://www.tryfsharp.org/Tutorials.aspx
I am working on designing a GUI for a software that will be written in C++ or C#. My partner and I would like to test out the GUI in the browser first and then import to C++ or C#.
Does a C++ or C# library exist for converting CSS/HTML/jQuery code to C++ or C# code?
No, the paradigms for developing for web applications and desktop applications are completely incompatible.
If you don't have experience developing UI for a desktop application, the prototyping phase is a great time to get that experience.
I always find it easiest to create prototypes in Visual Studio, and I also rely on Kaxaml for testing small blocks of xaml.
If you're interested targeting WPF/C#, here is a tool that converts between HTML/CSS and XAML. It doesn't support ever possible tag or markup scenario, but for basic HTML/CSS it does seem to work.
Personally, I would avoid this as a prototyping approach, and would go straight to using WPF or Silverlight with a tool like Expression Blend (or even Visual Studio). With the prototyping features already available in these tools, there's really no reason to mock up such UIs in a browser with HTML. I also wouldn't trust that such a conversion would ever preserve all of the behavior quirks and nuances that you would desire.
Prototyping is also the point where you are beginning to establish assumption about the range of UI interactions you intend to support .. why complicate that by using the wrong tool? If your goal is to quickly communicate a possible UI layout to a customer, I suggest you use Visio or a paper mockup as premature interactivity could actually get in the way of a meaningful discussion of user experience. You don't want such discussions to get bogged down in fonts, colors, and pixels.
I was learning python using the tutorial that comes with the standard python installation. One of the benefits that the author states about python is "maybe you’ve written a program that could use an extension language, and you don’t want to design and implement a whole new language for your application" - My question is how would i go about designing a program (using c#) that can be extended using Python interactively(for this to be possible, i would imagine that i would need to create some sort of a "shell" or "interactive" mode for the .net program) ?
Are there any pointers on how to design .NET programs that have an interactive shell. I would then like to use python script in the shell to "extend" or interact with the program.
EDIT: This question partly stems from the demo give by Miguel de Icaza during PDC 2008 where he showed the interactive csharp command prompt, C# 4.0 i think also has this "compiler as a service" feature. I looked at that and thought how cool would it be to design a windows or web program in .NET that had a interactive shell.. and a scripting language like python could be used to extend the features provided by the program.
Also, i started thinking about this kind of functionality after reading one of Steve Yegge's essays where he talks about systems that live forever.
This sounds like a great use of IronPython.
It's fairly easy to set up a simple scripting host from C# to allow calls into IronPython scripts, as well as allowing IronPython to call into your C# code. There are samples and examples on the CodePlex site that show how to do this very thing.
Another good site for examples and samples is ironpython.info
And here is a page dedicated to an example answering your very question, albeit in a generic DLR-centric way -- this would allow you to host IronPython, IronRuby, or whatever DLR languages you want to support.
I've used these examples in the past to create an IronPython environment inside a private installation of ScrewTurn Wiki - it allowed me to create very expressive Wiki templates and proved to be very useful in general.
I was looking solution for the same problem, and found IronTextBox: http://www.codeproject.com/KB/edit/irontextbox2.aspx
It needs a little tuning for current versions, but seems to be everything I needed. First made it compile, and then added variables I wanted to access from shell to the scope.
Python as an extension language is called "Embedding Python".
you can call a python module from c++ by bascially calling the python intepreter and have it execute the python source. This is called embedding.
It works from C and C++, and will probably work just as well from C#.
And no, you do not need any kind of "shell". While Python can be interactive, that's not a requirement at all.
Here is a link to a blog post about adding IronRuby to script a C# application.
http://blog.jimmy.schementi.com/2008/11/adding-scripting-to-c-silverlight-app.html
The principles would also work well for using IronPython.
If your goal is to avoid learning a new language you can use CSScript.Net and embedded scripts written in C# or VB into you application. With CSScript you get full access to the CLR. Three different models of script execution are supported so that you can execute script that refers to objects in your current app domain, execute using remoting, or execute as a shell.
Currently I am using CCScript as "glue" code for configuring application objects somewhat similar to using Boo.
This link tasks you to a code project article that provides a good overview.
I don't know what you mean with
"extend" or interact with the program
so I can't answer your question. Can you give an example?
There is an open source interactive C# shell in mono: http://www.mono-project.com/CsharpRepl
When you like python, .Net and language extension, you will probably like Boo over Iron python. Boo comes with an open source interactive shell too.
I disagree with
"you don’t want to design and
implement a whole new language for
your application"
It's not as hard as it used to be to create a simple DSL. It won't take you days to implement, just hours. It might be an interesting option.