Skip to content

Commit 31fc136

Browse files
committed
refactor: suppress nullable compliler warnigns
1 parent 6fbfe68 commit 31fc136

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

OsmoDoc/Word/Models/DocumentData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public class DocumentData
1313
/// <summary>
1414
/// Gets or sets the list of content placeholders in the document.
1515
/// </summary>
16-
public List<ContentData> Placeholders { get; set; }
16+
public List<ContentData> Placeholders { get; set; } = new();
1717

1818
/// <summary>
1919
/// Gets or sets the list of table data in the document.
2020
/// </summary>
2121

22-
public List<TableData> TablesData { get; set; }
22+
public List<TableData> TablesData { get; set; } = new();
2323
}

OsmoDoc/Word/Models/TableData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ public class TableData
1818
/// Each dictionary contains column header-value pairs.
1919
/// </summary>
2020

21-
public List<Dictionary<string, string>> Data { get; set; }
21+
public List<Dictionary<string, string>> Data { get; set; } = new();
2222
}

OsmoDoc/Word/WordDocumentGenerator.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,20 @@ private async static Task ReplaceImagePlaceholders(string inputFilePath, string
305305
DocProperties? docProperty = drawing.Descendants<DocProperties>().FirstOrDefault();
306306

307307
// If drawing / image name is present in imagePlaceholders dictionary, then replace image
308-
if (docProperty != null && imagePlaceholders.ContainsKey(docProperty.Name))
308+
if (docProperty != null && docProperty.Name != null && imagePlaceholders.ContainsKey(docProperty.Name!))
309309
{
310310
List<Blip> drawingBlips = drawing.Descendants<Blip>().ToList();
311311

312312
foreach (Blip blip in drawingBlips)
313313
{
314-
OpenXmlPart imagePart = wordDocument.MainDocumentPart.GetPartById(blip.Embed);
314+
if (blip.Embed == null)
315+
{
316+
continue;
317+
}
318+
319+
OpenXmlPart imagePart = mainDocumentPart!.GetPartById(blip.Embed!);
315320

316-
string imagePath = imagePlaceholders[docProperty.Name];
321+
string imagePath = imagePlaceholders[docProperty.Name!];
317322

318323
// Asynchronously download image data using HttpClient
319324
byte[] imageData = await _httpClient.GetByteArrayAsync(imagePath);

0 commit comments

Comments
 (0)