From c74caee6bce9ac5a3eac473fde2d4292941f9c7a Mon Sep 17 00:00:00 2001 From: Pawel Baran Date: Wed, 10 Jul 2024 18:08:24 +0200 Subject: [PATCH 1/2] #3370 fixed --- Serialiser_Engine/Compute/Deserialise/Type.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Serialiser_Engine/Compute/Deserialise/Type.cs b/Serialiser_Engine/Compute/Deserialise/Type.cs index 6f5b75934..b767a8b81 100644 --- a/Serialiser_Engine/Compute/Deserialise/Type.cs +++ b/Serialiser_Engine/Compute/Deserialise/Type.cs @@ -46,7 +46,7 @@ private static Type DeserialiseType(this BsonValue bson, Type value, string vers return null; else if (bson.IsString) { - Type type = BH.Engine.Base.Create.Type(bson.AsString, true); + Type type = BH.Engine.Base.Create.Type(bson.AsString, true, true); if (type != null) return type; else From b0677719582aaf9d35b9d508bec769fcb77bae17 Mon Sep 17 00:00:00 2001 From: Pawel Baran Date: Thu, 11 Jul 2024 13:39:44 +0200 Subject: [PATCH 2/2] review comments addressed --- BHoM_Engine/Create/Type/Type.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/BHoM_Engine/Create/Type/Type.cs b/BHoM_Engine/Create/Type/Type.cs index 9f94c7521..a93931e32 100644 --- a/BHoM_Engine/Create/Type/Type.cs +++ b/BHoM_Engine/Create/Type/Type.cs @@ -78,15 +78,14 @@ public static Type Type(string name, bool silent = false, bool takeFirstIfMultip else if (types.Count == 1) return types[0]; else if (types.Count > 1 && takeFirstIfMultiple) - return types.OrderBy(x => x.Assembly.FullName).First(); - else if (!silent) { - string message = "Ambiguous match: Multiple types correspond the the name provided: \n"; - foreach (Type type in types) - message += "- " + type.FullName + "\n"; + if (!silent) + Compute.RecordWarning($"Ambiguous match: Multiple types correspond the the name provided:\n{string.Join("\n", types.Select(x => x.FullName))}"); - Compute.RecordError(message); + return types.OrderBy(x => x.Assembly.FullName).First(); } + else if (!silent) + Compute.RecordError($"Ambiguous match: Multiple types correspond the the name provided:\n{string.Join("\n", types.Select(x => x.FullName))}"); return null; }