This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put default interfaces behind a define (#15358)
This is needed so that we can turn default interfaces off in release branches. I can't find a central location where the PRERELEASE flag could be defined because native and managed builds seem to be completely disconnected. To limit the risk of only flipping the flag in one build type, I'm adding a test that verifies being able to load an interface with default methods matches what RuntimeFeature says.
- Loading branch information
1 parent
d714acd
commit 809b8f7
Showing
16 changed files
with
146 additions
and
118 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
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
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
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
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
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
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
73 changes: 73 additions & 0 deletions
73
tests/src/baseservices/compilerservices/RuntimeFeature/DefaultImplementationsOfInterfaces.il
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,73 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
// | ||
// Verifies that RuntimeFeature::IsSupported("DefaultImplementationsOfInterfaces") matches reality. | ||
// This needs to succeed no matter whether default interfaces are supported. | ||
// | ||
|
||
.assembly extern System.Runtime{} | ||
.assembly DefaultImplementationsOfInterfaces{} | ||
|
||
.class interface private abstract auto ansi DefaultInterface | ||
{ | ||
.method public hidebysig newslot virtual | ||
instance void Method() cil managed | ||
{ | ||
.maxstack 8 | ||
ret | ||
} | ||
} | ||
|
||
.method private hidebysig static void TryLoadDefaultInterface() cil managed noinlining | ||
{ | ||
.maxstack 8 | ||
ldtoken DefaultInterface | ||
call class [System.Runtime]System.Type [System.Runtime]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) | ||
callvirt instance string [System.Runtime]System.Object::ToString() | ||
pop | ||
ret | ||
} | ||
|
||
.method private hidebysig static bool SupportsDefaultInterfaces() cil managed | ||
{ | ||
.maxstack 1 | ||
.try | ||
{ | ||
call void TryLoadDefaultInterface() | ||
leave.s Supports | ||
|
||
} | ||
catch [System.Runtime]System.TypeLoadException | ||
{ | ||
pop | ||
leave.s DoesNotSupport | ||
|
||
} | ||
Supports: | ||
ldc.i4.1 | ||
ret | ||
|
||
DoesNotSupport: | ||
ldc.i4.0 | ||
ret | ||
} | ||
|
||
.method private hidebysig static int32 | ||
Main() cil managed | ||
{ | ||
.entrypoint | ||
.maxstack 2 | ||
ldstr "DefaultImplementationsOfInterfaces" | ||
call bool [System.Runtime]System.Runtime.CompilerServices.RuntimeFeature::IsSupported(string) | ||
call bool SupportsDefaultInterfaces() | ||
beq Good | ||
|
||
ldc.i4.m1 | ||
ret | ||
|
||
Good: | ||
ldc.i4 100 | ||
ret | ||
} |
Oops, something went wrong.