I use C# on a daily basis to do most of my coding.
I really don't like #region directives. It's not just a love-hate thing. I really hate it. I have a compulsive need to eliminate them. It's extra fluff that really doesn't need to be in the in the code to make the code any more meaningful. It doesn't add any value to the executable bits.
Using Find/Replace always gets tedius. Why not just remove all instances of it throughout the solution in one action?
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module CodeHelper
Public Sub RemoveRegions()
RemoveThisRegexFromSolution("\#region.+")
RemoveThisRegexFromSolution("\#endregion")
End Sub
Public Sub RemoveThisRegexFromSolution(ByVal findRegex As String)
DTE.Windows.Item(Constants.vsWindowKindFindReplace).Activate() 'Find and Replace
DTE.Find.FindWhat = findRegex
DTE.Find.ReplaceWith = ""
DTE.Find.Target = vsFindTarget.vsFindTargetFiles
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = True
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
DTE.Find.SearchPath = "Entire Solution"
DTE.Find.SearchSubfolders = True
DTE.Find.KeepModifiedDocumentsOpen = False
DTE.Find.FilesOfType = "*.*"
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResults1
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.Execute() ' Do it
DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close() ' Close the box
End Sub
End Module