-
Notifications
You must be signed in to change notification settings - Fork 52
Add version to TaskName #416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| namespace Microsoft.DurableTask; | ||
|
|
||
| /// <summary> | ||
| /// The version of a durable task. | ||
| /// </summary> | ||
| public readonly struct TaskVersion : IEquatable<TaskVersion> | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="TaskVersion"/> struct. | ||
| /// </summary> | ||
| /// <param name="version">The version of the task. Providing <c>null</c> will result in the default struct.</param> | ||
| public TaskVersion(string version) | ||
| { | ||
| if (version == null) | ||
| { | ||
| this.Version = null!; | ||
| } | ||
| else | ||
| { | ||
| this.Version = version; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the version of a task. | ||
| /// </summary> | ||
| public string Version { get; } | ||
|
|
||
| /// <summary> | ||
| /// Implicitly converts a <see cref="TaskVersion"/> into a <see cref="string"/> of the <see cref="Version"/> property value. | ||
| /// </summary> | ||
| /// <param name="value">The <see cref="TaskVersion"/> to be converted into a <see cref="string"/>.</param> | ||
| public static implicit operator string(TaskVersion value) => value.Version; | ||
|
|
||
| /// <summary> | ||
| /// Implicitly converts a <see cref="string"/> into a <see cref="TaskVersion"/>. | ||
| /// </summary> | ||
| /// <param name="value">The <see cref="string"/> to convert into a <see cref="TaskVersion"/>.</param> | ||
| public static implicit operator TaskVersion(string value) => new TaskVersion(value); | ||
|
|
||
| /// <summary> | ||
| /// Compares two <see cref="TaskVersion"/> structs for equality. | ||
| /// </summary> | ||
| /// <param name="a">The first <see cref="TaskVersion"/> to compare.</param> | ||
| /// <param name="b">The second <see cref="TaskVersion"/> to compare.</param> | ||
| /// <returns><c>true</c> if the two <see cref="TaskVersion"/> objects are equal; otherwise <c>false</c>.</returns> | ||
| public static bool operator ==(TaskVersion a, TaskVersion b) | ||
| { | ||
| return a.Equals(b); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Compares two <see cref="TaskVersion"/> structs for inequality. | ||
| /// </summary> | ||
| /// <param name="a">The first <see cref="TaskVersion"/> to compare.</param> | ||
| /// <param name="b">The second <see cref="TaskVersion"/> to compare.</param> | ||
| /// <returns><c>false</c> if the two <see cref="TaskVersion"/> objects are equal; otherwise <c>true</c>.</returns> | ||
| public static bool operator !=(TaskVersion a, TaskVersion b) | ||
| { | ||
| return !a.Equals(b); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether to <see cref="TaskVersion"/> objects | ||
| /// are equal using value semantics. | ||
| /// </summary> | ||
| /// <param name="other">The other <see cref="TaskVersion"/> to compare to.</param> | ||
| /// <returns><c>true</c> if the two <see cref="TaskVersion"/> are equal using value semantics; otherwise <c>false</c>.</returns> | ||
| public bool Equals(TaskVersion other) | ||
| { | ||
| return string.Equals(this.Version, other.Version, StringComparison.OrdinalIgnoreCase); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether to <see cref="TaskVersion"/> objects | ||
| /// are equal using value semantics. | ||
| /// </summary> | ||
| /// <param name="obj">The other object to compare to.</param> | ||
| /// <returns><c>true</c> if the two objects are equal using value semantics; otherwise <c>false</c>.</returns> | ||
| public override bool Equals(object? obj) | ||
| { | ||
| if (obj is not TaskVersion other) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return this.Equals(other); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Calculates a hash code value for the current <see cref="TaskVersion"/> instance. | ||
| /// </summary> | ||
| /// <returns>A 32-bit hash code value.</returns> | ||
| public override int GetHashCode() | ||
| { | ||
| return StringComparer.OrdinalIgnoreCase.GetHashCode(this.Version); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we evaluated versioning for
TaskActivity? DurableTask.Core has it. I personally haven't used it much myself, unlike orchestration versioning which I used extensively. Still wondering if it is planned?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also haven't used it much, the initial thought here is that differently versioned orchestrations can have the different activities and different version activities in the same orchestration were less likely.
That being said, we've left the door open for it, so if it's a requested feature or something we agree to as a team we can still implement it down the road.