From 197350ddc27d7a96d4161bf62dea55667406cd5c Mon Sep 17 00:00:00 2001 From: GH Cao Date: Wed, 21 Aug 2024 09:48:11 +0800 Subject: [PATCH] Fix AOT fixup failure when XAML files are in sub directories --- BuildTasks/NativeAotFixup.cs | 9 +++------ ModernXamlCompiler/ModernXamlCompiler.msbuildproj | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/BuildTasks/NativeAotFixup.cs b/BuildTasks/NativeAotFixup.cs index 6d62725..615bb44 100644 --- a/BuildTasks/NativeAotFixup.cs +++ b/BuildTasks/NativeAotFixup.cs @@ -41,8 +41,7 @@ private void Pass1Fixes() private void Pass2Fixes() { - Log.LogMessage(MessageImportance.High, "Pass2AddPartial"); - var pagePass2CsList = Directory.GetFiles(ObjDirectory, "*.g.cs"); + var pagePass2CsList = Directory.GetFiles(ObjDirectory, "*.g.cs", SearchOption.AllDirectories); foreach (var pagePass2Cs in pagePass2CsList) { var filename = Path.GetFileName(pagePass2Cs); @@ -52,9 +51,7 @@ private void Pass2Fixes() continue; } - var path = Path.Combine(ObjDirectory, filename); - - var str = File.ReadAllText(path); + var str = File.ReadAllText(pagePass2Cs); str = Regex.Replace(str, "private class (.*?_obj\\d*_Bindings) :(\\s+global::Windows.UI.Xaml.(?:IDataTemplateExtension|Markup.IDataTemplateComponent|Markup.IXamlBindScopeDiagnostics|Markup.IComponentConnector),)", "private partial class $1 :$2"); @@ -72,7 +69,7 @@ private void Pass2Fixes() str = Regex.Replace(str, "(this.dataRoot = )\\((global::.*?)\\)(.*?);", "$1global::WinRT.CastExtensions.As<$2>($3);"); - File.WriteAllText(path, str); + File.WriteAllText(pagePass2Cs, str); } } diff --git a/ModernXamlCompiler/ModernXamlCompiler.msbuildproj b/ModernXamlCompiler/ModernXamlCompiler.msbuildproj index d2dc69a..241c9dd 100644 --- a/ModernXamlCompiler/ModernXamlCompiler.msbuildproj +++ b/ModernXamlCompiler/ModernXamlCompiler.msbuildproj @@ -5,7 +5,7 @@ DisposableMemory.ModernNetUAP.XamlCompiler - 0.2.2-preview1 + 0.2.2 driver1998 UWP (Windows.UI.Xaml) Xaml Compiler support for Modern .NET https://github.com/driver1998/ModernNetUAP.XamlCompiler