Skip to content

Include specversion in GetPopulatedAttributes - #374

Open
authuir wants to merge 1 commit into
cloudevents:mainfrom
authuir:include-specversion-in-populated-attributes
Open

Include specversion in GetPopulatedAttributes#374
authuir wants to merge 1 commit into
cloudevents:mainfrom
authuir:include-specversion-in-populated-attributes

Conversation

@authuir

@authuir authuir commented Aug 19, 2026

Copy link
Copy Markdown

Summary

  • include specversion and its canonical value in CloudEvent.GetPopulatedAttributes()
  • keep existing AMQP, HTTP, Kafka, Avro, JSON, and Protobuf wire output unchanged by skipping the version where it is already serialized separately
  • add a regression test and update the test event clone helper for the read-only version attribute

This aligns attribute enumeration with the Java SDK, where getAttributeNames() includes the populated specversion context attribute.

Fixes #373

Testing

  • git diff --check
  • VS Code C# diagnostics for all changed files

The focused CloudEventTest run could not start locally because NuGet restore repeatedly timed out connecting to api.nuget.org (SSL transport error: socket not connected).

Signed-off-by: Yu Zhou <zhouyu@microsoft.com>
@jskeet

jskeet commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

As it stands, this is a breaking change - the method is explicitly documented not to include the version attribute. The version attribute is "special" in various other ways - for example, it's read-only, and you can't access it via the indexer.

If you really, really think there ought to be a way of obtaining all the attributes including the version (which is frankly easy enough to do at the caller side where necessary) we could introduce a new overload:

public IEnumerable<KeyValuePair<CloudEventAttribute, object>> GetPopulatedAttributes(bool includeSpecVersionAttribute)

The existing method could just return GetPopulatedAttributes(false). That would also mean that none of the other code needs to change.

Personally I'm not really convinced it's worth doing this, but that would at least be much better than a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include specversion in CloudEvent.GetPopulatedAttributes

2 participants