Skip to content

Commit

Permalink
Fix compiler warning about no await operators (#1059)
Browse files Browse the repository at this point in the history
Fix the compiler warning "This async method lacks 'await' operators and
will run synchronously."
  • Loading branch information
rmunn authored Sep 24, 2024
1 parent 7aafe1a commit d478374
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ await _api.CreateEntry(new Entry()
}});
}

public async Task DisposeAsync()
public Task DisposeAsync()
{
_api.Dispose();
return Task.CompletedTask;
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ await _api.CreateEntry(new Entry()
});
}

public async Task DisposeAsync()
public Task DisposeAsync()
{
_api.Dispose();
return Task.CompletedTask;
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ await _api.CreateEntry(new Entry()
});
}

public async Task DisposeAsync()
public Task DisposeAsync()
{
_api.Dispose();
return Task.CompletedTask;
}

[Fact]
Expand Down
42 changes: 24 additions & 18 deletions backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,20 @@ public Task<WritingSystem> UpdateWritingSystem(WritingSystemId id, WritingSystem
throw new NotImplementedException();
}

public async IAsyncEnumerable<PartOfSpeech> GetPartsOfSpeech()
public IAsyncEnumerable<PartOfSpeech> GetPartsOfSpeech()
{
foreach (var partOfSpeech in PartOfSpeechRepository.AllInstances().OrderBy(p => p.Name.BestAnalysisAlternative.Text))
{
yield return new PartOfSpeech { Id = partOfSpeech.Guid, Name = FromLcmMultiString(partOfSpeech.Name) };
}
return PartOfSpeechRepository
.AllInstances()
.OrderBy(p => p.Name.BestAnalysisAlternative.Text)
.ToAsyncEnumerable()
.Select(partOfSpeech => new PartOfSpeech
{
Id = partOfSpeech.Guid,
Name = FromLcmMultiString(partOfSpeech.Name)
});
}

public async Task CreatePartOfSpeech(PartOfSpeech partOfSpeech)
public Task CreatePartOfSpeech(PartOfSpeech partOfSpeech)
{
if (partOfSpeech.Id == default) partOfSpeech.Id = Guid.NewGuid();
UndoableUnitOfWorkHelper.Do("Create Part of Speech",
Expand All @@ -187,22 +192,25 @@ public async Task CreatePartOfSpeech(PartOfSpeech partOfSpeech)
.Create(partOfSpeech.Id, Cache.LangProject.PartsOfSpeechOA);
UpdateLcmMultiString(lcmPartOfSpeech.Name, partOfSpeech.Name);
});
return Task.CompletedTask;
}

public async IAsyncEnumerable<SemanticDomain> GetSemanticDomains()
public IAsyncEnumerable<SemanticDomain> GetSemanticDomains()
{
foreach (var semanticDomain in SemanticDomainRepository.AllInstances().OrderBy(p => p.Abbreviation.UiString))
{
yield return new SemanticDomain
return
SemanticDomainRepository
.AllInstances()
.OrderBy(p => p.Abbreviation.UiString)
.ToAsyncEnumerable()
.Select(semanticDomain => new SemanticDomain
{
Id = semanticDomain.Guid,
Name = FromLcmMultiString(semanticDomain.Name),
Code = semanticDomain.Abbreviation.UiString ?? ""
};
}
});
}

public async Task CreateSemanticDomain(SemanticDomain semanticDomain)
public Task CreateSemanticDomain(SemanticDomain semanticDomain)
{
if (semanticDomain.Id == Guid.Empty) semanticDomain.Id = Guid.NewGuid();
UndoableUnitOfWorkHelper.Do("Create Semantic Domain",
Expand All @@ -215,6 +223,7 @@ public async Task CreateSemanticDomain(SemanticDomain semanticDomain)
UpdateLcmMultiString(lcmSemanticDomain.Name, semanticDomain.Name);
UpdateLcmMultiString(lcmSemanticDomain.Abbreviation, new MultiString(){{"en", semanticDomain.Code}});
});
return Task.CompletedTask;
}

internal ICmSemanticDomain GetLcmSemanticDomain(Guid semanticDomainId)
Expand Down Expand Up @@ -285,7 +294,7 @@ public IAsyncEnumerable<Entry> GetEntries(QueryOptions? options = null)
return GetEntries(null, options);
}

public async IAsyncEnumerable<Entry> GetEntries(
public IAsyncEnumerable<Entry> GetEntries(
Func<ILexEntry, bool>? predicate, QueryOptions? options = null)
{
var entries = EntriesRepository.AllInstances();
Expand Down Expand Up @@ -320,10 +329,7 @@ public async IAsyncEnumerable<Entry> GetEntries(
.Skip(options.Offset)
.Take(options.Count);

foreach (var entry in entries)
{
yield return FromLexEntry(entry);
}
return entries.ToAsyncEnumerable().Select(FromLexEntry);
}

public IAsyncEnumerable<Entry> SearchEntries(string query, QueryOptions? options = null)
Expand Down

0 comments on commit d478374

Please sign in to comment.