Create your custom monitoring system thanks to RevDeBug Selective Recording.
Estimated reading time: 3 mins
Last edited: 04 Nov 2019
By default, RevDeBug parses and processes all of the available code within a project. Whitelisting allows you to choose particular parts of your code. This means - if you enable whitelisting, anything that is not whitelisted, will not be recorded.
Whitelist from recording particular parts of code
To enable RevDeBug Whitelist, you must add a reference to the RevDeBug.Config library in your project. You can find it by opening RevDeBug Compiler directory. It is easily accessed through the RevDeBug Menu (RevDeBug > Advanced > Open RevDeBug Compiler directory).
RevDeBug.Config.dll provides access to RevDeBug.Config.Filter namespace, in which there are two attributes defined:
- EnableWhitelistAttribute – assembly wide attribute, enables RevDeBug Whitelist.
- WhitelistAttribute – can be used on declared types and methods (including properties and methods).
To enable RevDeBug Whitelist, you must first declare EnableWhitelist attribute within your project. The best place to do this is AssemblyInfo.cs created automatically by Visual Studio. You can find it in your project’s Properties node in Solution Explorer view.
Add this line of code, at the end of the file:
Now you can add Whitelist attribute to any type or method declarator you want. Just write this line above something you want to whitelist:
Whitelisting is inheritable, so if you whitelist a class, then all its methods and nested types will be whitelisted too.
Do not forget to compile the project using RevDeBug and run it to receive desirable states.
Disable whitelisting mode
To temporarily disable the Whitelist mode, just comment or remove previously added RevDeBug attributes and recompile your project.
To completely remove Whitelist mode, follow these four steps:
- Remove RevDeBug.Config.dll from project References
- Delete line associated with RevDeBug from AssemblyInfo project file
- Comment or remove all Whitelist attributes from classes and methods
- Compile project using RevDeBug to record all states, or without to get regular output file
RDBIgnore works adversely to Whitelist.
First, you have to create project_name.rdbignore file in your project’s solution.
Next, open it’s properties, and change the first one - Build Action - to AdditionalFiles.
Now you just have to write down the names or directories of any files or folders you do not want to record. Remember, that each record has to start from a new line.
Alternatively to RDBIgnore you can use NoTimeTravel region. It is the simpliest way of disabling recording for specified part of code.
Here is an example - the code inside the region won’t be recorded.
#region NoTimeTravel /* any code */ #endregion
Set exclusion rules
If you were ever worried, that RevDeBug will record some sensitive data, you shouldn’t be. With Exclusion Rules you can exclude anything you want.
You can define the rules per project, by creating a file called project_name.rdbbuildignore. You have to add it to your project’s solution.
Then open it’s properties and change the first one - Build Action - to AdditionalFiles. Now you can write rules for excluding your data. For example, if you do not want to record any important data like passwords, card numbers, etc. It is enough for you to write there the variable names. Like this:
password pwd cardNumber secretkey
Notice, that every variable is written in a new line, without commas or semicolons. Be sure, that this file has such structure, otherwise it won’t exclude provided variables!
Whitelist by project
If you want to add/remove RevDeBug from your project you need to go to Solution Explorer and click right mouse button on your project and choose add/remove RevDeBug
You can also add/ remove RevDeBug from RevDeBug panel >Status > Current solution.