csharp-fix.pl

来自「一个语言识别引擎」· PL 代码 · 共 38 行

PL
38
字号
#!/usr/bin/perl -w

use strict;

# for Mono compile
my $compile_command = "mcs *.cs";

my $txt = `$compile_command 2>&1`;

my @bugs = ($txt =~ /([a-z0-9_]+\.cs\([0-9]+),[0-9]+\).*CS0115/img);

foreach my $bug (@bugs) {
    if ($bug =~ /(.*)\((.*)/) {
	my $fileName = $1;
	my $lineNumber = $2;
	print "Problem at $fileName:$lineNumber ... ";
	
	my $buffer = "";
	my $ct = 1;
	open(FIN,"<$fileName");
	while (<FIN>) {
	    if ($ct==$lineNumber) {
		$_ =~ s/override/virtual/;
		print " fixed";
	    }
	    $buffer .= $_;
	    $ct++;
	}
	print "\n";
	close(FIN);
	open(FOUT,">$fileName");
	print FOUT $buffer;
	close(FOUT);
    }
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?