#!c:/perl/bin/perl.exe use strict; use warnings; use File::Find; our $copyright = <<'HERE'; #region "Usage Rights" // Redacted to protect the guilty // All rights reserved. This document was developed under U.S. // Government Contract No. pi, and therefore the U.S. // Government is granted a copyright license to this document for U.S. // Government purposes. #endregion HERE our $access_modifier = "public|private|protected|internal|protected internal"; our $method_modifier = "virtual|sealed|override|abstract|extern"; our $comment = < \\s*///\\s*\\w+ \\s*///\\s* \\s*///\\s*\\w+\\s* HERE our $not_method = "as|basebreakcase|catch|checked|class|const|continue| default|delegate|do|else|enum|event|explicit|false|finally|fixed| for|foreach|goto|if|implicit|in|interface|is|lock|namespace| null|object|operator|out|params|readonly|ref|return|sizeof| stackalloc|struct|switch|this|throw|true|try|typeof|unchecked| unsafe|using|volatile|while"; =comment put stuff to glob the files here. =cut # Gets input and output filenames while getting Wanted to work my ($filin, $filout) = (@ARGV); Wanted($filin, $filout); exit; sub Wanted { my ($filin, $filout) = (@_); my %methods; open(FILIN, "<", "$filin") or die $^E; my $autogen = 0; my $line; while ($line = ) { chomp $line; if ($line =~ /^\W*$not_method/) { next; } if ($autogen < 48) { # This block looks for auto-generated files and skips to the next with no alterations at all. if ($line =~ //) { close FILIN; return 0; } ++$autogen; } if ( $line =~ m`(new)? # new is an optional element \s+ ($access_modifier) # public, private, protected etc. \s* ($method_modifier)? # static, override, extern, etc. Also optional \s* \w+ # return type, not optional \s+ \w+ # method name \s* \( .* \) # parameter list in parentheses `xo ) { # 'x' allows comments and internal whitespace, o says compile the pattern once only my $method = $line; my $summary = $method; $summary =~ s/^\s+//; my $params = $summary; $params =~ s`.*\(([^\(]*)\)`$1`; my @params = split ',', $params; my $header = < /// $summary /// HERE for (@params) { my ($type, $name) = split ' ', $_; $header .= <$type HERE } $methods{$method} = $header; } } close FILIN; open FILIN, "<", "$filin" or die $!; my $file; {local $/; $file = ; close FILIN; } METHOD: for (sort keys %methods) { my $method = $_; if ($file =~ m`$comment$method`s) { next METHOD; } my $header = $methods{$method}; my @file = split /$method/, $file; $file[0] .= $header; $file = join '', @file; } $file =~ s/#region "Usage Rights".+Government purposes.\n#endregion//gs; $file = $copyright . $file; open FILOUT, ">", "$filout"; print FILOUT $file; close FILOUT; } #### public virtual void Destroy(object O) { try { m_container.Mockery.VerifyAllExpectationsHaveBeenMet(); } finally { m_container = null; } }