eDosStation/CompareDef/Program.cs

77 lines
2.8 KiB
C#
Raw Normal View History

2023-10-24 07:10:30 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CompareDef
{
class Program
{
const string def1 = @"D:\l\src\cs\eDosStation\TestMK3Dll\reader31\reader3.def";
const string def2 = @"D:\l\src\cs\eDosStation\TestMK3Dll\reader32\reader32.def";
static System.Collections.Generic.Dictionary<string, int> def1List, def2List;
static System.Collections.Generic.Dictionary<string, int> ImportDef(string defPath)
{
char[] sep = new char[] { ' ', '\t' };
System.Collections.Generic.Dictionary<string, int> list = new Dictionary<string, int>();
using (var s = new System.IO.StreamReader(defPath))
{
s.ReadLine();
s.ReadLine();
2024-09-04 13:05:16 +02:00
#pragma warning disable CS0168 // The variable 'l' is declared but never used
2023-10-24 07:10:30 +02:00
string l;
2024-09-04 13:05:16 +02:00
#pragma warning restore CS0168 // The variable 'l' is declared but never used
2023-10-24 07:10:30 +02:00
while (!s.EndOfStream)
{
var a = s.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries);
if (a.Length==2)
{
int i = a[0].IndexOf('=');
if (i >= 0)
a[0] = a[0].Substring(0, i );
2024-05-16 15:56:07 +02:00
i = a[0].LastIndexOf('@');
if (i >= 0) a[0] = a[0].Substring(0, i);
if (a[0].StartsWith("Begin", StringComparison.CurrentCultureIgnoreCase)) a[0] = a[0].Substring(5);
else if (a[0].StartsWith("End", StringComparison.CurrentCultureIgnoreCase)) a[0] = a[0].Substring(3);
if (!list.ContainsKey(a[0])) list.Add(a[0], int.Parse(a[1].Substring(1)));
2023-10-24 07:10:30 +02:00
}
}
};
return list;
}
static void CompareLists()
{
foreach (var x in def2List)
{
if (def1List.ContainsKey(x.Key))
{
//if (def1List[x.Key] != x.Value)
//{
// System.Diagnostics.Debug.WriteLine($"Ordinal changed function {x.Key} ordinal1 = {def1List[x.Key]} now at {x.Value}");
//}
} else
{
System.Diagnostics.Debug.WriteLine($"New function {x.Key} at {x.Value}");
}
}
}
static void Main(string[] args)
{
def1List = ImportDef(def1);
def2List = ImportDef(def2);
CompareLists();
}
}
}