Skip to content

Instantly share code, notes, and snippets.

@mat3u
Last active August 29, 2015 14:02
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 mat3u/76c8a6a079ce6381da3b to your computer and use it in GitHub Desktop.
Save mat3u/76c8a6a079ce6381da3b to your computer and use it in GitHub Desktop.
Extracts TODOs and FIXMEs from C# code
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