Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadatatoken override to SymbolMethod #54656

Merged

Conversation

KevinRansom
Copy link
Member

Fixes #53300 - RefEmit SymbolMethod should probably have a Metadata token override

The MetadataToken base implementation of MetadataToken throws an exception. This provides an implementation that merely returns m_token to get a token for the symbol.

Originally the token was retrieved using the GetToken() method removed here: b72b13e#diff-0db30e8f862ac0489421d919d343654824ac89bd001e8fb50e3c54cb53862b85L138

m_token is passed in to the SymbolMethod constructor

Without Fix

C:\kevinransom\runtime\artifacts\bin\testhost\net6.0-windows-Release-x64>dotnet C:\kevinransom\fsharp\artifacts\bin\fsi\Release\net5.0\fsi.dll

Microsoft (R) F# Interactive version 11.4.2.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> let arr = Array2D.create 3 4 0
- let _ = Array2D.get arr 0 0;;


error FS0193: internal error: Operation is not valid due to the current state of the object.

>

With Fix

C:\kevinransom\runtime\artifacts\bin\testhost\net6.0-windows-Release-x64>dotnet C:\kevinransom\fsharp\artifacts\bin\fsi\Release\net5.0\fsi.dll

Microsoft (R) F# Interactive version 11.4.2.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> let arr = Array2D.create 3 4 0
- let _ = Array2D.get arr 0 0;;
val arr : int [,] = [[0; 0; 0; 0]
                     [0; 0; 0; 0]
                     [0; 0; 0; 0]]

@KevinRansom
Copy link
Member Author

/cc @jkotas @vzarytovskii

@jkotas
Copy link
Member

jkotas commented Jun 24, 2021

Could you please also augment

private void VerifyGetArrayMethod(ModuleBuilder module, Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
to validate that the MethodToken property returns a value that looks like a method token?

@jkotas
Copy link
Member

jkotas commented Jun 24, 2021

cc @steveharter Fix for a regression introduced by #43330

@jkotas jkotas merged commit 32b58a1 into dotnet:main Jun 26, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jul 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

RefEmit SymbolMethod should probably have a Metadata token override
2 participants