Enable Moq HostTests on ios - #131919
Conversation
These use some reflection APIs which were not working on trimming enabled workloads. Expand the trimming descriptor for Moq assembly so the required types are preserved.
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @dotnet/area-extensions-hosting |
There was a problem hiding this comment.
Pull request overview
This PR re-enables Moq-based HostTests on Apple mobile CoreCLR by ensuring the linker preserves required Moq/Castle types under aggressive trimming, and by removing the platform-specific ActiveIssue skips.
Changes:
- Added a trimmer root descriptor reference for the shared Castle/Moq linker descriptor in the hosting unit test project.
- Removed
[ActiveIssue(...128405...)]from several Moq/Castle-backedHostTests, keeping theIsReflectionEmitSupportedgate. - Expanded
ILLink.Descriptors.Castle.xmlto preserve theMoq.Asyncnamespace during trimming.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Microsoft.Extensions.Hosting.Unit.Tests.csproj | Adds the shared Castle/Moq trimmer descriptor to the test project so trimmed workloads keep needed types. |
| src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs | Removes Apple mobile ActiveIssue skips so these Moq-based tests can run again when Reflection.Emit is supported. |
| eng/testing/ILLinkDescriptors/ILLink.Descriptors.Castle.xml | Roots Moq.Async to prevent trimming from removing reflection-activated async-related Moq types. |
Suppressed comments (6)
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs:663
- Same as above: the comment should match the current gating (Reflection.Emit support + trimmed-workload descriptors) now that these tests are being re-enabled on Apple mobile CoreCLR.
}
// Moq heavily utilizes RefEmit, which does not work on most aot workloads
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public async Task WebHostStopAsyncUsesDefaultTimeoutIfNoTokenProvided()
{
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs:630
- Same as above: consider updating this comment to reflect the current reason these tests are guarded (Reflection.Emit support + trimmed-workload descriptors), rather than describing it primarily as an AOT limitation.
}
// Moq heavily utilizes RefEmit, which does not work on most aot workloads
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public async Task HostStopAsyncUsesDefaultTimeoutIfGivenTokenDoesNotFire()
{
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs:1220
- Same as above: update this comment to reflect why the tests are conditionally enabled (Reflection.Emit support + trimmed-workload descriptors), to avoid future confusion about Apple mobile support.
}
// Moq heavily utilizes RefEmit, which does not work on most aot workloads
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public void Dispose_DisposesAppConfigurationProviders()
{
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs:1245
- Same as above: adjust this comment so it reflects the current reason for the conditional (Reflection.Emit support + trimmed-workload descriptors) rather than primarily calling out AOT.
}
// Moq heavily utilizes RefEmit, which does not work on most aot workloads
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public void Dispose_DisposesHostConfigurationProviders()
{
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs:1321
- Same as above: consider updating this comment to align with the current Apple mobile enablement story (Reflection.Emit support + trimmed-workload descriptors).
}
// Moq heavily utilizes RefEmit, which does not work on most aot workloads
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public async Task DisposeAsync_DisposesAppConfigurationProviders()
{
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs:1346
- Same as above: now that the ActiveIssue skip is removed, updating this comment helps clarify the intended conditions for these Moq-based tests.
}
// Moq heavily utilizes RefEmit, which does not work on most aot workloads
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public async Task DisposeAsync_DisposesHostConfigurationProviders()
{
| @@ -593,7 +593,6 @@ public async Task HostShutsDownWhenTokenTriggers() | |||
| } | |||
|
|
|||
| // Moq heavily utilizes RefEmit, which does not work on most aot workloads | |||
These use some reflection APIs which were not working on trimming enabled workloads. Expand the trimming descriptor for Moq assembly so the required types are preserved.
Fixes #128405