From 4c26517c04f2c0c3833b87445f70c2c40d0cf8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 1 Oct 2024 06:36:48 +0900 Subject: [PATCH] Enable IDynamicInterfaceCastable tests disabled on fixed bug (#108376) These had to be excluded in #108235 but #108328 fixed them in the meantime. One of these PRs might be serviced for .NET 9 and the other may not, so I'm just reenabling this in a separate PR to make backports easier. --- .../IDynamicInterfaceCastable/Program.cs | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/tests/Interop/IDynamicInterfaceCastable/Program.cs b/src/tests/Interop/IDynamicInterfaceCastable/Program.cs index ccf91480faaa3f..73c84920352d15 100644 --- a/src/tests/Interop/IDynamicInterfaceCastable/Program.cs +++ b/src/tests/Interop/IDynamicInterfaceCastable/Program.cs @@ -393,38 +393,26 @@ public static void ValidateGenericInterface() Console.WriteLine(" -- Validate cast"); // ITestGeneric -> ITestGenericIntImpl - if (!TestLibrary.Utilities.IsNativeAot) // https://github.com/dotnet/runtime/issues/108229 - { - Assert.True(castableObj is ITestGeneric, $"Should be castable to {nameof(ITestGeneric)} via is"); - Assert.NotNull(castableObj as ITestGeneric); - } + Assert.True(castableObj is ITestGeneric, $"Should be castable to {nameof(ITestGeneric)} via is"); + Assert.NotNull(castableObj as ITestGeneric); ITestGeneric testInt = (ITestGeneric)castableObj; // ITestGeneric -> ITestGenericImpl - if (!TestLibrary.Utilities.IsNativeAot) // https://github.com/dotnet/runtime/issues/108229 - { - Assert.True(castableObj is ITestGeneric, $"Should be castable to {nameof(ITestGeneric)} via is"); - Assert.NotNull(castableObj as ITestGeneric); - } + Assert.True(castableObj is ITestGeneric, $"Should be castable to {nameof(ITestGeneric)} via is"); + Assert.NotNull(castableObj as ITestGeneric); ITestGeneric testStr = (ITestGeneric)castableObj; // Validate Variance // ITestGeneric -> ITestGenericImpl - if (!TestLibrary.Utilities.IsNativeAot) // https://github.com/dotnet/runtime/issues/108229 - { - Assert.True(castableObj is ITestGeneric, $"Should be castable to {nameof(ITestGeneric)} via is"); - Assert.NotNull(castableObj as ITestGeneric); - } + Assert.True(castableObj is ITestGeneric, $"Should be castable to {nameof(ITestGeneric)} via is"); + Assert.NotNull(castableObj as ITestGeneric); ITestGeneric testVar = (ITestGeneric)castableObj; - if (!TestLibrary.Utilities.IsNativeAot) // https://github.com/dotnet/runtime/issues/108229 - { - // ITestGeneric is not recognized - Assert.False(castableObj is ITestGeneric, $"Should not be castable to {nameof(ITestGeneric)} via is"); - Assert.Null(castableObj as ITestGeneric); - var ex = Assert.Throws(() => { var _ = (ITestGeneric)castableObj; }); - Assert.Equal(string.Format(DynamicInterfaceCastableException.ErrorFormat, typeof(ITestGeneric)), ex.Message); - } + // ITestGeneric is not recognized + Assert.False(castableObj is ITestGeneric, $"Should not be castable to {nameof(ITestGeneric)} via is"); + Assert.Null(castableObj as ITestGeneric); + var ex = Assert.Throws(() => { var _ = (ITestGeneric)castableObj; }); + Assert.Equal(string.Format(DynamicInterfaceCastableException.ErrorFormat, typeof(ITestGeneric)), ex.Message); int expectedInt = 42; string expectedStr = "str";