cloudevents / cloudevents/sdk-csharp
CloudEventAttribute should implement equality operators
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 334
- Forks
- 88
- Avg merge
- 7m
- Merged PRs (30d)
- 2
Description
CloudEvent.GetPopulatedAttributes() returns an IEnumerable<KeyValuePair<CloudEventAttribute, object>> which is actually a bit odd. You'd think it would be usable as a dictionary, but I'm guessing there might be a cause where the same attribute names appear more than once, but in my case, I know they won't, so I tried to create a dictionary from it, but unfortunately, since the Key is CloudEventAttribute, indexing it requires equality operators. Even if I simply search the list of KVPs, it makes it awkward to find an attribute that may or may not exist (SingleOrDefault for example, because default is a KVP with null values), so I think I have to loop on it the old fashioned way.
I find the interface in general to be very awkward, but I think some comparison operators would be helpful, or even a helper method that can grab the attribute and/or value by name. There's already a method to get the attribute, there's just no value in it; it's only the name. Maybe there's some other incantation I'm not seeing; the documentation on extension attributes is lacking in general.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating CloudEventAttribute, CloudEvent.GetPopulatedAttributes(), and the existing method that retrieves an attribute. Review nearby tests and the extension-attribute documentation, then define the expected lookup or equality behavior from the issue. Done means callers can reliably identify an optional attribute without awkward KVP handling, with coverage for missing and repeated names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100