From feeb76373f72f042466b3ba425dc7e2848af56a0 Mon Sep 17 00:00:00 2001 From: Marko Ristin-Kaufmann Date: Sun, 4 Feb 2024 21:36:56 +0100 Subject: [PATCH] wip --- .../Program.cs | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/Script.SemanticallyPatchAasCore/Program.cs b/src/Script.SemanticallyPatchAasCore/Program.cs index 3ae82ca3..75be050d 100644 --- a/src/Script.SemanticallyPatchAasCore/Program.cs +++ b/src/Script.SemanticallyPatchAasCore/Program.cs @@ -204,9 +204,22 @@ private static bool PatchTypes(string srcTypesPath, string tgtTypesPath) { text ); - // TODO: implement -- iterate over tree and create patches + var root = (CompilationUnitSyntax)tree.GetRoot(); + var patches = new List(); + #region FindTheLastUsingAndAddNewtownsoft + root.DescendantNodes() + .OfType() + .Select(node => + { + + } + ); + + #endregion + + // TODO: find the last include, add Newtonsoft include // TODO: find all classes which implement IReferable, add snippet at the first part of the body @@ -276,10 +289,31 @@ private static int SemanticallyPatch(Arguments a) { string tgtTypesPath = Path.Join(a.TargetProject, "types.cs"); - bool success = true; - success = PatchTypes(srcTypesPath, tgtTypesPath) && success; - - // TODO: copy all the other files + bool success = PatchTypes(srcTypesPath, tgtTypesPath); + + var filenames = new List() { + "constants.cs", + "copying.cs", + "jsonization.cs", + "reporting.cs", + "stringification.cs", + "verification.cs", + "visitation.cs", + "xmlization.cs" + }; + foreach (var filename in filenames) { + string src = Path.Join(a.SourceProject, filename); + string tgt = Path.Join(a.TargetProject, filename); + + try { + File.Copy(src, tgt); + } catch(Exception exception) { + Console.Error.WriteLine( + $"Failed to copy {src} to {tgt}: {exception}" + ); + success = False; + } + } if (!success) { return 1;