Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions BHoM_Engine/Create/Type/GenericType.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2025, the respective contributors. All rights reserved.
*

Check failure on line 4 in BHoM_Engine/Create/Type/GenericType.cs

View check run for this annotation

BHoMBot-CI / copyright-compliance

BHoM_Engine/Create/Type/GenericType.cs#L3-L4

Copyright message is invalid - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasValidCopyright
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
Expand Down Expand Up @@ -142,7 +142,11 @@
}
//Main type definition as string up until the first split char (first '<').
//Number of generic arguments will be 1 less than the number of argsSplit count
return GenericType(name.Substring(0, argsSplit[0]) + "`" + (argsSplit.Count - 1), arguments, silent, takeFirstIfMultiple);
Type type = GenericType(name.Substring(0, argsSplit[0]) + "`" + (argsSplit.Count - 1), arguments, silent, takeFirstIfMultiple);

if (type != null && name.Contains("&"))
type = type.MakeByRefType();
return type;
}

/***************************************************/
Expand Down Expand Up @@ -209,9 +213,12 @@
arguments.Add(name.Substring(argsStarts[i], argsEnd[i] - argsStarts[i]).Trim());
}
string mainName = name.Substring(0, nameEnd);
//Main type definition as string up until the first split char (first '<').
//Main type definition as string up until the first split char (first '[[').
//Number of generic arguments will be 1 less than the number of argsSplit count
return GenericType(mainName, arguments, silent, takeFirstIfMultiple);
Type type = GenericType(mainName, arguments, silent, takeFirstIfMultiple);
if (type != null && name.Contains("&"))
type = type.MakeByRefType();
return type;
}

/***************************************************/
Expand Down
16 changes: 13 additions & 3 deletions BHoM_Engine/Create/Type/Type.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2025, the respective contributors. All rights reserved.
*

Check failure on line 4 in BHoM_Engine/Create/Type/Type.cs

View check run for this annotation

BHoMBot-CI / copyright-compliance

BHoM_Engine/Create/Type/Type.cs#L3-L4

Copyright message is invalid - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasValidCopyright
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
Expand Down Expand Up @@ -49,6 +49,13 @@
return null;
}

if (name.StartsWith("System.")) //If a system type, try create it before doing anything else. If failing, rest of method will handle unqualified, generics, reference etc
{
Type type = System.Type.GetType(name);
if (type != null)
return type;
}

if (name.Contains('<'))
return GenericTypeAngleBrackets(name, silent, takeFirstIfMultiple);
else if (name.Contains('`') && name.Contains("[["))
Expand All @@ -67,9 +74,9 @@
if (type == null)
type = System.Type.GetType(unQualifiedName); //Fallback for when deserialising a type from a later net runtime to a lower net runtime. Can be critical when going between softwares of different net runtimes.

if (type == null && name.EndsWith("&"))
if (type == null && name.Contains("&"))
{
type = Type(name.TrimEnd(new char[] { '&' }), true);
type = Type(name.Replace("&", ""), silent, takeFirstIfMultiple);
if (type != null)
type = type.MakeByRefType();
}
Expand Down Expand Up @@ -103,7 +110,10 @@
["System.Drawing.Bitmap"] = typeof(System.Drawing.Bitmap),
["System.Collections.Generic.SortedDictionary`2"] = typeof(System.Collections.Generic.SortedDictionary<,>),
["System.Data.DataTable"] = typeof(System.Data.DataTable),
["System.Collections.Generic.HashSet`1"] = typeof(System.Collections.Generic.HashSet<>)
["System.Collections.Generic.HashSet`1"] = typeof(System.Collections.Generic.HashSet<>),
["System.Xml.XmlNode"] = typeof(System.Xml.XmlNode),
["System.Xml.Linq.XDocument"] = typeof(System.Xml.Linq.XDocument),
["System.Collections.Concurrent.ConcurrentBag`1"] = typeof(System.Collections.Concurrent.ConcurrentBag<>)
};

/*******************************************/
Expand Down
10 changes: 2 additions & 8 deletions Serialiser_Engine/Compute/Deserialise/Type.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2025, the respective contributors. All rights reserved.
*

Check failure on line 4 in Serialiser_Engine/Compute/Deserialise/Type.cs

View check run for this annotation

BHoMBot-CI / copyright-compliance

Serialiser_Engine/Compute/Deserialise/Type.cs#L3-L4

Copyright message is invalid - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/HasValidCopyright
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
Expand Down Expand Up @@ -38,7 +38,7 @@
/*******************************************/
/**** Private Methods ****/
/*******************************************/

private static Type DeserialiseType(this BsonValue bson, Type value, string version, bool isUpgraded)
{
// Handle the case where the type is represented as a string
Expand Down Expand Up @@ -146,16 +146,10 @@
Type type = null;
if (fullName == "T")
return null;
if (fullName.IsOmNamespace())
type = Base.Create.Type(fullName, true, true);
else if (fullName.IsEngineNamespace())
type = Base.Create.EngineType(fullName, true, true);
else
{
type = Type.GetType(fullName);
if (type == null)
type = System.Type.GetType(Base.Query.UnqualifiedName(fullName));
}
type = Base.Create.Type(fullName, true, true); //Use for all cases except engine methods as method able to handle both oM, and system types, as well as adapter. Also this method is called no matter what if the type is serialised as a string rather than document in this file

if (type == null)
{
Expand Down