Powershell to recursively strip C# regions from files

Here’s a super quick little powershell snippet to strip regions out of all C# files in a directory tree. Useful for legacy code where people hide long blocks in regions rather than encapsulate it into smaller methods/objects.

dir -recurse -filter *.cs $src | foreach ($_) {    $file = $_.fullname    echo $file    (get-content $file) | where {$_ -notmatch "^.*#(end)?region.*$" } | out-file $file}

Run this in your solution folder and support the movement against C# regions!