Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mristin committed Feb 4, 2024
1 parent be39987 commit feeb763
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions src/Script.SemanticallyPatchAasCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IPatch>();

#region FindTheLastUsingAndAddNewtownsoft
root.DescendantNodes()
.OfType<UsingDirectiveSyntax>()
.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
Expand Down Expand Up @@ -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<string>() {
"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;
Expand Down

0 comments on commit feeb763

Please sign in to comment.