Resource Analyzer

Resource Analyzer is a command-line tool designed to perform asset maintenance within a software project. This tool is particularly useful for developers and development teams who need an in-depth analysis of the resources used in the source code, identifying any inconsistencies and unused resources.


Key features
Resource Analyzer performs a full scan of the source code, analyzing all files with extensions specified in the configuration parameters. During the scan, the tool identifies all the resources instantiated in the project and compares them with those present in the resource management system provided by DataWeb.


Running the Tool
A typical example of running the tool from the command line is as follows:

 

resourceanalyzer appurl=https://localhost:5051 path=C:\Projects\MyProject

 

  • appurl: The URL of the application from which to retrieve the list of resources in DataWeb. This parameter is required
  • path: path of the project to be scanned. If omitted, the scan is performed in the current folder where the command prompt is running

     

Operation
During execution, Resource Analyzer uses a specific regex to identify all resources in the source code:
 

[\""|\'](?<resource>[A-Z][a-zA-Z0-9\-_]{1,49}\.[A-Z][a-zA-Z0-9\-_]{1,49}\.[A-Z][a-zA-Z0-9\-_]{1,99})[\""|\']


This regex allows you to locate all occurrences of resources in the Context.Group.Name form, ensuring that only strings that adhere to the resource naming convention are recognized.


Once the scan is complete, Resource Analyzer connects to a project endpoint managed by DataWeb to retrieve the list of actual resources. Next, generate two reports in the project path:

 

  • Unused Resources: resources that are present in DataWeb but not used in the source code
  • Missing Resources: resources that are present in the source code but are missing in DataWeb
     

Report Format
The generated reports are in CSV format and contain:

 

  • the Name of the resource (the unique identifier of the resource)
  • the file path, if any, where the resource was found in the source code

 

Important Note: Resources marked as "system" in DataWeb are not processed by Resource Analyzer.


Audit Customization
The audit performed by Resource Analyzer can be customized through the following topics:

 

  • appUrl (required): The URL of the web app from which to retrieve the list of resources in DataWeb
  • path: the scan path. If not specified, the tool audits the active folder of the prompt
  • contexts: Limit the analysis to specific contexts, such as App, Account, or MobileApp
  • extensions: specifies which types of text files must be processed to find resources. The default values are: .cs,.cshtml,.ts,.vue
  • excludedfolders: Indicates which folders to exclude from scanning. The default value is: node_modules,obj,bin
     
An example of a command with all the custom parameters would look like this:
 
resourceanalyzer appurl=https://localhost:5051 path=C:\Projects\MyProject contexts=DataWeb,App extensions=.cs,.cshtml,.ts,.vue excludedfolders=node_modules

Conclusion
Resource Analyzer is a powerful and flexible tool for maintaining control over localization resources in a software project. Using this tool, development teams can quickly identify unused or missing resources, thereby streamlining the development process and improving overall project quality.