Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add API for changes to dispatch sub changes

オープン
#48 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp

調査の方向性

IChangeContext.cs から始めて提案されている dispatch API を理解し、次に SnapshotWorker.cs と既存の MarkDeleted の処理を読みます。適用中に発行された変更が収集されて適用されるように dispatch フローを実装し、説明どおりに削除処理を変更側へ移行でき、MarkDeleted が不要になることを確認します。

索引モデルが issue の本文から書いたものです。

説明

What

We want changes to be able to dispatch other changes. For example deletes:

public class DeleteEntryChange(Guid entityId) : EditChange<Entry>(entityId), IPolyType
{
    public static string TypeName => "delete:Entry";

    public override async ValueTask ApplyChange(Entry entry, IChangeContext context)
    {
        entry.DeletedAt = context.Commit.DateTime;
        await foreach (var obj in context.GetObjectsReferencing(EntityId, includeDeleted: false))
        {
            context.DispatchChange(new RemoveReferenceChange(obj));
        }
    }
}

or when we want to update objects which contain a copy of data

public class UpdateHeadwordChange(Guid entityId, string headword) : EditChange<Entry>(entityId), IPolyType
{
    public static string TypeName => "update:Entry:Headword";

    public override async ValueTask ApplyChange(Entry entry, IChangeContext context)
    {
        entry.Headword = headword;
        await foreach(var complexForm in context.GetObjectsReferencing(entry.Id).OfType<ComplexForm>())
        {
            context.DispatchChange(new UpdateComplexFormChange(complexForm.Id, headword));
        }
    }
}

this would also be used for data migrations, maybe previously a field was owned by an object, but you want to move that field to a different object, however you have old changes which reference the old object, you can now dispatch a change to the correct object.

Why
  • simplify delete handling code. Much of our current delete code could be moved into 2 dedicated types, one for a delete and one for removing a reference.
  • allow updating derived data, eg writing system exemplars, or complex forms.
  • data migrations, right now if you want to move a field from one object to another there's no way to write a change which allows that because a change can only modify the object it references in it's EntityId.
How

Add a new API to IChangeContext:
https://github.com/sillsdev/harmony/blob/5a660d125c4f1adc99c3384f275259b3d607d9a1/src/SIL.Harmony.Core/IChangeContext.cs#L3-L18

void DispatchChanges(params Span<IChange> changes);

this would require a lot of changes to SnapshotWorker, after a change was applied we need to gather the changes it dispatched and apply them. Much of the code in MarkDeleted will prove a useful model I suspect, however MarkDeleted itself should go away entirely as it will be handled via changes now instead.

主要言語
C#
スター
14
フォーク
4
平均マージ
2日 18時間
マージ済み PR(30日)
6

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sillsdev/harmony のほかの issue

sillsdev/harmony の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。