Script# + Reflector

The new .reflector assembly list file feature of .NET Reflector can be used to streamline the class browsing experience for Script#...

One of the benefits of using Script# that I've alluded to multiple times now, is the ability to use a standard class browser like .NET Reflector against your code. If you're using Reflector, you probably want to browse your Script# assemblies separate from the .NET Framework assemblies because of their overlap (eg. both of them contain a definition of System.Object and other basic classes such as String, Int32 etc.). In fact Reflector has the notion of assembly lists so you can already create interesting groups of assemblies and open/browse them as a set.

I've been asking Lutz for a feature to enable defining and storing an assembly set into a file, and then launching reflector.exe with an assembly list file. He has added that functionality as of version 5.0.21.0, so if you don't have the latest version (you probably do, given the auto-update functionality) go and download it now.

Essentially you can now have .reflector files with a plain list of assembly paths. You'll need to run reflector.exe /register once so that file association is created. Once you've done that, you can download ScriptSharp.reflector (the set of Script# assemblies and ScriptFX script framework), and ScriptSharpAtlas.reflector (the set of Script# assemblies usable against Microsoft ASP.NET AJAX). Caveat: For these standalone files, I've assumed the default install path, so you may need to edit them depending on your particular setup. This will be cleaned up in the future once the Script# installer creates these files and places shortcuts into the start menu.

The screenshot below shows browsing against the ASP.NET AJAX assemblies along with documentation. As most users of reflector will know, the tool picks up the same doc-comments stored in xml files alongside their associated assemblies that are used to drive intellisense inside Visual Studio.

The Script# readme describes all the assemblies in more detail. So there you have it ... class-browser support and some initial documentation... enjoy!

Posted on Tuesday, 6/12/2007 @ 6:12 PM | #Script#


Comments

12 comments have been posted.

Andrew Yanovsky

Posted on 6/14/2007 @ 3:54 AM
Cool!
By the way, it would be great to enable changing custom transport to have RESTful requests too, not only ...?param=1&callback=Delegate.***... Is it possible to override that in current Script# version? Without REST proxy caching is impossible, and service availability will be limited. Proxy caching (not browser caching) reduces the server load very much.

Nikhil Kothari

Posted on 6/14/2007 @ 11:45 AM
Andrew, I am not entirely sure what you're asking for - essentially what the Script# networking stack enables are RESTful requests. That said, you can certainly build your own mechanism by deriving from HTTPTransport, and writing a class that implements IHTTPResponse, and you can pretty much do anything under the covers, in terms of actual execution of the request, as well as marshalling of data on request/response ends.

Christiaan Van den Poel

Posted on 6/15/2007 @ 12:52 PM
Cool indeed, as always...

Although I'm still having troubles downloading the 2 .reflector files.
What can I do?
C+++

Matthew C. Hintzen

Posted on 6/15/2007 @ 3:58 PM
Nikhil,

Small irk about Script#. Ever since I added it, it has interferred with my normal .NET assembly project development. Its when i'm adding a class (normal C# class) to my project that I run into the stumble. I'm used to right mouse clicking on my project and then clicking "Add Class...", the next thing I do is type in my new class name and hit enter, but... since installing script# when I do that instead of picking the generic Class type in the Add New Item dialog, it picks your Script# Class type, and if I forget that change in behavior (which I do about 10% of the time) instead of getting a plain empty class named correctly, it adds a Script# class and also the Script# dependecies to my references. That's the part that is painful. I have to go back and clean up my project.

Any way to make the default add item type when right clicking to "Add Class..." to go back to being the default Class type instead of your Script# class type?

Matthew

Nikhil Kothari

Posted on 6/15/2007 @ 9:43 PM
Christiaan - the site is back up ... you should be able to download the .reflector files now.

Matthew - I haven't seen this on my machine. I was under the impression Visual Studio defaults to whatever you did last... is that not the case?

Christiaan Van den Poel

Posted on 6/16/2007 @ 1:58 PM
Nikhil,

I'm sorry to say, but I still cannot download these files.

Next to that, I'm experiencing the same problem as Matthew describes.

TIA
C+++

Matthew C. Hintzen

Posted on 6/21/2007 @ 3:04 PM
No, I'm afraid not Nikhil. It consistantly selects the Script# class.

Although I now program in C# exclusively, I do still have my dev environment set to VB developer settings (too lazy to re-learn key mappings), so maybe that is why I'm getting different behavior. Also I am running Vista x64!

Michael

Posted on 7/15/2007 @ 6:34 PM
Hi Nikhil,

First of, thanks again for your magnificent nStuff. Script# already saved me countless hours !
After solving initial problems with VS2005 installation (Script# installer wipes out all other project/item options) it's been quite a nice ride :)
Today I ran into another problem that I badly need your help with. Here it is. I have a method
public void AddHandler(TableRowElement row) {
Type.SetField(row, "_mouseoverDelegate", new DomEventHandler(Mouseover));
DomEvent.AddHandler(row, "mouseover", Type.GetField(row, "_mouseoverDelegate") as Sys.UI.DomEventHandler);
}
in my class that will not compile under aacorlib version. I'm trying to find a work around still using that version and tryed the following:
public void AddHandler(TableRowElement row) {
Type.SetField(row, "_mouseoverDelegate", new DomEventHandler(Mouseover));
DomEvent.AddHandler(row, "mouseover", (Sys.UI.DomEventHandler) Type.GetField(row, "_mouseoverDelegate"));
}

Compiler is bailing out with this code giving me something like:

Error 2 The "ScriptCompilerTask" task failed unexpectedly.
nStuff.ScriptSharp.Preprocessor.PreprocessorException: Unable to resolve or open included file '%code%'
at nStuff.ScriptSharp.Preprocessor.PreprocessorTextReader.RaiseError(String errorMessage, Exception innerException)
at nStuff.ScriptSharp.Preprocessor.PreprocessorTextReader.ProcessIncludeInstruction(String instructionLine, Boolean skipPreprocessing)
at nStuff.ScriptSharp.Preprocessor.PreprocessorTextReader.GetNextLine()
at nStuff.ScriptSharp.Preprocessor.PreprocessorTextReader.EnsureLine()
at nStuff.ScriptSharp.Preprocessor.PreprocessorTextReader.Read()
at nStuff.ScriptSharp.ScriptPreprocessor.Preprocess(PreprocessorOptions options)
at nStuff.ScriptSharp.ScriptCompiler.GenerateScriptWithTemplate()
at nStuff.ScriptSharp.ScriptCompiler.Compile(CompilerOptions options, String& startupType)
at nStuff.ScriptSharp.ScriptCompilerTask.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound) TableRowExtender

Would you give me some directions - what would be a good workaround? Or, should I just switch over to sscorlib and drop my attempts to use aacorlib?

Thanks again for your help,
-Michael

Michael

Posted on 7/15/2007 @ 6:56 PM
Nikhil,

Sorry, I forgot to mention the desirable compiler output - what exactly I'm trying to do would be an obvious question :) Here it is.
,
addMyHandler: function(row) {
row._mouseoverDelegate = Function.createDelegate(this, this._mouseover);
$addHandler(row, 'mouseover', row._mouseoverDelegate);
},

Any help would be highly appriciated, cheers.
-Michael

Nikhil Kothari

Posted on 7/16/2007 @ 6:53 PM
Michael,
Great to hear script# working for you.

I believe the problem you're seeing is "as" is not supported for aacorlib.dll - given that MicrosoftAjax.js does not define a method such as Type.SafeCast which is only defined in sscorlib.js. You'll have to either just cast to DomEventHandler, or extract out the code and do an manual "is" check followed by a cast. Most of the differences between script# mode and atlas mode are verifiable upfront, and I was under the impression this was as well... but apparently not. Hope that helps!

Michael

Posted on 7/16/2007 @ 8:53 PM
Nikhil,

Thanks a mil! After getting your message I took closer look into casting to DomEventHandler and, bingo! here was the problem. Note, that in example that I mentioned, the inline-op based casting was done as in
public void AddHandler(TableRowElement row) {
Type.SetField(row, "_mouseoverDelegate", new DomEventHandler(Mouseover));
DomEvent.AddHandler(row, "mouseover", (Sys.UI.DomEventHandler) Type.GetField(row, "_mouseoverDelegate"));
}

As soon as I replaced (Sys.UI.DomEventHandler) with just (DomEventHandler) everything started to work! The bottom line is [as always]: RTFM! In your writeup it is clearly indicated that the "multi-point" method calls are not supported...

Well, I'm really glad that this thing being resolved without the need for 0.3.0.1 :)

Thanks again and hope to see 0.4 soon :)
-Michael

Heidi

Posted on 8/3/2007 @ 3:38 AM
Hi,

i tried to get script# but noticed that projects.nikhilk.net is down! how do i now get the binaries and docs ?

thx in advance
The discussion on this post has been closed. Please use my contact form to provide comments.