Last Updated: February 25, 2016
·
484
· lukasz-madon

Script to add <auto-generated> to generated files

# Script add "// <auto-generated />" to .cs files tosuppress StyleCop warning (e.g. Thrift generated)
# Usage: powershell -ExecutionPolicy ByPass -File "$(ProjectDir)AddAutoGenerateToFiles.ps1" "$(ProjectDir)Generated"
$autoGenerated = "// <auto-generated />"
Get-ChildItem -recurse $args[0] -Filter *.cs | Foreach-Object {
 $content = Get-Content $_.FullName
 if(!$content[0].StartsWith($autoGenerated)) {
 Set-Content -Path $_.FullName -Value $autoGenerated
 Add-Content -Path $_.FullName -Value $content
 }
}