pass same file line

This commit is contained in:
ikpil 2023-04-29 12:33:34 +09:00
parent b30f3c7666
commit 39bb7e32b4
1 changed files with 62 additions and 52 deletions

View File

@ -4,6 +4,15 @@ 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)
@ -36,6 +45,7 @@ public static class Program
locations.Add(fileLocation); locations.Add(fileLocation);
} }
} }
return locations; return locations;
} }
@ -52,14 +62,14 @@ public static class Program
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);
} }
} }