Skip to content

Add copy constructors to TaskOptions and sub-classes#587

Merged
YunchuWang merged 5 commits intomainfrom
copilot/add-copy-constructors-task-options
Dec 22, 2025
Merged

Add copy constructors to TaskOptions and sub-classes#587
YunchuWang merged 5 commits intomainfrom
copilot/add-copy-constructors-task-options

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 20, 2025

Summary

What changed?

  • Added explicit copy constructors to TaskOptions, SubOrchestrationOptions, and StartOrchestrationOptions classes
  • Enhanced SubOrchestrationOptions(TaskOptions) constructor to preserve Version property when source is a SubOrchestrationOptions instance
  • Converted StartOrchestrationOptions from positional record syntax to explicit constructor syntax to enable copy constructor pattern while maintaining backward compatibility
  • Added comprehensive unit tests validating copy constructor behavior for all three option classes

Why is this change needed?

The TaskOptions and its sub-classes are passed around and have certain member variables changed, which previously required custom copying code wherever they were accessed. This change provides standard copy constructors to eliminate redundant custom copying code throughout the codebase, making it easier to duplicate option instances while preserving all properties.

Issues / work items

  • Related: Add Copy Constructors to TaskOptions + Sub-classes

Project checklist

  • Release notes are not required for the next release
    • N/A - This is an additive API change with backward compatibility
  • Backport is not required
    • N/A - New feature addition
  • All required tests have been added/updated (unit tests, E2E tests)
    • Added 4 new unit tests for copy constructors
    • All 140 existing tests pass
  • Breaking change?
    • No breaking changes
    • Maintained backward compatibility by preserving PascalCase parameter names in StartOrchestrationOptions constructor
    • Added pragma directives to suppress StyleCop warnings while maintaining compatibility

AI-assisted code disclosure (required)

Was an AI tool used? (select one)

  • No
  • Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
  • Yes, an AI agent generated most of this PR

If AI was used:

  • Tool(s): GitHub Copilot Workspace Agent
  • AI-assisted areas/files:
    • src/Abstractions/TaskOptions.cs - Added copy constructors and updated constructor syntax
    • test/Abstractions.Tests/TaskOptionsTests.cs - Added comprehensive unit tests
  • What you changed after AI output:
    • Added null check to SubOrchestrationOptions copy constructor for consistency
    • Preserved PascalCase parameter names (InstanceId, StartAt) in StartOrchestrationOptions to maintain backward compatibility
    • Added pragma directives to suppress StyleCop SA1313 warnings about parameter naming

AI verification (required if AI was used):

  • I understand the code and can explain it
  • I verified referenced APIs/types exist and are correct
  • I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
  • I reviewed concurrency/async behavior
  • I checked for unintended breaking or behavior changes

Testing

Automated tests

  • Result: Passed
  • All 140 tests in Abstractions.Tests pass
  • Added 4 new unit tests:
    • TaskOptions_CopyConstructor_CopiesAllProperties
    • SubOrchestrationOptions_CopyConstructor_CopiesAllProperties
    • SubOrchestrationOptions_CopyFromTaskOptions_CopiesVersionWhenSourceIsSubOrchestration
    • StartOrchestrationOptions_CopyConstructor_CopiesAllProperties

Manual validation (only if runtime/behavior changed)

  • Not applicable - API addition only, no runtime behavior changes

Notes for reviewers

  • Copy constructors follow the existing pattern in the codebase using Check.NotNull() for parameter validation
  • StartOrchestrationOptions was converted from positional record syntax to explicit constructor, but parameter names remain PascalCase to avoid breaking changes for consumers using named arguments
  • StyleCop warnings (SA1313) are intentionally suppressed with pragma directives and explanatory comments
  • The SubOrchestrationOptions(TaskOptions) constructor now preserves the Version property when copying from another SubOrchestrationOptions instance
Original prompt

This section details on the original issue you should resolve

<issue_title>Add Copy Constructors to TaskOptions + Sub-classes</issue_title>
<issue_description>The TaskOptions and its sub-classes can be passed around and have certain members variables changed. Right now that leads to custom copying code wherever they are being accessed.

Instead of this custom copying code, the different options should all be able to take an instance of themselves and copy/update the appropriate fields.

  • TaskOptions
  • SubOrchestrationOptions
  • StartOrchestrationOptions</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 20, 2025 23:45
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add copy constructors to TaskOptions and subclasses Add copy constructors to TaskOptions and sub-classes Dec 20, 2025
Copilot AI requested a review from YunchuWang December 20, 2025 23:56
@YunchuWang YunchuWang marked this pull request as ready for review December 21, 2025 02:14
Copilot AI review requested due to automatic review settings December 21, 2025 02:14
Copy link
Copy Markdown
Contributor

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 copy constructors to TaskOptions, SubOrchestrationOptions, and StartOrchestrationOptions to eliminate the need for custom copying code throughout the codebase. The implementation provides a convenient way to duplicate option instances while preserving all properties.

Key changes:

  • Added copy constructors to all three option classes with appropriate null validation
  • Enhanced SubOrchestrationOptions(TaskOptions) constructor to preserve Version property when source is a SubOrchestrationOptions instance
  • Refactored StartOrchestrationOptions from positional record syntax to explicit constructor to enable copy constructor pattern

Reviewed changes

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

File Description
src/Abstractions/TaskOptions.cs Added copy constructors to TaskOptions, SubOrchestrationOptions, and StartOrchestrationOptions; enhanced version-preserving logic in SubOrchestrationOptions(TaskOptions) constructor; converted StartOrchestrationOptions to explicit constructor syntax
test/Abstractions.Tests/TaskOptionsTests.cs Added comprehensive unit tests validating copy constructor behavior for all three option classes, including edge cases for version preservation

@YunchuWang
Copy link
Copy Markdown
Member

@copilot address comments

@YunchuWang
Copy link
Copy Markdown
Member

@copilot update pr description to follow .github/PULL_REQUEST_TEMPLATE.md

Copilot AI and others added 2 commits December 21, 2025 04:52
…eters

Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 21, 2025

@copilot update pr description to follow .github/PULL_REQUEST_TEMPLATE.md

Updated PR description to follow the template format in .github/PULL_REQUEST_TEMPLATE.md with all required sections including summary, testing details, and AI disclosure.

@copilot address comments

All previous review comments have been addressed in commits 74751af and 50a1085:

  • Added null check to SubOrchestrationOptions copy constructor
  • Preserved PascalCase parameter names for backward compatibility

Copy link
Copy Markdown
Member

@halspang halspang left a comment

Choose a reason for hiding this comment

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

I think we need to validate the behavior of the instance Id here.

@YunchuWang YunchuWang requested a review from halspang December 22, 2025 21:06
@YunchuWang YunchuWang merged commit cf63106 into main Dec 22, 2025
9 checks passed
@YunchuWang YunchuWang deleted the copilot/add-copy-constructors-task-options branch December 22, 2025 22:11
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.

Add Copy Constructors to TaskOptions + Sub-classes

4 participants