forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide More Detailed Information in System.TypeLoadException for Inc…
…orrect MethodImplAttribute Marking (dotnet#95833) * Provide More Detailed Information in System.TypeLoadException for Incorrect MethodImplAttribute Marking * fix failing tests * disable tests on mono
- Loading branch information
1 parent
5dc63a6
commit 80245dd
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/tests/Loader/classloader/MethodImpl/InternalMethodImplTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using Xunit; | ||
|
||
public class InternalMethodImplTest | ||
{ | ||
[Fact, SkipOnMono("the error message is specific to coreclr")] | ||
public static int TypeLoadExceptionMessageContainsMethodNameWhenInternalCallOnlyMethodIsCalled() | ||
{ | ||
if (TestLibrary.Utilities.IsNativeAot) | ||
{ | ||
return 100; // unsupported on NativeAOT | ||
} | ||
|
||
try | ||
{ | ||
new F1(); | ||
return -1; | ||
} | ||
catch (TypeLoadException ex) | ||
{ | ||
return ex.Message.Contains("Internal call method 'F2.Foo' with non-zero RVA.") ? 100 : -1; | ||
} | ||
catch (Exception ex) | ||
{ | ||
return -1; | ||
} | ||
} | ||
} | ||
|
||
class F1 | ||
{ | ||
public F1() | ||
{ | ||
var f2 = new F2(); | ||
} | ||
} | ||
|
||
class F2 | ||
{ | ||
[MethodImpl(MethodImplOptions.InternalCall)] | ||
public void Foo() | ||
{ | ||
|
||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/tests/Loader/classloader/MethodImpl/InternalMethodImplTest.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<Compile Include="InternalMethodImplTest.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> | ||
</ItemGroup> | ||
</Project> |