Add a TryGetChapters function to ScriptureRangeParser

Aperta
#486 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@pmachapman ci sta già lavorando.

Dal 14/9/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

When I call ScriptureRangeParser.GetChapters(), I sometimes need to wrap it in a try/catch to ensure that any invalid chapter ranges (i.e. because a versification has changed) do not crash the method calling it, and I would rather the method just skip the range.

Does it make sense to have a ScriptureRangeParser.TryGetChapters(string scriptureRange, out Dictionary<string, List<int>> chapters) method that returns true if the chapters were retrieved, or false if they were not?

Another option could be to have a more forgiving GetChapters() implementation that will just parse the chapter ranges specified, even if they are not precisely the same as the versification requires (i.e. additional chapter numbers are in the range)

In Scripture Forge I created an extension method along the lines of:

    public static bool TryGetChapters(
        this ScriptureRangeParser scriptureRangeParser,
        string chapterSelections,
        [NotNullWhen(true)] out Dictionary<string, List<int>>? chapters
    )
    {
        try
        {
            chapters = scriptureRangeParser.GetChapters(chapterSelections);
            return true;
        }
        catch (ArgumentException)
        {
            chapters = null;
            return false;
        }
    }
Lingua principale
C#
Stelle
29
Fork
17
Merge medio
3g 2h
PR unite (30g)
8

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

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/machine

Tutte le issue di sillsdev/machine

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.