|
| 1 | +<!-- This test validates that MonoRuntimeMixedModeExcludedAssembly works independently |
| 2 | + without requiring WasmShellAOTProfileExcludedMethods --> |
| 3 | +<Project Sdk="Microsoft.NET.Sdk.WebAssembly"> |
| 4 | + |
| 5 | + <PropertyGroup> |
| 6 | + <TargetFramework>net10.0</TargetFramework> |
| 7 | + <OutputType>Exe</OutputType> |
| 8 | + <IsPackable>false</IsPackable> |
| 9 | + |
| 10 | + <!-- Enable Mixed Mode AOT --> |
| 11 | + <WasmShellMonoRuntimeExecutionMode>InterpreterAndAOT</WasmShellMonoRuntimeExecutionMode> |
| 12 | + <RunAOTCompilation>true</RunAOTCompilation> |
| 13 | + |
| 14 | + <!-- Enable AOT profile debug list generation to verify filtering works --> |
| 15 | + <WasmShellGenerateAOTProfileDebugList>true</WasmShellGenerateAOTProfileDebugList> |
| 16 | + |
| 17 | + <!-- Use the AOT profile for profiled AOT compilation --> |
| 18 | + <WasmAotProfilePath>$(MSBuildThisFileDirectory)aot.profile</WasmAotProfilePath> |
| 19 | + |
| 20 | + <!--<WasmShellGenerateAOTProfile>true</WasmShellGenerateAOTProfile>--> |
| 21 | + |
| 22 | + <!-- Important: We deliberately DO NOT set WasmShellAOTProfileExcludedMethods |
| 23 | + to test that MonoRuntimeMixedModeExcludedAssembly works independently --> |
| 24 | + </PropertyGroup> |
| 25 | + |
| 26 | + <ItemGroup> |
| 27 | + <!-- Add a dependency that we'll exclude from AOT --> |
| 28 | + <PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> |
| 29 | + </ItemGroup> |
| 30 | + |
| 31 | + <ItemGroup> |
| 32 | + <!-- Test that this works without WasmShellAOTProfileExcludedMethods being set --> |
| 33 | + <MonoRuntimeMixedModeExcludedAssembly Include="Newtonsoft.Json" /> |
| 34 | + <MonoRuntimeMixedModeExcludedAssembly Include="System.Xml" /> |
| 35 | + </ItemGroup> |
| 36 | + |
| 37 | + <Import Project="..\Uno.Wasm.Bootstrap\build\Uno.Wasm.Bootstrap.props" /> |
| 38 | + <Import Project="..\Uno.Wasm.Bootstrap\build\Uno.Wasm.Bootstrap.targets" /> |
| 39 | + |
| 40 | + <ItemGroup> |
| 41 | + <ProjectReference Include="..\Uno.Wasm.Bootstrap\Uno.Wasm.Bootstrap.csproj"> |
| 42 | + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> |
| 43 | + <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> |
| 44 | + <UndefineProperties>TargetFramework</UndefineProperties> |
| 45 | + </ProjectReference> |
| 46 | + </ItemGroup> |
| 47 | + |
| 48 | + <!-- Post-build validation target --> |
| 49 | + <Target Name="ValidateMixedModeProfileFiltering" AfterTargets="Publish" Condition="'$(WasmAotProfilePath)' != ''"> |
| 50 | + <PropertyGroup> |
| 51 | + <_originalProfilePath>$(IntermediateOutputPath)AOTProfileDump.Original.txt</_originalProfilePath> |
| 52 | + <_filteredProfilePath>$(IntermediateOutputPath)AOTProfileDump.Filtered.txt</_filteredProfilePath> |
| 53 | + </PropertyGroup> |
| 54 | + |
| 55 | + <!-- Verify that both debug dump files were generated --> |
| 56 | + <Error Condition="!Exists('$(_originalProfilePath)')" |
| 57 | + Text="AOTProfileDump.Original.txt was not generated. MonoRuntimeMixedModeExcludedAssembly may not be working correctly." /> |
| 58 | + |
| 59 | + <Error Condition="!Exists('$(_filteredProfilePath)')" |
| 60 | + Text="AOTProfileDump.Filtered.txt was not generated. Profile filtering for MonoRuntimeMixedModeExcludedAssembly is not being applied." /> |
| 61 | + |
| 62 | + <!-- Read and analyze the profile dumps --> |
| 63 | + <ReadLinesFromFile File="$(_originalProfilePath)"> |
| 64 | + <Output TaskParameter="Lines" ItemName="_OriginalProfileLines" /> |
| 65 | + </ReadLinesFromFile> |
| 66 | + |
| 67 | + <ReadLinesFromFile File="$(_filteredProfilePath)"> |
| 68 | + <Output TaskParameter="Lines" ItemName="_FilteredProfileLines" /> |
| 69 | + </ReadLinesFromFile> |
| 70 | + |
| 71 | + <!-- Check that Newtonsoft.Json methods exist in original profile --> |
| 72 | + <ItemGroup> |
| 73 | + <_NewtonsoftMethodsInOriginal Include="@(_OriginalProfileLines)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('Newtonsoft.Json'))" /> |
| 74 | + </ItemGroup> |
| 75 | + |
| 76 | + <Error Condition="@(_NewtonsoftMethodsInOriginal->Count()) == 0" |
| 77 | + Text="No Newtonsoft.Json methods found in original profile. The test may not be using the assembly correctly." /> |
| 78 | + |
| 79 | + <!-- Check that Newtonsoft.Json methods do NOT exist in filtered profile --> |
| 80 | + <ItemGroup> |
| 81 | + <_NewtonsoftMethodsInFiltered Include="@(_FilteredProfileLines)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('Newtonsoft.Json'))" /> |
| 82 | + </ItemGroup> |
| 83 | + |
| 84 | + <Error Condition="@(_NewtonsoftMethodsInFiltered->Count()) > 0" |
| 85 | + Text="Found @(_NewtonsoftMethodsInFiltered->Count()) Newtonsoft.Json methods in filtered profile. Assembly exclusion is not working! First method: @(_NewtonsoftMethodsInFiltered->'%(Identity)', ' | ')" /> |
| 86 | + |
| 87 | + <!-- Check that System.Xml methods do NOT exist in filtered profile --> |
| 88 | + <ItemGroup> |
| 89 | + <_SystemXmlMethodsInFiltered Include="@(_FilteredProfileLines)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('System.Xml'))" /> |
| 90 | + </ItemGroup> |
| 91 | + |
| 92 | + <Error Condition="@(_SystemXmlMethodsInFiltered->Count()) > 0" |
| 93 | + Text="Found @(_SystemXmlMethodsInFiltered->Count()) System.Xml methods in filtered profile. Assembly exclusion is not working!" /> |
| 94 | + |
| 95 | + <Message Importance="high" Text="✓ Profile filtering validated successfully!" /> |
| 96 | + <Message Importance="high" Text=" - Original profile has @(_OriginalProfileLines->Count()) total methods" /> |
| 97 | + <Message Importance="high" Text=" - Filtered profile has @(_FilteredProfileLines->Count()) total methods" /> |
| 98 | + <Message Importance="high" Text=" - Found @(_NewtonsoftMethodsInOriginal->Count()) Newtonsoft.Json methods in original (correctly excluded from filtered)" /> |
| 99 | + <Message Importance="high" Text=" - MonoRuntimeMixedModeExcludedAssembly is working correctly!" /> |
| 100 | + </Target> |
| 101 | + |
| 102 | +</Project> |
0 commit comments