This repository was 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
Detect ByRefLike types using attribute #15745
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
186 changes: 186 additions & 0 deletions
186
tests/src/Loader/classloader/regressions/GitHub_11371/Negative_ByRefLikeType.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,186 @@ | ||
// 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. | ||
|
||
.assembly extern System.Console { } | ||
.assembly extern System.Runtime { } | ||
.assembly Negative_ByRefLikeType { } | ||
|
||
.class sequential ansi sealed beforefieldinit MyByRefLikeType | ||
extends [System.Runtime]System.ValueType | ||
{ | ||
.custom instance void [System.Runtime]System.Runtime.CompilerServices.IsByRefLikeAttribute::.ctor() = ( 01 00 00 00 ) | ||
} | ||
|
||
.class sequential ansi sealed beforefieldinit ByRefLikeStaticField | ||
{ | ||
.field private static valuetype MyByRefLikeType s | ||
} | ||
|
||
.class sequential ansi sealed beforefieldinit ByRefLikeFieldInNonValueType | ||
{ | ||
.field private valuetype MyByRefLikeType f | ||
} | ||
|
||
.class sequential ansi sealed beforefieldinit ByRefLikeFieldInNonByRefLikeType | ||
{ | ||
.field private valuetype MyByRefLikeType f | ||
} | ||
|
||
.class public auto ansi beforefieldinit Test | ||
extends [System.Runtime]System.Object | ||
{ | ||
.method private hidebysig static void ByRefLikeBoxing() cil managed | ||
{ | ||
.maxstack 1 | ||
.locals init (valuetype MyByRefLikeType V_0) | ||
ldloc.0 | ||
box valuetype MyByRefLikeType | ||
pop | ||
ret | ||
} | ||
|
||
.method private hidebysig static void ByRefLikeStaticField() cil managed | ||
{ | ||
.maxstack 1 | ||
ldsfld valuetype MyByRefLikeType ByRefLikeStaticField::s | ||
pop | ||
ret | ||
} | ||
|
||
.method private hidebysig static void ByRefLikeFieldInNonValueType() cil managed | ||
{ | ||
.maxstack 1 | ||
ldnull | ||
ldfld valuetype MyByRefLikeType ByRefLikeFieldInNonValueType::f | ||
pop | ||
ret | ||
} | ||
|
||
.method private hidebysig static void ByRefLikeFieldInNonByRefLikeType() cil managed | ||
{ | ||
.maxstack 1 | ||
.locals init (valuetype ByRefLikeFieldInNonByRefLikeType V_0) | ||
ldloc.0 | ||
ldfld valuetype MyByRefLikeType ByRefLikeFieldInNonValueType::f | ||
pop | ||
ret | ||
} | ||
|
||
.method private hidebysig static void ByRefLikeArray() cil managed | ||
{ | ||
.maxstack 1 | ||
ldc.i4.1 | ||
newarr valuetype MyByRefLikeType | ||
pop | ||
ret | ||
} | ||
|
||
.method private hidebysig static void ByRefLikeGenericInstantiation() cil managed | ||
{ | ||
.maxstack 1 | ||
newobj instance void class [System.Runtime]System.Collections.Generic.List`1<valuetype MyByRefLikeType>::.ctor() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-empty stack but returns void? |
||
pop | ||
ret | ||
} | ||
|
||
.method public hidebysig static int32 Main() cil managed | ||
{ | ||
.entrypoint | ||
.maxstack 1 | ||
|
||
ldstr "ByRefLikeBoxing" | ||
call void [System.Console]System.Console::WriteLine(string) | ||
.try | ||
{ | ||
call void Test::ByRefLikeBoxing() | ||
leave TestFailed | ||
} | ||
catch [System.Runtime]System.InvalidProgramException | ||
{ | ||
pop | ||
leave ByRefLikeBoxing_Done | ||
} | ||
ByRefLikeBoxing_Done: | ||
|
||
ldstr "ByRefLikeStaticField" | ||
call void [System.Console]System.Console::WriteLine(string) | ||
.try | ||
{ | ||
call void Test::ByRefLikeStaticField() | ||
leave TestFailed | ||
} | ||
catch [System.Runtime]System.TypeLoadException | ||
{ | ||
pop | ||
leave ByRefLikeStaticField_Done | ||
} | ||
ByRefLikeStaticField_Done: | ||
|
||
ldstr "ByRefLikeFieldInNonValueType" | ||
call void [System.Console]System.Console::WriteLine(string) | ||
.try | ||
{ | ||
call void Test::ByRefLikeFieldInNonValueType() | ||
leave TestFailed | ||
} | ||
catch [System.Runtime]System.TypeLoadException | ||
{ | ||
pop | ||
leave ByRefLikeFieldInNonValueType_Done | ||
} | ||
ByRefLikeFieldInNonValueType_Done: | ||
|
||
ldstr "ByRefLikeFieldInNonByRefLikeType" | ||
call void [System.Console]System.Console::WriteLine(string) | ||
.try | ||
{ | ||
call void Test::ByRefLikeFieldInNonByRefLikeType() | ||
leave TestFailed | ||
} | ||
catch [System.Runtime]System.TypeLoadException | ||
{ | ||
pop | ||
leave ByRefLikeFieldInNonByRefLikeType_Done | ||
} | ||
ByRefLikeFieldInNonByRefLikeType_Done: | ||
|
||
ldstr "ByRefLikeArray" | ||
call void [System.Console]System.Console::WriteLine(string) | ||
.try | ||
{ | ||
call void Test::ByRefLikeArray() | ||
leave TestFailed | ||
} | ||
catch [System.Runtime]System.TypeLoadException | ||
{ | ||
pop | ||
leave ByRefLikeArray_Done | ||
} | ||
ByRefLikeArray_Done: | ||
|
||
ldstr "ByRefLikeGenericInstantiation" | ||
call void [System.Console]System.Console::WriteLine(string) | ||
.try | ||
{ | ||
call void Test::ByRefLikeGenericInstantiation() | ||
leave TestFailed | ||
} | ||
catch [System.Runtime]System.TypeLoadException | ||
{ | ||
pop | ||
leave ByRefLikeGenericInstantiation_Done | ||
} | ||
ByRefLikeGenericInstantiation_Done: | ||
|
||
ldstr "All Tests Passed" | ||
call void [System.Console]System.Console::WriteLine(string) | ||
ldc.i4.s 100 | ||
ret | ||
TestFailed: | ||
ldstr "Test Failed" | ||
call void [System.Console]System.Console::WriteLine(string) | ||
ldc.i4.1 | ||
ret | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/src/Loader/classloader/regressions/GitHub_11371/Negative_ByRefLikeType.ilproj
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,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> | ||
<PropertyGroup> | ||
<AssemblyName>Negative_ByRefLikeType</AssemblyName> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> | ||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<OutputType>Exe</OutputType> | ||
<CLRTestKind>BuildAndRun</CLRTestKind> | ||
<CLRTestPriority>0</CLRTestPriority> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Negative_ByRefLikeType.il" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> | ||
</ItemGroup> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> | ||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe update the comment above (
// Inherit IsByRefLike characteristic from fields
) since we're not inheriting it anymore, but merely checking?