Skip to content

Commit

Permalink
fix: null reference on extra elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Jan 31, 2024
1 parent 3dec778 commit f5b5164
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class RequestedChapterDocument : DocumentBase<RequestedChapterDocument>,
public const int CurrentVersion = 1;

// ReSharper disable once FieldCanBeMadeReadOnly.Local
[BsonExtraElements] private Dictionary<string, object> _extraElements = null!;
[BsonExtraElements] private Dictionary<string, object>? _extraElements;

public required string RequestedMangaId { get; set; }
public required string ChapterId { get; set; } = null!;
Expand All @@ -27,6 +27,11 @@ void ISupportInitialize.BeginInit()

void ISupportInitialize.EndInit()
{
if (_extraElements == null)
{
return;
}

if (!_extraElements.TryGetValue("CreationDate", out object? creationDate))
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class RequestedMangaDocument : DocumentBase<RequestedMangaDocument>, ISup
public const int CurrentVersion = 1;

// ReSharper disable once FieldCanBeMadeReadOnly.Local
[BsonExtraElements] private Dictionary<string, object> _extraElements = null!;
[BsonExtraElements] private Dictionary<string, object>? _extraElements;

public required int SearchId { get; set; }
public required string SourceId { get; set; } = null!;
Expand All @@ -26,6 +26,11 @@ void ISupportInitialize.BeginInit()

void ISupportInitialize.EndInit()
{
if (_extraElements == null)
{
return;
}

if (!_extraElements.TryGetValue("CreationDate", out object? creationDate))
{
return;
Expand Down

0 comments on commit f5b5164

Please sign in to comment.