Repository navigation
Conversation
|
@BHoMBot check code-compliance |
|
@adecler to confirm, the following actions are now queued:
There are 578 requests in the queue ahead of you. |
IsakNaslundBh
left a comment
There was a problem hiding this comment.
Have tested this through, and seem the back and forward to json is functioning. However the methods are not triggering correctly in the UI.
For example, this method:
public static T FailingGenericMethod<T>(this T val) where T : struct
{
return default(T);
}
Get stuck to double, and can never accept anything else:
Also tried some other examples, that might be out of scope for this, like:
public static double MassTest<T>(this T elementM) where T : BHoMObject, IElementM
Does not work at all (think it is under the "unsatisfied" case.
Also tried a case I at one point actually wanted to make use of, with the new() keyword:
public static ILink<TNode> SetElements0D<TNode>(this ILink<TNode> link, List<IElement0D> newElements0D)
where TNode : INode, new()
To allow to skip the Activator.CreateInstance call. This is ofc of less criticality in general, and might be out of scope of this PR.
Mostly wanted to flag that I am not sure if the fixes in here actually makes the methods work in the UI (as shown by the double case).
Will leave this as a comment rather than blocking request for changes.
|
@IsakNaslundBh , yes this PR is just to address the issue raised by Peter since it was impacting other components. The handling of generics in the UI is a separate issue that will likely have to be addressed in BHoM_UI. Although it will be tricky since we don't know what the method should be until something is plugged in the input. |
|
@BHoMBot check documentation-compliance |
|
@adecler to confirm, the following actions are now queued:
There are 2 requests in the queue ahead of you. |
Issues addressed by this PR
Closes #3614
Test files
The simplest to compare the before and after is to run this GH script:
GenericMethodSerialisation.zip
First, it serialises all existing generic BHoM methods to establish a baseline (serialisation relies heavily on reflection so it is a good way to cover many cases at once).
Secondly, it test a set of weird generic cases. It's quite likely that we will never encounter most of them. But, since issue #3614 is also related to a case we don't have in the installer, it's best to be prepared.
You can also run the new unit tests added in this PR.