From d27488dbcf982a582de03edfd989add51baee1b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 26 Feb 2026 12:52:44 +0900 Subject: [PATCH] Delete unnecessary test See the comment. There is a bit more context on the .NET Framework side: ``` This tests that we throw an exception when trying to load a module that contains two TypeDefs with the same name. We must use binary post-processing to make this happen since no compiler will allow us to define a duplicate type name. For simplicity, we have an IL image checked in and we'll just copy it over to testbin. Since this is an IL image, it should always work. However, if this image should ever stop working, the image can be reproduced by doing the following: 1) ilasm test5.il 2) use pereader to dump the structure of test5.exe 3) Find the index into the string heap for the name of the "Foo" class, copy the index 4) Find the path to the index for the name of the "Bar" class 5) create a file like test5.cpt that writes the Foo index value onto the name index field of the Bar class (thus, assigning the name "Foo" to the Bar type.) 6) use pewriter /source test5.exe /modify test5.cpt /out test5.cpt.exe to recreate the corrupted executable file. When running this test, set the environment variable: COMPLUS_DisableWatsonForManagedExceptions=1 to avoid a debugging pop-up dialog for the expected unhandled exception. ``` But basically this PE file should be modified and the test harness expects it to crash with an unhandled exception. It is not testing anything interesting without those steps. --- .../classloader/regressions/181424/test5.il | 99 ------------------- .../regressions/181424/test5.ilproj | 10 -- 2 files changed, 109 deletions(-) delete mode 100644 src/tests/Loader/classloader/regressions/181424/test5.il delete mode 100644 src/tests/Loader/classloader/regressions/181424/test5.ilproj diff --git a/src/tests/Loader/classloader/regressions/181424/test5.il b/src/tests/Loader/classloader/regressions/181424/test5.il deleted file mode 100644 index f3fbfb0f877c35..00000000000000 --- a/src/tests/Loader/classloader/regressions/181424/test5.il +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -.assembly extern System.Console { } -.assembly extern xunit.core {} -.assembly test5{} -.assembly extern test5{} -.assembly extern mscorlib{} - -// In this module, we define types Foo and Bar. We'll use PEHacker to postprocess -// the executable that results from this, changing the name of Bar to Foo. Then, -// we have two entirely different types that happen to have the same name in the -// same namespace. -// -// In Main, we have three tests. -// The first two effective load types Foo and (what originally was:) Bar. -// TypeDefs are used here, so the IL code will actually contain tokens to the -// respective types. This works fine. -// But in the third test, we try to use Foo through a TypeRef whose resolution scope -// is 'this' assembly, thereby trying to load type Foo by name. But this is ambiguous, -// since both types (after our postprocessing) have the name Foo. Originally, the runtime -// just took the first one it found, giving us no way to load the second one by name. -// Thus, VSWhidbey 181424 was filed to disallow this scenario. -// We expected a TypeLoadException now when trying to load two types that have the same -// name in the same namespace. - -.class public Bar extends [mscorlib]System.Object{ - .field public int32 i - .method public specialname instance void .ctor(){ - ldarg.0 - call instance void [mscorlib]System.Object::.ctor() - ldarg.0 - ldc.i4.s 2 - stfld int32 Bar::i - ret - } -} - -.class public Foo extends [mscorlib]System.Object{ - .field public int32 i - .method public specialname instance void .ctor(){ - ldarg.0 - call instance void [mscorlib]System.Object::.ctor() - ldarg.0 - ldc.i4.s 3 - stfld int32 Foo::i - ret - } -} - -.method public static int32 Main(){ - .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( - 01 00 00 00 - ) - .entrypoint - .locals init(int32 retVal) - // there's no way to get to Foo through TypeRef - ldc.i4 100 // default pass - stloc retVal - newobj instance void Foo::.ctor() - ldfld int32 Foo::i - ldc.i4.s 3 - beq NEXT1 - ldc.i4 101 - stloc retVal - ldstr "FAIL: (Type 0x02000003) i != 3" - call void [System.Console]System.Console::WriteLine(string) - - NEXT1: - newobj instance void Bar::.ctor() - ldfld int32 Bar::i - ldc.i4.s 2 - beq NEXT2 - ldc.i4 101 - stloc retVal - ldstr "FAIL: (Type 0x02000002) i != 2" - call void [System.Console]System.Console::WriteLine(string) - - NEXT2: - newobj instance void [test5]Foo::.ctor() - ldfld int32 [test5]Foo::i - ldc.i4.s 3 - beq NEXT3 - ldc.i4 101 - stloc retVal - ldstr "FAIL: (TypeRef to Foo) i != 3" - call void [System.Console]System.Console::WriteLine(string) - - NEXT3: - ldloc retVal - ldc.i4 100 - bne.un END - ldstr "PASS" - call void [System.Console]System.Console::WriteLine(string) - - END: - ldloc retVal - ret -} diff --git a/src/tests/Loader/classloader/regressions/181424/test5.ilproj b/src/tests/Loader/classloader/regressions/181424/test5.ilproj deleted file mode 100644 index 4043cb2935bd77..00000000000000 --- a/src/tests/Loader/classloader/regressions/181424/test5.ilproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - true - 1 - - - - -