Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Add API for changes to dispatch sub changes

Aperta
#48 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
csharp

Direzione di ricerca

Inizia da IChangeContext.cs per comprendere l’API di dispatch proposta, quindi leggi SnapshotWorker.cs e la gestione esistente di MarkDeleted. Implementa il flusso di dispatch in modo che le modifiche emesse durante l’applicazione vengano raccolte e applicate, quindi verifica che la gestione delle eliminazioni possa essere spostata nelle modifiche come descritto e che MarkDeleted non sia più necessario.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C#
Stelle
14
Fork
4
Merge medio
5g 15h
PR unite (30g)
10

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sillsdev/harmony

Tutte le issue di sillsdev/harmony

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.