forked from mirror/DotRecast
pass same file line
This commit is contained in:
parent
b30f3c7666
commit
39bb7e32b4
|
@ -4,11 +4,20 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
public class FileLocation
|
||||||
|
{
|
||||||
|
public required string Path { get; init; }
|
||||||
|
public required int Line { get; init; }
|
||||||
|
public required int Column { get; init; }
|
||||||
|
public required string Letter { get; init; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
private static List<FileLocation> CreateLocations(string path)
|
private static List<FileLocation> CreateLocations(string path)
|
||||||
{
|
{
|
||||||
List<string> list = ((IEnumerable<string>) File.ReadAllLines(path)).Where<string>((Func<string, bool>) (line => line.Contains("error CS1061: "))).ToList<string>();
|
List<string> list = ((IEnumerable<string>)File.ReadAllLines(path)).Where<string>((Func<string, bool>)(line => line.Contains("error CS1061: "))).ToList<string>();
|
||||||
List<FileLocation> locations = new List<FileLocation>();
|
List<FileLocation> locations = new List<FileLocation>();
|
||||||
foreach (string input in list)
|
foreach (string input in list)
|
||||||
{
|
{
|
||||||
|
@ -36,13 +45,14 @@ public static class Program
|
||||||
locations.Add(fileLocation);
|
locations.Add(fileLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Change(FileLocation location)
|
private static void Change(FileLocation location)
|
||||||
{
|
{
|
||||||
string[] contents = File.ReadAllLines(location.Path);
|
string[] contents = File.ReadAllLines(location.Path);
|
||||||
List<string> list = ((IEnumerable<char>) contents[location.Line - 1].ToCharArray()).Select<char, string>((Func<char, string>) (x => x.ToString() ?? "")).ToList<string>();
|
List<string> list = ((IEnumerable<char>)contents[location.Line - 1].ToCharArray()).Select<char, string>((Func<char, string>)(x => x.ToString() ?? "")).ToList<string>();
|
||||||
list[location.Column - 2] = "[";
|
list[location.Column - 2] = "[";
|
||||||
if (location.Letter == "x")
|
if (location.Letter == "x")
|
||||||
list[location.Column - 1] = "0]";
|
list[location.Column - 1] = "0]";
|
||||||
|
@ -50,16 +60,16 @@ public static class Program
|
||||||
list[location.Column - 1] = "1]";
|
list[location.Column - 1] = "1]";
|
||||||
else if (location.Letter == "z")
|
else if (location.Letter == "z")
|
||||||
list[location.Column - 1] = "2]";
|
list[location.Column - 1] = "2]";
|
||||||
string str = string.Join("", (IEnumerable<string>) list);
|
string str = string.Join("", (IEnumerable<string>)list);
|
||||||
contents[location.Line - 1] = str;
|
contents[location.Line - 1] = str;
|
||||||
//File.WriteAllLines(location.Path, contents);
|
|
||||||
|
File.WriteAllLines(location.Path, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var locations = Program.CreateLocations("../../../../../error.log");
|
var locations = Program.CreateLocations("../../../../../error.log");
|
||||||
foreach (FileLocation location in locations)
|
foreach (FileLocation location in locations.DistinctBy(x => x.Path + x.Line))
|
||||||
Program.Change(location);
|
Change(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue