Skip to content

Instantly share code, notes, and snippets.

@rflechner
Last active October 20, 2016 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rflechner/cde0349812bae1280ee8f58bd90a50cb to your computer and use it in GitHub Desktop.
Save rflechner/cde0349812bae1280ee8f58bd90a50cb to your computer and use it in GitHub Desktop.
Get C# files not ending with LF (\n)
Function Get-CsharpFileNotEndingWithLF([string]$path)
{
$files = Get-ChildItem -Path $path -Recurse -Include @("*.cs")
$files | Foreach {
$content = [System.IO.File]::ReadAllText($_)
if ($content -ne $null)
{
$endsWithCRLF = $content.EndsWith("`n")
if (-not $endsWithCRLF -and -not $_.FullName.Contains("\obj\")) {
Write-Host "Invalid end of file in $($_.FullName)"
}
}
}
}
(curl "https://gist.githubusercontent.com/rflechner/cde0349812bae1280ee8f58bd90a50cb/raw/4ac34f043c33921055b83ff07b75e1f69901bea1/Get-CsharpFileNotEndingWithLF.ps1").Content > $PROFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment