-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
[API Proposal]: Add GetDeclaringType to PropertyDefinition and EventDefinition #60380
Comments
Tagging subscribers to this area: @buyaa-n Issue DetailsBackground and motivationS.R.Metadata provides a way to get the owning type of fields and methods. It doesn't provide an API to get owning type of properties and events. I think it should be exposed for parity. The lookup strategy is similar (a binary search in one of the tables). API Proposalnamespace System.Reflection.Metadata
{
public struct PropertyDefinition
{
public TypeDefinitionHandle GetDeclaringType();
}
public struct EventDefinition
{
public TypeDefinitionHandle GetDeclaringType();
}
} API UsagePropertyDefinition someProperty = ...;
var owningType = someProperty.GetDeclaringType(); RisksNo response
|
Cc @tmat for a S.R.Metadata new API opinion. |
Moving this to 8.0, @MichalStrehovsky please let us know if you need it in 7.0 |
API looks good to me. |
namespace System.Reflection.Metadata;
public partial struct PropertyDefinition
{
public TypeDefinitionHandle GetDeclaringType();
}
public partial struct EventDefinition
{
public TypeDefinitionHandle GetDeclaringType();
} |
I took the liberty to implement this issue (see After the implementation quite a few tests fail. I think I did something wrong with the offset calculation. Can anyone help me out here, or does anyone see where the error lies? I am grateful for any help. |
I didn't look in detail yet, but at minimum there are two copy-paste bugs in |
Background and motivation
S.R.Metadata provides a way to get the owning type of fields and methods. It doesn't provide an API to get owning type of properties and events. I think it should be exposed for parity.
The lookup strategy is similar (a binary search in one of the tables).
API Proposal
API Usage
Risks
No response
The text was updated successfully, but these errors were encountered: