Resource Static Analysis Executor overview - microsoft/Resource-Static-Analysis GitHub Wiki
The Resource-Static-Analysis Executor is a simple little sample application that enables you to validate software resources. The sample is very similar to a workflow that Microsoft Office team is actually using to validate that sufficient context have been added to resources by the developers in Word, Excel, OneNote, etc.
The sample configures the engine, with a data source, and a data adapter, and then runs a set of rules that checks for "localizability" issues on a set of resource files, so that one can ensure clean data even before code and resources are checked into a source control system.
A slightly modified version of the Resource-Static-Analysis Executor is also available to validate across multiple resource files. Batch Mode Executor scans directories and sub directories and look for supported resource files to run the engine against them.
###Usage
Resource-Static-Analysis Executor
ResourceStaticAnalysisExecutor.exe <Rules Path directory> <Path to file to be scanned>
Example
ResourceStaticAnalysisExecutor.exe C:\ResourceStaticAnalysis\Rules C:\MySoftwareResourceFiles\*.resx
Batch-Mode Executor
BatchModeExecutor.exe <Rules Path directory> <directory to scan> <optional include subdirectories? (true|false)> <optional path to output directory>
Example
BatchModeExecutor.exe C:\ResourceStaticAnalysis\Rules C:\MySoftwareResourceFiles true C:\MySoftwareResourceFiles\Output
###How it works
Both executors, have a similar way of working. Regardless we want to scan one or multiple resources, there are some steps that are required in order to run the Resource Static Analysis Engine against resource files. The steps are enumerated below:
- Instantiate the engine. During this step, a new instance of the ResourceStaticAnalysisApplication class gets created. This class is used to configure, initiate and execute the Resource Static Analysis Engine.
- Engine Configuration. It creates the configuration to be used by the Resource Static Analysis Engine. For that, it adds the Data Source Provider, the Property Adapter, the Classification Object Adapter and the Classification Adapter into the configuration. It also creates and sets the Data Source Package that the engine utilizes to understand what type of resources we are scanning through the engine. Also, the engine gets initialized and picks the built dll files that contain the checks the engine will run.
- Output Configuration. It configures the engine output using the ResourceStaticAnalysisOutput.xsd file to set up the schema for the output. Depending on how this file is created and what properties are included while configuring the output, the XML file that the engine will return will have a different layout. In the executors provided, the output file will contain a set of properties for the resources that had issues (SourceString, ResourceId, Comments) and whether or not for each rule, the checks found any issue (_True or False).
- Engine Execution. At this point, the engine is instantiated, initialized and configured so it is able to take the resource file and run against all the rules that were built in the dlls folder. The engine returns an output file per resource but also a list of exceptions in your source code in case there were any. Exceptions get logged in as trace errors
See more about the engine here.
See more about rules here.