Read all c# classes and verifies that AllowUnsafeUpdates is not set

cls
Write-Host "**************************************************************************************************"
Write-Host "| This script will read all c# classes and verifies that AllowUnsafeUpdates is not set           |"
Write-Host "**************************************************************************************************"
Write-Host

$srcdir = Read-Host "Provide directory where all the source code is located" 

$s = [system.IO.SearchOption]::AllDirectories
$fileEntries = [IO.Directory]::GetFiles($srcdir,"*.cs",$s);

Write-Host

foreach($fullFileName in $fileEntries) 
{ 
	$file = New-Object -typename System.IO.StreamReader -argumentlist $fullFileName
	$b = $file.ReadToEnd()

	$contains = $b.Contains("AllowUnsafeUpdate");
	if($contains){
		Write-Host $fullFileName "contains AllowUnsafeUpdate" -foreground Red
		Write-Host
	}
	
	$file.Close();
}


VN:F [1.9.22_1171]
Rating: 8.2/10 (5 votes cast)
VN:F [1.9.22_1171]
Rating: +1 (from 3 votes)