This documentation is not maintained. Please refer to doc.castsoftware.com/technologies to find the latest updates.

Summary: This document provides basic information about the extension providing HTML5/JavaScript support for Web applications.

What's new:

  • Support of Object Oriented ECMA6 annotations (classes, constructors, try/catch...)
  • Support of const, let arrows ECMA6 annotations
  • Support of Javascript call(), window.function(), bind(), prototype and prototype inheritance
  • HttpRequest web service (<a href="">)
  • 18 new Quality Rules

Description

In what situation should you install this extension?

The analyzer could be used if your application is a Web Application, has HTML/Javascript/CSS files and/or contains HTML/Javascript fragments embedded into JEE and .NET files (for example).

The analyzer provides the following features:

  • Automated Function Point counting.
  • Checksum, number of code lines, number of comment lines, comments are present.
  • Local and global resolution is done when function is called directly through its name (inference engine resolution is not available).
  • For global resolution, caller is searched in all .js files. If only one callee is found, a link is created. If several callees are found, the analyzer watches inclusions in html files to see if it can filter the callee. If nothing is found in html files to filter, links are created to all possible callees.

Files analyzed

Icon(s)FileExtensionNote

HTML

*.html, *.htm, *.xhtml
  • Supports HTML/XHTML versions 1 - 5.
  • creates one "HTML5 Source Code" object that is the caller of html to js links and a transaction entry point
  • broadcasts tags and attributes/values to other CAST extensions such as AngularJS. Other extensions will not need to analyze the files themselves.

Javascript*.js

Supports:

  • JavaScript 1 to 1.8.1.
  • JavaScript ECMA 6

See also JavaScript below for more information.

Cascading Style Sheet*.css

Supports CSS 1 - 3.

 

Java Server Page*.jsp

Supports JSP 1.1 - 2.3.

See JSP below for more information.

Active Server Page*.asp, *.aspx

See (Classic) ASP below for more information.

HTML Components*.htcHTC files contain html, javascript fragments that will be parsed. Created objects will be linked to the HTC file.

ASP.NET MVC Razor*.cshtml

See ASP.NET MVC Razor below for more information.

Note that by default some files are automatically excluded from the analysis, typically third-party frameworks which are not required. Please see the filters.json file located at the root of the extension folder for a complete list of default exclusions.

Technology support notes

(Classic) ASP

Click here to expand...

Although CAST AIP handles classic ASP (Active Server Pages) applications "out of the box" with the ASP analyzer, the HTML5 and JavaScript extension is also capable of analyzing classic ASP applications. Below is a comparison of the analysis of the same classic ASP application with results from the HTML5 and JavaScript extension on the left and results with the ASP analyzer embedded in CAST AIP on the right:

Some additional links are provided in certain situations:

But less information in other situations:

ASP.NET MVC Razor

Click here to expand...


Summary: This document provides basic information about the how the .NET technology ASP.NET MVC Razor is supported.

Introduction

ASP.NET MVC Razor is supported via the HTML5 and JavaScript extension, therefore you should ensure that a HTML5 and JavaScript Analysis Unit is configured to cover the relevant source code.

Features

  • Creates objects specific to Razor corresponding to requests to the .NET server, as services, embedded in .cshtml files.
  • Creates objects specific to ASP.NET corresponding to operations which are methods of controllers in the .NET server, embedded in .cs files. This part of the extension is launched by the .NET analyzer.
  • Creates call links between these two kinds of objects through the Web Services Linker. These two kinds of objects are identified by a URL, in order to be compatible with the Web Services Linker.

Server part (without specific routing)

The following objects are created:

ASP.NET Any Operation

ASP.NET Get Operation

HTML5 Razor Get service

ASP.NET Put Operation

ASP.NET Post Operation

HTML5 Razor Post service

ASP.NET Delete Operation

URL creation

URLs are created as follows:

"Course/Edit" for the Edit method of this CourseController class. This is an operation which may correspond to any type of request from the client, then a CAST_AspDotNet_AnyOperation is created:

public class CourseController : Controller
{ 
	public ActionResult Edit(int? id)
 	{
	}
}

"Course/Edit"  for the Edit method of this CourseController class, first Edit corresponds to a POST operation, then a CAST_AspDotNet_PostOperation is created.  The second Edit corresponds to any of the other operation types,and depending on this a CAST_AspDotNet_GetOperation object, CAST_AspDotNet_PutOperation object or CAST_AspDotNet_DeleteOperation are created:

public class CourseController : Controller
{ 
	[HttpPost]
	public ActionResult Edit(int? id)
 	{
	}

	public ActionResult Edit(other params)
 	{
	}
}

"Course/Edit"  for the Edit method of this CourseController class, this is a POST operation:

public class CourseController : Controller
{ 
	[HttpPost, ActionName("Edit")]
	public ActionResult EditPost(int? id)
 	{
	}
}

In this case, the url is "CourseEdit", and not "CourseEditPost" because of the attribute "ActionName" presence, which contains an alias (click to enlarge):

Server part (with specific routing)

This section is the same as the previous one (Server part (without specific routing)), except that URLs are modified depending on a specific config routing. Specific routings are present in the following files:

App_Start/RouteConfig.cs files:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace ContosoUniversity
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}
or some files named <name>AreaRegistration.cs files:
using System.Web.Mvc;

namespace XL.XLI.ScoringWebAppTool.WebUI.Areas.DesignProfessional
{
    public class DesignProfessionalAreaRegistration : AreaRegistration 
    {
        public override string AreaName 
        {
            get { return "DesignProfessional"; }
        }
        
        /* Order is important, as the engine uses fall-through matching logic. */
        public override void RegisterArea(AreaRegistrationContext context) 
        {
            context.MapRoute
            (
                "DesignProfessional_Default2",
                "DesignProfessional/{controller}/{action}/{id}",
                new
                {
                    controller = "PreRenewal",
                    action     = "Index",
                    id         = UrlParameter.Optional
                }
            );
            context.MapRoute
            (
                "DesignProfessional_Default",
                "DesignProfessional/PreRenewal",
                new
                {
                    controller = "PreRenewal",
                    action     = "Index",
                    id         = UrlParameter.Optional
                }
            );
        }
    }
}

Razor Client part

Creates object specific to Razor corresponding to requests to the NET server, as services, embedded in .cshtml files. The following objects are created:

HTML5 Razor Get service

HTML5 Razor Post service

Code examples

Html.ActionLink call

This code in a .cshtml file located in a directory named "Course" will create an object of type CAST_HTML5_Razor_GetService whose URL is "Course/Delete/{}". The presence of "{}" is due to the presence of a parameter of type "new {}" containing a word equals to "id" or ending with "id":

@Html.ActionLink("Delete", "Delete", new { id = item.CourseID })

Url.Action call

This code in a .cshtml file located in a directory named "Student" will create an object of type CAST_HTML5_Razor_GetService whose URL is "Student/Index":

@Html.PagedListPager(Model, page => Url.Action("Index",
	new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))

Html.ActionLinkWithAccess call

This code in a .cshtml file located in a directory named "StaffIncreaseProfilePeriod" will create an object of type CAST_HTML5_Razor_GetService whose URL is "StaffIncreaseProfilePeriod/Create":

<li>@Html.ActionLinkWithAccess(__("Add increase profile"), "Create", null, new { @class = "btn popupLink", data_popupsize = "big" })</li>

Html.Action call

This code in a .cshtml file located in a directory named "Account" will create an object of type CAST_HTML5_Razor_GetService whose URL is "Account/ExternalLoginsList".

@Html.Action("ExternalLoginsList", new { ReturnUrl = ViewBag.ReturnUrl })

Ajax.ActionLink call

This code in a .cshtml file located in a directory named "NotificationMessenger" will create an object of type CAST_HTML5_Razor_PostService whose URL is "NotificationMessenger/Delete/{}".

@Ajax.ActionLink("x", "Delete", "NotificationMessenger", new { notific.Id }, new AjaxOptions() { HttpMethod = "POST", OnComplete = "DismissNotification" }, new { @class = "notification-close" })

Html.RenderAction call

This code in a .cshtml file located in a directory named "Holidays" will create an object of type CAST_HTML5_Razor_PostService whose url is "Holidays/ColorsLegend".

@{ Html.RenderAction("ColorsLegend"); }

Html.BeginForm call

This code in a .cshtml file will create an object of type CAST_HTML5_Razor_PostService whose url is "Student/Index".

   @using (Html.BeginForm("Index", "Student", FormMethod.Get))
{
    <p>
        Find by name: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)
        <input type="submit" value="Search" />
    </p>
}

Ajax.BeginForm call

This code in a .cshtml file will create an object of type CAST_HTML5_Razor_PostService whose url is "Missions/SynthesisAjaxHandler/{}".

@using (Ajax.BeginForm(
"SynthesisAjaxHandler", //actionName
"Missions", //controllerName
new { //routeValues
missionId = Model.Mission.Id,
dayId = Model.MissionDayId,
method="GET"
},
new AjaxOptions { //Ajax setup
UpdateTargetId = "synthesisLinesDiv",
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
},
new { //htmlAttributes
Id = "form-selectSynthesis",
//method="get"
}
))

JavaScript

Click here to expand...

CAST AIP has provided support for analyzing JavaScript via its JEE and .NET analyzers (provided out of box in CAST AIP) for some time now. The HTML5/JavaScript extension also provides support for JavaScript but with a focus on web applications. CAST highly recommends that you use this extension if your Application contains JavaScript and more specifically if you want to analyze a web application, however you should take note of the following when using the extension with CAST AIP ≤ 8.2.x

  • You should ensure that you configure the extension to NOT analyze the back end web client part of a .NET or JEE application.
  • You should ensure that you configure the extension to ONLY analyze the front end web application built with the HTML5/JavaScript that communicates with the back end web client part of a .NET or JEE application.
  • If the back end web client part of a .NET or JEE application is analyzed with the HTML5/JavaScript extension and with the native .NET/JEE analyzers, then your results will reflect this - there will be duplicate objects and links (i.e. from the analyzer and from the extension) therefore impacting results and creating erroneous Function Point data.
Note that in CAST AIP 8.3.x, support for analyzing JavaScript has been withdrawn from the JEE and .NET analyzers.

Support of JavaScript in this extension

  • JavaScript (1 to 1.8.1):
    • Javascript call(), function(), bind(), prototype and prototype inheritance are supported
    • creates Functions, Classes and Constructors
    • local call links between function calls and functions inside each JavaScript file are created

JSP

Click here to expand...

CAST recommends using the HTML5 and JavaScript extension to analyze classic JSP applications (JSP versions 1.1 - 2.3) - this is because the JEE Analyzer is not capable of analyzing the JavaScript elements of the JSP application. Below is a screenshot of the analysis of a classic JSP application using the HTML5/JavaScript extension - click to enlarge:

Transaction configuration information

HTML5 source code: it represents the whole HTML file content.

Supported Languages

Comparison with existing support for JavaScript in CAST AIP

How to disable legacy Javascript analyzer

CAST AIP has provided support for analyzing JavaScript via its JEE and .NET analyzers (provided out of box in CAST AIP) for some time now. The HTML5/JavaScript extension also provides support for JavaScript but with a focus on web applications. CAST highly recommends that you use this extension if your Application contains JavaScript and more specifically if you want to analyze a web application, however you should take note of the following:

  • You should ensure that you configure the extension to NOT analyze the back end web client part of a .NET or JEE application.
  • You should ensure that you configure the extension to ONLY analyze the front end web application built with the HTML5/JavaScript that communicates with the back end web client part of a .NET or JEE application.
  • If the back end web client part of a .NET or JEE application is analyzed with the HTML5/JavaScript extension and with the native .NET/JEE analyzers, then your results will reflect this - there will be duplicate objects and links (i.e. from the analyzer and from the extension) therefore impacting results and creating erroneous Function Point data.

Note that in CAST AIP 8.3.x support for analyzing JavaScript has been withdrawn from the JEE and .NET analyzers.

Function Point, Quality and Sizing support

This extension provides the following support:

  • Function Points (transactions): a green tick indicates that OMG Function Point counting and Transaction Risk Index are supported
  • Quality and Sizing: a green tick indicates that CAST can measure size and that a minimum set of Quality Rules exist
Function Points
(transactions)
Quality and Sizing
(tick)(tick)

CAST AIP compatibility

This extension is compatible with:

CAST AIP release
Supported
8.2.x(tick)
8.1.x(tick)
8.0.x(tick)
7.3.4 and all higher 7.3.x releases(tick)

Supported DBMS servers

This extension is compatible with the following DBMS servers:

CAST AIP releaseCSS2OracleMicrosoft
All supported releases(tick)(tick)(error)

Prerequisites

(tick)An installation of any compatible release of CAST AIP (see table above)

Download and installation instructions

Please see:

The latest release status of this extension can be seen when downloading it from the CAST Extend server.

Packaging, delivering and analyzing your source code

Please see: HTML5 and JavaScript - Packaging, delivering and analyzing your source code

What results can you expect?

Once the analysis/snapshot generation has completed, you can view the results in the normal manner:

CAST Enlighten

Javascript ECMA6 Classes and Constructors example

CAST Management Studio analysis content

Objects

The following objects are displayed in CAST Enlighten:

 IconDescription
JavaScript file
HTML5 Source Code
HTML5 CSS Source Code
HTML5 CSS Source Code Fragment
HTML5 JavaScript Source Code
HTML5 JavaScript Source Code Fragment
HTML5 JavaScript Source Code Fragment from JEE object

Java Server Page (JSP) Content

Active Server Page (ASP) Content

Active Server Page .NET (ASPX) Content

HTML Component Content

Razor Template View

HTML5 JavaScript Function

HTML5 Javascript Method

HTML5 Javascript Class

HTML5 Javascript Class Constructor
HTML5 Web Socket Service

HTML5 Get XMLHttpRequest Service

HTML5 Get HttpRequest Service

HTML5 Update XMLHttpRequest Service

HTML5 Update HttpRequest Service

HTML5 Post XMLHttpRequest Service

HTML5 Post HttpRequest Service

HTML5 Delete XMLHttpRequest Service

HTML5 Delete HttpRequest Service

Rules

The list of rules is available here:

https://technologies.castsoftware.com/rules?rlH=AIP/extensions/com.castsoftware.html5/versions/1.6.0-funcrel/quality-rules

Known Limitations

  • Create object thanks to prototype is not supported