From 08edee2ff5e47e3c49bd556c41bbab3526385db3 Mon Sep 17 00:00:00 2001
From: HerrKnarz <40741234+HerrKnarz@users.noreply.github.com>
Date: Tue, 4 Apr 2023 22:09:55 +0200
Subject: [PATCH] fixed error, when company name is null
---
Generic/CompanyCompanion/ViewModels/MergeCompanies.cs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/Generic/CompanyCompanion/ViewModels/MergeCompanies.cs b/Generic/CompanyCompanion/ViewModels/MergeCompanies.cs
index 452752d20..6a30083b3 100644
--- a/Generic/CompanyCompanion/ViewModels/MergeCompanies.cs
+++ b/Generic/CompanyCompanion/ViewModels/MergeCompanies.cs
@@ -61,7 +61,7 @@ public MergeCompanies(CompanyCompanion plugin)
/// Name to clean.
/// List of words to remove.
/// Name with the words removed
- private string RemoveWords(string name, List wordList)
+ private static string RemoveWords(string name, IReadOnlyCollection wordList)
{
return name != null
? string.Join(" ", name.Split().Where(w => !wordList.Contains(w.RemoveSpecialChars().Replace("-", ""), StringComparer.InvariantCultureIgnoreCase)))
@@ -75,6 +75,11 @@ private string RemoveWords(string name, List wordList)
/// cleaned up name
private string CleanUpCompanyName(string name)
{
+ if (string.IsNullOrEmpty(name))
+ {
+ return name;
+ }
+
string newName = name;
if (newName.EndsWith(")"))
@@ -114,6 +119,7 @@ public void GetMergeList(bool cleanUpName = false, bool findSimilar = false)
try
{
List companyList = API.Instance.Database.Companies
+ .Where(c => !string.IsNullOrEmpty(c.Name))
.Select(c => new MergeItem
{
Id = c.Id,