This project is read-only.
JsAction provide quick and easy way to map 1:1 server side methods with client side ones.
Visual Studio provides a great intellisense support for .NET languages (C#, Vb.NET), but also for JavaScript using the new ide features

Even if JsAction methods are runtime generated, after a lot of work i provided a way to have intellisense support not only for method listing, but also for (bada bum piish) server side comments.

Let's start with a simple Complex class and a method marked with JsAction attribute. Let's add also server side comments on method.

    public class Student
        public string firstName { get; set; }
        public string lastName { get; set; }

        /// <summary>
        /// Sums two numbers
        /// </summary>
        /// <param name="st">The student</param>
        /// <param name="a">First number</param>
        /// <param name="b">Second number</param>
        /// <returns>The sum</returns>
        public JsonResult MyTestMethod(Student st, int a, int b)
            st.SumHere = a + b;
            return Json(st);


Now run the application and verify carefully that all works. Doc generation feature requires that
  • Application compiles.
  • Application works.
  • Xml output file is enabled (Project Properties -> Build -> Check "Xml Documentation File").

Now we're ready to generate documentation. Go to Tools->Library Package Manager-> Package Manager Console
Once opened we just have to write
PM> JsAction-GenDoc

The project will be build and run. If any error occurs, it will be displayed on the console.
Do not move or do nothing until project will close itself automatically. Return to visual studio and look to your script folder
A new file has been added: JsAction documentation file. It contains unminified and commented javascript code.
/*Generated: 19/02/2012 23:50:35*/
var JsActions = {
    MyTestMethod: function (st, a, b, options) { ///<summary>
        ///            Sums two numbers
        ///            </summary><param name="st" type="Student">The student</param><param name="a" type="Int32">First number</param><param name="b" type="Int32">Second number</param><returns>The sum</returns><param name="options" type="ajaxSettings">[OPTIONAL] AjaxOptions partial object; it will be mergend with the one sent to .ajax jQuery function</param>
        var opts = {
            url: "/Home/MyTestMethod",
            async: true,
            cache: true,
            type: "GET",
            data: $.toDictionary({
                st: st,
                a: a,
                b: b
        jQuery.extend(opts, options);
        return jQuery.ajax(opts);

Now let's create a new javascript file and use the doc file as reference.
Code completion
Code comments!!
As you can see from the second image, also parameter type is resolved. (Student,Int32). This should help you to never use a wrong type.
Note also the jQuery options object, always optional.

JsAction, when possible, performs also a Complex Type Decomposition.
As you can see from the image, if your methods takes a complex type, JsAction will generate the corresponding javascript object declaration with intellisense support to have a quick and safe way to costruct objects.

IMPORTANT: The vsdoc file must never be used as a @JsScript call replacement. It misses internal functions and it's purpose it's only to documentate function during development.
NOTE: Intellisense feature will work also if no Xml Documentation file generation is enabled. However, it will miss YOUR comments, providing only method signature and type resolution.

Last edited Mar 31, 2012 at 12:04 PM by XVincentX, version 9


No comments yet.