Skip to content

[API Proposal]: Add GetDeclaringType to PropertyDefinition and EventDefinition #60380

Closed
@MichalStrehovsky

Description

@MichalStrehovsky

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

namespace System.Reflection.Metadata
{
    public struct PropertyDefinition
    {
        public TypeDefinitionHandle GetDeclaringType();
    }

    public struct EventDefinition
    {
        public TypeDefinitionHandle GetDeclaringType();
    }
}

API Usage

PropertyDefinition someProperty = ...;
var owningType = someProperty.GetDeclaringType();

Risks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedAPI was approved in API review, it can be implementedarea-System.Reflection.Metadatain-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions