Last active
August 29, 2015 14:02
-
-
Save mat3u/76c8a6a079ce6381da3b to your computer and use it in GitHub Desktop.
Extracts TODOs and FIXMEs from C# code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[ValidateScript({Test-Path $_ -PathType 'Container'})] | |
[string]$path | |
) | |
Add-Type -AssemblyName System.Web | |
$files = ls -R -Path $path -Filter *.cs | |
$tasks = @() | |
$files | %{ | |
$_.FullPath | |
$file = $_ | |
$content = gc $_.FullName | |
$line = 1 | |
$content | %{ | |
$task = @{ | |
File = $file.FullName | |
Line = $line | |
Text = [System.Web.HttpUtility]::HtmlEncode($_) | |
} | |
if ($_ -Match "//\s*FIXME"){ | |
$task.Type = "fixme" | |
} | |
if ($_ -Match "//\s*TODO"){ | |
$task.Type = "todo" | |
} | |
if ($task.Type -ne $null) { | |
$tasks += $task | |
} | |
$line = $line + 1 | |
} | |
} | |
"<?xml version=`"1.0`" encoding=`"utf-8`" standalone=`"no`"?>" | |
"<tasks>" | |
# render work | |
#<task type="fixme" file="..." line="32">,,,</task> | |
$tasks | % { | |
" <task type=`"$($_.Type)`" file=`"$($_.File)`" line=`"$($_.Line)`">" | |
" " + $_.Text | |
" </task>" | |
} | |
"</tasks>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment