Browse Source

More nullable fixes

pull/165/head
Ionite 1 year ago
parent
commit
dd6b8a066a
No known key found for this signature in database
  1. 6
      StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionList.cs
  2. 2
      StabilityMatrix.Avalonia/DesignData/MockLiteDbContext.cs
  3. 9
      StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs

6
StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionList.cs

@ -502,7 +502,11 @@ public class CompletionList : TemplatedControl
if (string.IsNullOrEmpty(query))
return;
var suggestedIndex = _listBox.SelectedIndex;
var suggestedIndex = _listBox?.SelectedIndex ?? -1;
if (suggestedIndex == -1)
{
return;
}
var bestIndex = -1;
var bestQuality = -1;

2
StabilityMatrix.Avalonia/DesignData/MockLiteDbContext.cs

@ -47,7 +47,7 @@ public class MockLiteDbContext : ILiteDbContext
public Task<GithubCacheEntry?> GetGithubCacheEntry(string cacheKey)
{
return Task.FromResult<GithubCacheEntry>(null);
return Task.FromResult<GithubCacheEntry?>(null);
}
public Task<bool> UpsertGithubCacheEntry(GithubCacheEntry cacheEntry)

9
StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs

@ -239,8 +239,13 @@ public abstract class BaseGitPackage : BasePackage
public override async Task<bool> CheckForUpdates(InstalledPackage package)
{
var currentVersion = package.Version;
if (currentVersion == null)
if (currentVersion is null or { InstalledReleaseVersion: null, InstalledBranch: null })
{
Logger.Warn(
"Could not check updates for package {Name}, version is invalid: {@currentVersion}",
Name,
currentVersion
);
return false;
}
@ -254,7 +259,7 @@ public abstract class BaseGitPackage : BasePackage
}
var allCommits = (
await GetAllCommits(currentVersion.InstalledBranch).ConfigureAwait(false)
await GetAllCommits(currentVersion.InstalledBranch!).ConfigureAwait(false)
)?.ToList();
if (allCommits == null || !allCommits.Any())
{

Loading…
Cancel
Save