CloudEventAttribute should implement equality operators
See original GitHub issueCloudEvent.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.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Okay. I’ll keep going with the
IEqualityComparer
PR then. That would allow something like:We could add extension methods for that easily without a new collection type. Anyway, will look more carefully on Monday.