diff --git a/tests/dotnet/UnitTests/TrimmerWarningsTest.cs b/tests/dotnet/UnitTests/TrimmerWarningsTest.cs index baa7ccdc5c3d..b319f249d3c3 100644 --- a/tests/dotnet/UnitTests/TrimmerWarningsTest.cs +++ b/tests/dotnet/UnitTests/TrimmerWarningsTest.cs @@ -8,7 +8,25 @@ public class TrimmerWarningsTest : TestBaseClass { [TestCase (ApplePlatform.TVOS, "tvossimulator-x64")] public void TrimmerWarningsManagedStaticRegistrar (ApplePlatform platform, string runtimeIdentifiers) { - TrimmerWarnings (platform, runtimeIdentifiers, "managed-static", Array.Empty ()); + // FIXME: dotnet/runtime#100256 + ExpectedBuildMessage [] expectedWarnings; + switch (platform) { + case ApplePlatform.iOS: + case ApplePlatform.TVOS: + expectedWarnings = Array.Empty (); + break; + case ApplePlatform.MacOSX: + case ApplePlatform.MacCatalyst: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeCompiled: Attribute 'System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute' is being referenced in code but the trimmer was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the trimmer attribute XML portion which removes the attribute instances, or override the removal by using the trimmer XML descriptor to keep the attribute type (which in turn keeps all of its instances)."), + }; + break; + default: + Assert.Fail ($"Unknown platform: {platform}"); + return; + } + + TrimmerWarnings (platform, runtimeIdentifiers, "managed-static", expectedWarnings); } [Test] @@ -18,7 +36,25 @@ public void TrimmerWarningsManagedStaticRegistrar (ApplePlatform platform, strin [TestCase (ApplePlatform.TVOS, "tvos-arm64")] public void TrimmerWarningsStaticRegistrar (ApplePlatform platform, string runtimeIdentifiers) { - TrimmerWarnings (platform, runtimeIdentifiers, "static", Array.Empty ()); + // FIXME: dotnet/runtime#100256 + ExpectedBuildMessage [] expectedWarnings; + switch (platform) { + case ApplePlatform.iOS: + case ApplePlatform.TVOS: + expectedWarnings = Array.Empty (); + break; + case ApplePlatform.MacOSX: + case ApplePlatform.MacCatalyst: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeCompiled: Attribute 'System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute' is being referenced in code but the trimmer was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the trimmer attribute XML portion which removes the attribute instances, or override the removal by using the trimmer XML descriptor to keep the attribute type (which in turn keeps all of its instances)."), + }; + break; + default: + Assert.Fail ($"Unknown platform: {platform}"); + return; + } + + TrimmerWarnings (platform, runtimeIdentifiers, "static", expectedWarnings); } [Test] @@ -28,7 +64,25 @@ public void TrimmerWarningsStaticRegistrar (ApplePlatform platform, string runti [TestCase (ApplePlatform.TVOS, "tvos-arm64")] public void TrimmerWarningsDynamicRegistrar (ApplePlatform platform, string runtimeIdentifiers) { - TrimmerWarnings (platform, runtimeIdentifiers, "dynamic", Array.Empty ()); + // FIXME: dotnet/runtime#100256 + ExpectedBuildMessage [] expectedWarnings; + switch (platform) { + case ApplePlatform.iOS: + case ApplePlatform.TVOS: + expectedWarnings = Array.Empty (); + break; + case ApplePlatform.MacOSX: + case ApplePlatform.MacCatalyst: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeCompiled: Attribute 'System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute' is being referenced in code but the trimmer was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the trimmer attribute XML portion which removes the attribute instances, or override the removal by using the trimmer XML descriptor to keep the attribute type (which in turn keeps all of its instances)."), + }; + break; + default: + Assert.Fail ($"Unknown platform: {platform}"); + return; + } + + TrimmerWarnings (platform, runtimeIdentifiers, "dynamic", expectedWarnings); } void TrimmerWarnings (ApplePlatform platform, string runtimeIdentifiers, string registrar, params ExpectedBuildMessage [] expectedWarnings)