Skip to content

Conversation

muhammad-othman
Copy link
Member

Description

  • Updated EventStreamPublisherMarshaller.tt to support publishing CBOR payloads.
  • Updated EventStreamOutputGenerator.tt to support reading CBOR response.

Motivation and Context

DOTNET-8164

Testing

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@GarrettBeatty GarrettBeatty requested a review from Copilot August 12, 2025 23:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for CBOR (Concise Binary Object Representation) protocol to event streaming functionality in the AWS SDK for .NET, enabling the generation of event stream publishers and consumers that can handle CBOR-encoded payloads.

  • Introduces CBOR-specific marshalling and unmarshalling for event stream events
  • Updates code generators to produce CBOR-compatible event stream publishers and output generators
  • Adds new utility methods for converting event stream messages to appropriate contexts

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
EventStreamUtils.cs Adds utility method to convert event stream messages to generic streams
IEventStreamPublisher.cs Changes EventStreamRequest access modifier from private to protected
Member.cs Updates type unmarshaller instantiation logic for CBOR protocol support
StructureGenerator.tt Adds CBOR namespace imports and fixes event interface inheritance
EventStreamOutputGenerator.tt Implements CBOR support for event stream output generation
EventStreamPublisherMarshaller.tt Adds CBOR marshalling support for event stream publishers
JsonRPCStructureUnmarshaller.tt Fixes null reference check for event payload members
CborStructureUnmarshaller.tt Fixes event payload member handling and structure cleanup
CborSimpleTypeUnmarshaller.cs Adds new DateTime unmarshaller for epoch milliseconds
CborEventStreamPublisher.cs New base class for CBOR event stream publishers

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -611,7 +611,7 @@ public bool IsEventInputStream
{
get
{
if (this.ModelShape.IsEventStream && this.model.Operations.FirstOrDefault(x => string.Equals(this.OwningShape.Name, x.RequestStructure.Name)) != null)
if (this.ModelShape.IsEventStream && this.model.Operations.FirstOrDefault(x => string.Equals(this.OwningShape.Name, x.RequestStructure?.Name)) != null)
Copy link
Preview

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This null-conditional operator may introduce inconsistent behavior. If RequestStructure is null, the string.Equals will never match, potentially changing the logic from the original code which would have thrown a NullReferenceException.

Suggested change
if (this.ModelShape.IsEventStream && this.model.Operations.FirstOrDefault(x => string.Equals(this.OwningShape.Name, x.RequestStructure?.Name)) != null)
if (this.ModelShape.IsEventStream && this.model.Operations.FirstOrDefault(x => string.Equals(this.OwningShape.Name, x.RequestStructure.Name)) != null)

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that because I faced a an operation without a request structure in a testing service.

}
reader.ReadEndMap();
Copy link
Preview

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reader.ReadEndMap() call has been moved outside the conditional block, but it should only be called when a map was actually started. This could cause issues when handling event structures with explicit payload members.

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it wasn't, the duplicate if conditions was merged in one condition.

Copy link
Contributor

@peterrsongg peterrsongg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looked at the generated branch. looks good.

Copy link
Contributor

@ashishdhingra ashishdhingra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good at high level. Nice work on modifying T4 files.

@muhammad-othman muhammad-othman merged commit 50bb85d into cbor-protocol Aug 14, 2025
1 check passed
@dscpinheiro dscpinheiro deleted the muhamoth/DOTNET-8164-cbor-event-streaming-support branch August 15, 2025 20:50
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.

3 participants