A Newbie Question : Interactive development with Visual Studio

瀏覽次數:50 次
跳到第一則未讀訊息

Chris Kim

未讀,
2014年9月1日 清晨6:24:412014/9/1
收件者:o2-pl...@owasp.org
Hi, I just learned about O2 platform and I'm very excited about thinking that I could possibly do C# interactive development within Visual Studio.
This is something I've been dreaming about for a long time (I have background in CommonLisp where interactive development is the norm)

I downloaded the VS plugin but there are very little documentation to figure out how to use.
My questions are below.

1. Can I intereactively develop the current solution file I loaded into Visual Studio from C# Repl?
2. If so, changing source code without stopping the running instance will dynamically compile?
3. WPF is my choice of desktop UI. Are there some support for WPF? (It seems like WinForm is the default)
4. Is it possible to show us some examples?
5. If above answers to above questions are no, is it on the roadmap for the near future?

Thank you very much.

-chris

Dinis Cruz

未讀,
2014年9月1日 下午1:27:492014/9/1
收件者:O2 Platform
Hi Chris, I'm glad you found the O2 Platform, specially since it looks like it already have the main features you are looking for :)

The key concept used across the main O2 Platform (and FluentSharp) APIs is the REPL (Read Eval Print Loop), which should be very common to you (btw you can run .Net's version of Lisp via this O2 script : Util - Clojure-clr REPL (Lisp).h2 )

Assuming you are running VS2010 and have installed this VS Extension (VisualStudio C# REPL - O2 Platform (v5.1)), see my comments below

On 1 September 2014 11:24, Chris Kim <chri...@gmail.com> wrote:
Hi, I just learned about O2 platform and I'm very excited about thinking that I could possibly do C# interactive development within Visual Studio.
This is something I've been dreaming about for a long time (I have background in CommonLisp where interactive development is the norm)

I downloaded the VS plugin but there are very little documentation to figure out how to use.

For this type of O2 functionality your best best for O2 Documentation is my blog http://blog.diniscruz.com/search/label/O2%20Platform (221 post) and the http://o2platform.wordpress.com/ blog (100+ posts)
 
My questions are below.

1. Can I intereactively develop the current solution file I loaded into Visual Studio from C# Repl?


2. If so, changing source code without stopping the running instance will dynamically compile?

You can achieve this kind of 'dynamic code compilation without stopping the running instance' using the O2 REPL kind of development (which is the one I used to create all the O2 tools and APIs you see in there.

But if you are using VisualStudio to compile and run your app, you will find that you can't touch the dlls (since they are locked by VS). The key to achieve what (I think) you want to do, is to find a way to run your 'code/WPF-Control' in isolation (a bit like what I did here Real-time Programming C# WinForms Controls in VisualStudio's IDE (i.e. without using F5) ). Btw, if you haven't checkout NCrunch, you should since it makes a massive difference in TDD development (see my posts on it here http://blog.diniscruz.com/search/label/NCrunch
 
3. WPF is my choice of desktop UI. Are there some support for WPF? (It seems like WinForm is the default)

There is quite already a lot of WPF support in O2's Apis. For example see http://blog.diniscruz.com/2013/04/winforms-webbrowser-running-inside-wpf.html


WPF support is not as mature as WinForms, but you should be able to find a lot of good stuff in there. 

Can you give me an example of what you would like to do?
 
4. Is it possible to show us some examples?

The links above should give you quite a lot of code samples, but the best way is, if you give me a more specific example of what you are trying to, I can write a blog post about with it :)


The code for the VS 2010 extension is at https://github.com/o2platform/FluentSharp.VisualStudio

The key part of the extension (and the bit that allows the real time programming of the VS UI) is the capture of these native VS objects/events: https://github.com/o2platform/FluentSharp.VisualStudio/blob/master/FluentSharp.VisualStudio_2010/VisualStudio_2010.cs#L17 (which you have real-time programmatically access from the O2 REPL running inside VS)
 
5. If above answers to above questions are no, is it on the roadmap for the near future?

Well here are the areas where we need help at the moment https://github.com/o2platform/FluentSharp/issues , namely this one for running that Extension in VS 2013: https://github.com/o2platform/FluentSharp.VisualStudio/issues 

Btw which version of O2 are you using, this one OWASP O2 Platform 5.5 - RC1 , please give it a test drive has the most updated APIs (also check out some of those doc links)
 

Thank you very much.

No worries, and it would be great if you could let us know (or write a blog post about it) how you are trying to use O2 , specially which links/docs really helped you (as you can see, a big issue with O2/FluentSharp is the lack of documentation for new users (like you))

Best regards

Dinis Cruz 

Chris Kim

未讀,
2014年9月2日 清晨6:56:272014/9/2
收件者:o2-pl...@owasp.org
Hi, Dinis,

Thank you very much for such a detailed answer.
I went over the link and try to follow them.
I suppose what I want is rather a simple.
Create a project in Visual Studio 2010 and develop an application interactively.
Code are written using VS editor and (Unit)testing are done using O2 REPL plugin.

So for an example, I create a new project and create a class, how do I access the class from O2 REPL?
The closest example I found is,
But does so as an isolated code and not part of Visual Stuido project. Hmm...I'm not sure I can do the same with the current VS project.

Cheers!

-chris


Dinis Cruz

未讀,
2014年9月2日 清晨7:49:372014/9/2
收件者:O2 Platform
OK, so what do you mean by 'how do I access the class from O2 REPL'

do you want to access the compiled dlls or the actual source code? This is a key question because VS doesn't compile the full code until you hit F5

If you are doing TDD development, what I would do is to write the UnitTests inside VisualStudio and use the FluentSharp APIs that you can get from NuGet to invoke code (in a repl Style) on the class you created. That is the best of both worlds and is what I tend to do when developing the TeamMentor UnitTests (here is what my dev environment looks like http://blog.diniscruz.com/2014/07/how-to-debug-cassini-hosted-website-and.html and http://blog.diniscruz.com/2014/07/using-watin-and-embedded-cassini-to-run.html)

On the link that you provided, the compilation is done using O2's CSharp compiler (i.e. doesn't wait for VisualStudio to compile), which you can see on this gist https://gist.github.com/DinisCruz/4022339 (linked from the article)

I think a better example for you to follow is http://blog.diniscruz.com/2012/11/viewing-console-out-messages-created.html Can you see how the Console.out message that was written from inside the WinForms Control (hosted in VS WinForms Control designer) was shown on the O2 Control?


--
You received this message because you are subscribed to the Google Groups "O2 Platform" group.
To post to this group, send email to o2-pl...@owasp.org.
Visit this group at http://groups.google.com/a/owasp.org/group/o2-platform/.

chri...@gmail.com

未讀,
2014年9月2日 上午11:20:002014/9/2
收件者:O2 Platform
Hi, Dinis,
 
Thanks for the quick reply.
 
There are couple of things I want to do from the Q2 REPL.
 
1. Dynamically execute a code written from Visual Studio. (Sure, it has to be compiled first) 
 
For a simplified example,
 
<From Visual Stuido>
 
public class Person
{
     public string Name { get; set; }
}
 
===========================
<And from O2 REPL>
 
Person person = new Person { Name = "foo" };
Console.WriteLine(person.Name);
 
 
2. Dynamically compile methods of a running instance without stop->edit->compile->run.
 
For an example, if a method dynamically recompiled while an instance is running and the method is called again after the recompile, it calls the new method.
(It will probably require DLL swapping on the fly, or just updating the function entry point will suffice)
The productivity of development will go up dramatically without stop->edit->compile->run cycle. 
 
I’m used to using #1, #2 from developing CommonLisp and I was wondering if it’s possible on C# using O2 Platform also.
I’m kind of lead to believe it’s possible. ^^
If it isn’t possible currently, how difficult would it be to support them? I’ll be super excited if is possible.
 
Thank you very much.
 
Cheers!
 
-chris
To unsubscribe from this group and stop receiving emails from it, send an email to o2-platform...@owasp.org.



이 이메일에는 바이러스와 맬웨어가 없습니다. avast! 안티바이러스 보호가 활성화된 상태이기 때문입니다.


Dinis Cruz

未讀,
2014年9月2日 晚上9:26:462014/9/2
收件者:O2 Platform
(see inline)

On 2 September 2014 16:19, <chri...@gmail.com> wrote:
Hi, Dinis,
 
Thanks for the quick reply.
 
There are couple of things I want to do from the Q2 REPL.
 
1. Dynamically execute a code written from Visual Studio. (Sure, it has to be compiled first) 
 
For a simplified example,
 
<From Visual Stuido>
 
public class Person
{
     public string Name { get; set; }
}
 
===========================
<And from O2 REPL>
 
Person person = new Person { Name = "foo" };
Console.WriteLine(person.Name);


Ok, can you take a look at the example I documented at https://github.com/o2platform/FluentSharp/issues/32 (that is a simple example, but already shows a lot of REPL capabilities)

Are you able to replicate it? (and achieve the same Outputs)

 
 
 
2. Dynamically compile methods of a running instance without stop->edit->compile->run.
 
For an example, if a method dynamically recompiled while an instance is running and the method is called again after the recompile, it calls the new method.

So you have that in the example shown above (well, I did it on Properties, but the same applies for methods, fields, enums, etc...)
 
(It will probably require DLL swapping on the fly, or just updating the function entry point will suffice)

The key issue here is to go around VS compilation and execution. Since once VS is executing that dll you will not able able to change it (easily)

 
The productivity of development will go up dramatically without stop->edit->compile->run cycle. 

Yes, that is exactly how I code (and the productivity boost is enormous)

My view is that "you shouldn't need to run the app (i.e. click F5) to see/execute the code changes you make during the normal development cycle"
 
 
I’m used to using #1, #2 from developing CommonLisp and I was wondering if it’s possible on C# using O2 Platform also.
I’m kind of lead to believe it’s possible. ^^

Yap its possible (specially in a TDD development mode)
 
If it isn’t possible currently, how difficult would it be to support them? I’ll be super excited if is possible.

Well you just need to figure out how to do it with O2 and fine tune your dev workflows :)

Chris Kim

未讀,
2014年9月4日 凌晨1:59:012014/9/4
收件者:o2-pl...@owasp.org
Hi, Dinis,
 
I see what you are doing. Basically, the code has to be opened/referenced in O2 REPL, right?
It is good for simple test but, how do I deal with a large project with many files?
Is there way to work with the whole project?
 
Many thanks.



This email is free from viruses and malware because avast! Antivirus protection is active.


Dinis Cruz

未讀,
2014年9月4日 上午8:08:482014/9/4
收件者:O2 Platform

In those cases you either add the O2 APIs to the main app, or run the tests from UnitTests.

I'll try to send an example later today.

Dinis Cruz

未讀,
2014年9月4日 晚上10:20:322014/9/4
收件者:O2 Platform
ok, what about this: https://github.com/o2platform/FluentSharp/issues/32#issuecomment-54570296

Is that more in line of what you are looking for?

Note how I was able to make a change in the main project which was (after build) directly consumed in a test (with no need to start the main app). What is key is that the tests are running in seconds

Dinis

Chris Kim

未讀,
2014年9月5日 清晨5:28:512014/9/5
收件者:O2 Platform
Hi, Dinis,
 
Wow.. this is awesome!
It’s lightyears better than what used to do on application development!
 
There is one thing that’s kinda cumbersome, that is, every time I run the unit test, it opens REPL window (vis .script_Me_WaitForClose()), and it doesn’t remember the references.
I have to retype all the references to REPL window over and over again. I can get quite tired pretty quickly.
 
Instead of opening REPL window everytime there are some changes, is it possible the REPL window stays opened at all time, and it somehow talks to the changed codes?
 
If that’s possible, I’ll be so happy. ^^
 
Thank you very much.

Dinis Cruz

未讀,
2014年9月5日 上午8:03:562014/9/5
收件者:O2 Platform

Yes that would be very annoying :)

Look at the source code of the script_IE extension method (or the script_IE_TeamMentor (not sure of that is the correct class name, but it should be similar))

I think the solution you're looking for is in there (basically you add a number of extra references to the REPL (as it loads))

BTW, have you seen the auto-backup of scripts? That is also a nice way to restore the last executed script.

Dinis Cruz

未讀,
2014年9月5日 下午5:57:312014/9/5
收件者:O2 Platform

chri...@gmail.com

未讀,
2014年9月6日 上午11:02:112014/9/6
收件者:o2-pl...@owasp.org
Hi, Dinis,
 
Cool! It will do it!
I’ll keep trying to use O2 Platform and let you know if I have more questions.
Thank you very much for such a great work.

Dinis Cruz

未讀,
2014年9月6日 上午11:31:522014/9/6
收件者:O2 Platform

No worries, and Thx for the great questions

BTW, have you tried the FluentSharp reflection APIs?

回覆所有人
回覆作者
轉寄
0 則新訊息