Who we are

We are the developers of Plastic SCM, a full version control stack (not a Git variant). We work on the strongest branching and merging you can find, and a core that doesn't cringe with huge binaries and repos. We also develop the GUIs, mergetools and everything needed to give you the full version control stack.

If you want to give it a try, download it from here.

We also code SemanticMerge, and the gmaster Git client.

Custom preview tool for DLL files

Thursday, January 19, 2017 Ma Nu 0 Comments

Encouraged by your feedback in UserVoice asking to add previews to dll files we would like to show you how to support the scenario by creating your own preview tool.

Add previews to dll files

What is a custom preview tool

The custom preview tool we are going to build will provide information to the Plastic SCM items and diff views. We will not only generate interesting data based on the "DLL" files but also a nice thumbnail image. As you may know from our previous blogposts (Custom binary preview and Binaries preview for game developers) a preview tool is in charge of providing three different things:

  • Create a small thumbnail of the file.
  • Create a full size image of the file.
  • Create a properties summary of the file.

We'll create a single tool to handle the three requirements but I just want to let you know you can create one for the thumbnail and the full size images creation and another tool for the properties generation. This can be configured inside the Plastic SCM Preferences > Preview Tools > Add panel.

Items View

When the file is clicked at the Plastic SCM items view, Plastic will execute our preview tool twice. The first time providing two parameters:

  1. The source file path of the file we'll use for generating the preview image (Thumbnail).
  2. The output file path we'll use in order to write the preview image generated.

The second time Plastic runs the tool to get the properties of the clicked file. To do this, Plastic will only send one argument, the source file path of the clicked file. We need to read the file, generate a text string of data based on the file and write it on the standard output, Plastic will read the preview tool output and the info will be displayed.

Diff View

When you run a file diff operation inside Plastic and this file has a Preview tool attached, Plastic will request the tool a full-size image of the file and, again, the properties of the file. This is done exactly in the same way as it's explained for the Items View, the tool is executed twice and using the same input parameters.

DLL Info

For our Preview tool, we are going to use the windows API in order to get the DLL thumbnail and full-size images. You can check how it's done by reviewing the WindowsThumbnailProvider class. Based on the file extension, the class is able to request the OS a thumbnail for it.

On the other hand, the DLL file properties are calculated inside the DLLInfoProvider class. You'll see how the System.Diagnostics.FileVersionInfo is used to read the we DLL FileName, ProductName and Version properties. Check all you can get from it here and feel free to improve it.

Configuration

Open the Plastic SCM Preferences, click on Preview Tools and add a new one:

  • The Full path to the executable has to be just that! The path to the .exe we have created
  • The Command options to generate a thumbnail preview field has to match the following: --thumbnail "@src" "@output"
  • And the Command options to generate a full size preview has to be "@src" "@output"

We are using the same tool for both the preview generator and the properties generator. So the Full path to the properties generator is exactly the same as the one above for the preview tool meanwhile the Command options to generate file properties files should just be @src. That's it!

For the avoidance of doubt here you have a screenshot of my config:

Configuration

Check out the results!

Items View
Diff DLL

Find the source code here and the tool ready to use here.

Manuel Lucio
I'm in charge of the Customer Support area.
I deal with complex setups, policies and working methodologies on a daily basis.
Prior to taking full responsibility of support, I worked as software engineer. I have been in charge of load testing for quite some time, so if you want to know how well Plastic compares to SVN or P4 under a really heavy load, I'm your guy.
I like to play with Arduino GPS devices, mountain biking and playing tennis.
You can find me hooked to my iPhone, skate-boarding or learning Korean... and also here @mrcatacroquer.

0 comentarios: