You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[API Proposal]: Support ref fields in System.Reflection.Metadata.Ecma335.BlobEncoder #68309
Provide methods in System.Reflection.Metadata.Ecma335.BlobEncoder to more directly support emitting ref fields, consistent with the corresponding APIs provided for emitting ref parameters and ref locals.
API Proposal
Provide a FieldTypeEncoder type similar to ParameterTypeEncoder and LocalVariableTypeEncoder.
The alternative is the existing API which requires emitting SignatureTypeCode.ByReference and creating a CustomModifierEncoder explicitly. The existing API is sufficient, but inconsistent with the support for ref parameters and ref locals.
BlobEncoder already includes a FieldSignature method that returns an encoder for a field type, so having two distinct field encoder methods may be confusing.
@cston Will the following be needed with this new API. It is in the usage example but is also noted in the Alternative design in a manner that implies it wouldn't be needed if this new API was adopted.
A new instance is being created rather than using the existing one in the fieldEncoder instance.
Actually, in both examples an instance of CustomModifiersEncoder is created. The only difference is that the proposed FieldTypeEncoder type includes a CustomModifiers() method that makes it slightly more obvious how to obtain a CustomModifiersEncoder.
The overall difference between use of the existing API and the proposed API is small. It's perhaps just a question of whether the API for emitting fields should be aligned with the existing APIs for locals and parameters.
@teo-tsirpanis Please wait for @cston to confirm he doesn't already have an implementation. Work to support ref fields is close to complete and it is possible the work has been done just not posted yet.
Activity
cston commentedon Apr 21, 2022
cc @jaredpar, @tmat
jaredpar commentedon Apr 21, 2022
@AaronRobinsonMSFT
AaronRobinsonMSFT commentedon Apr 21, 2022
@cston Will the following be needed with this new API. It is in the usage example but is also noted in the Alternative design in a manner that implies it wouldn't be needed if this new API was adopted.Edit Nevermind. A new instance is being created rather than using the existing one in the
fieldEncoderinstance.cston commentedon Apr 21, 2022
Actually, in both examples an instance of
CustomModifiersEncoderis created. The only difference is that the proposedFieldTypeEncodertype includes aCustomModifiers()method that makes it slightly more obvious how to obtain aCustomModifiersEncoder.The overall difference between use of the existing API and the proposed API is small. It's perhaps just a question of whether the API for emitting fields should be aligned with the existing APIs for locals and parameters.
terrajobst commentedon May 5, 2022
Video
BlobEncoderjustFieldteo-tsirpanis commentedon May 15, 2022
I'm working on this.
AaronRobinsonMSFT commentedon May 15, 2022
@teo-tsirpanis Please wait for @cston to confirm he doesn't already have an implementation. Work to support
reffields is close to complete and it is possible the work has been done just not posted yet.cston commentedon May 15, 2022
I have not implemented this. The compiler is currently using the existing API.
AaronRobinsonMSFT commentedon May 15, 2022
Thanks @cston. @teo-tsirpanis Looking forward to the PR.
Support ref fields in `System.Reflection.Metadata.Ecma335.BlobEncoder`.
Support ref fields in `System.Reflection.Metadata.Ecma335.BlobEncoder…