Also try to fix the StartupHookTests on LLVM FullAOT by making sure we also AOT dlls in subdirectories.
This uncovered an issue in src/tests/Common/external/external.csproj where an old version of Microsoft.CodeAnalysis.Compilers was referenced which made AOT fail, so I upgraded it.
That uncovered a problem AOTing Microsoft.CodeAnalysis.VisualBasic.dll so had to exclude it from AOTing.
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisVersion_LatestVS)" />
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisVersion_LatestVS)" />
- <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="$(MicrosoftCodeAnalysisAnalyzersVersion)" />
+ <PackageReference Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisVersion_LatestVS)" PrivateAssets="all" />
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisVersion_LatestVS)" PrivateAssets="all" />
+ <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="$(MicrosoftCodeAnalysisAnalyzersVersion)" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<PackageToInclude Include="CommandLineParser"/>
<PackageToInclude Include="Microsoft.DotNet.XUnitExtensions" />
- <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="1.1.1" />
+ <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="$(MicrosoftCodeAnalysisVersion_LatestVS)" />
<PackageReference Include="CommandLineParser" Version="2.1.1-beta" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="$(TraceEventVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
}
public static bool CanLoadAssemblyInSubdirectory =>
- !TestLibrary.Utilities.IsNativeAot && !TestLibrary.PlatformDetection.IsMonoLLVMFULLAOT;
+ !TestLibrary.Utilities.IsNativeAot &&
+ !TestLibrary.PlatformDetection.IsMonoLLVMFULLAOT &&
+ !OperatingSystem.IsAndroid() &&
+ !OperatingSystem.IsIOS() &&
+ !OperatingSystem.IsTvOS() &&
+ !OperatingSystem.IsBrowser() &&
+ !OperatingSystem.IsWasi();
[ConditionalFact(nameof(CanLoadAssemblyInSubdirectory))]
public static void AssemblyDirectory_Found()
private static delegate*<void> ProcessStartupHooks = (delegate*<void>)s_startupHookProvider.GetMethod("ProcessStartupHooks", BindingFlags.NonPublic | BindingFlags.Static).MethodHandle.GetFunctionPointer();
- public static bool IsSupported = ((delegate*<bool>)s_startupHookProvider.GetProperty(nameof(IsSupported), BindingFlags.NonPublic | BindingFlags.Static).GetMethod.MethodHandle.GetFunctionPointer())();
+ private static bool IsUnsupportedPlatform =
+ // these platforms need special setup for startup hooks
+ OperatingSystem.IsAndroid() ||
+ OperatingSystem.IsIOS() ||
+ OperatingSystem.IsTvOS() ||
+ OperatingSystem.IsBrowser() ||
+ OperatingSystem.IsWasi();
+
+ public static bool IsSupported = !IsUnsupportedPlatform && ((delegate*<bool>)s_startupHookProvider.GetProperty(nameof(IsSupported), BindingFlags.NonPublic | BindingFlags.Static).GetMethod.MethodHandle.GetFunctionPointer())();
[Fact]
public static void ValidHookName()
<Output TaskParameter="Filtered" ItemName="TestDirs" />
</RemoveDuplicates>
<ItemGroup>
- <TestsAndAssociatedAssemblies Include="%(TestDirs.Identity)/*.dll" Exclude="@(NoMonoAotAssemblyPaths)" />
- <CoreRootDlls Include="$(CORE_ROOT)/*.dll" Exclude="$(CORE_ROOT)/xunit.performance.api.dll" />
+ <TestsAndAssociatedAssemblies Include="%(TestDirs.Identity)/**/*.dll" Exclude="@(NoMonoAotAssemblyPaths)" />
+ <CoreRootDlls Include="$(CORE_ROOT)/*.dll" Exclude="$(CORE_ROOT)/xunit.performance.api.dll;$(CORE_ROOT)/Microsoft.CodeAnalysis.VisualBasic.dll" />
<AllDlls Condition="'$(MonoFullAot)' == 'true'" Include="@(TestsAndAssociatedAssemblies);@(CoreRootDlls)" />
<AllDlls Condition="'$(MonoFullAot)' != 'true'" Include="@(TestsAndAssociatedAssemblies)" />
</ItemGroup>
using (Listener listener = new())
{
+ CancellationTokenSource cts = new();
+
// Trigger the allocator task.
Task.Run(() =>
{
- while (true)
+ while (!cts.IsCancellationRequested)
{
for (int i = 0; i < 1000; i++)
{
}
}
+ cts.Cancel();
+
Assert2.True("listener.EventCount > 0", listener.EventCount > 0);
if (OperatingSystem.IsWindows())