Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit b3c65f6

Browse files
committed
Document ICopyable and add id checks to CopyFrom implementation
1 parent 3f4c8e1 commit b3c65f6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/GitHub.App/Models/PullRequestModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public PullRequestModel(int number, string title, IAccount author, DateTimeOffse
1919

2020
public void CopyFrom(IPullRequestModel other)
2121
{
22+
if (Number != other.Number)
23+
throw new ArgumentException("Instance to copy from must match", nameof(other));
2224
Title = other.Title;
2325
UpdatedAt = other.UpdatedAt;
2426
CommentCount = other.CommentCount;

src/GitHub.Exports/Collections/ICopyable.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
namespace GitHub.Collections
22
{
3+
/// <summary>
4+
/// Allows a type instance to copy data from another
5+
/// instance. Similar to a Clone action, but without
6+
/// creating a new instance.
7+
/// </summary>
8+
/// <typeparam name="T">Type that implements CopyFrom</typeparam>
39
public interface ICopyable<in T>
410
{
511
void CopyFrom(T other);

0 commit comments

Comments
 (0)