microsoft / microsoft/CsWin32

Add operators and override methods to PROPERTYKEY

Open
#729 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
2.5k
Forks
123
Avg merge
1d 3h
Merged PRs (30d)
9

Description

Is your feature request related to a problem? Please describe.
I want to implement the UIRibbon in C# with the help from CsWin32. Here I need the PROPERTYKEY. In the UIRibbon I have to compare the values of PROPERTYKEYs. But the actual implementation had no features for comparing.

Describe the solution you'd like
Something like the following would be useful:


        public static bool operator ==(PROPERTYKEY left, PROPERTYKEY right) =>
             ((left.fmtid == right.fmtid) && (left.pid == right.pid));

        public static bool operator !=(PROPERTYKEY left, PROPERTYKEY right) => !(left == right);

        public bool Equals(PROPERTYKEY other) => this == other;

        public override bool Equals(object obj) => obj is PROPERTYKEY other && this.Equals(other);

        public override int GetHashCode() => (fmtid.GetHashCode() ^ pid.GetHashCode());

        public override string ToString() =>
             "PROPERTYKEY: " + fmtid.ToString() + ":" + pid.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named; start by locating the PROPERTYKEY definition in the CsWin32 source and inspect nearby generated supporting types for comparison conventions. Add the requested operators and overrides for PROPERTYKEY, then run the relevant project tests or build to verify the type compiles and comparisons behave as specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.