Actions when opening a file

If you want to display a dialog box when opening a file in Visual Studio if the code file contains a TODO comment, here's how to achieve the result,

1. Add or activate action in main window.

2. Add condition inside EnvDTE tab:

Pre Post Guid Id   CustomIn   CustomOut Cancel
  {69F5F698-996B-4293-9FE7-4202564FE6E5} 256          

3. Activate Script Mode and add the following script:

#[var doc = #[DTE events.LastCommand.CustomIn]]
#[( $(doc.Length) != 0 )
{
    #[var msg = #[$([System.Text.RegularExpressions.Regex]::Matches(
        '$([System.IO.File]::ReadAllText($(doc)))', 
        "//\s*TODO.+"
    ))]]
    
    #[( $(msg.Length) != 0 )
    {
        #[File write("$(TMP)/TODO"):#[$(msg.Replace(';//', '//'))]]
        #[IO scall("notepad", "$(TMP)/TODO", 0)]
    }]
}]

4. Click [Apply] button. Enjoy.

Add some optional condition to filter opened or maybe closed files and their other words.

References