ExRam.Gremlinq icon indicating copy to clipboard operation
ExRam.Gremlinq copied to clipboard

System.ArgumentException: "Model" is not part of the model. when using a shared nuget package.

Open sebastianamaro opened this issue 8 months ago • 5 comments

Describe the bug I have a solution which uses GremlinQ. Since I am using a Microservice architecture, I need some common logic between the MS that access the graph, which I put in a shared custom nuget package. After I did this 2 things started to happen

  1. Only on AddV (not on update), i get an Argument Exception saying my object is not part of the model.
  2. The Path() response, changed, and instead of having the actual objects in the Objects field of the Path object, i has some Newtonsoft Dynamic representation (I dont have an example now, but if you need it I could try to recreate this).

Expected behavior The only thing I had in this Nuget package for now, is the Vertex and Edge classes, since they are for sure common to all the different MS. I expect that the library can identify that the type exists, and allow me to abstract some pieces of code into this Nuget package.

Version information 12.7.0

Minimal working example https://github.com/sebastianamaro/Gremlinqissue

I included there the Nuget package Project, so you can set that up in your enviroment. As you see it only contains 3 classes.

Additional context I think the issue relies here. GraphElementModel.cs Line 130

public ElementMetadata? TryGetMetadata(Type elementType) => _elementMetadataOverrides.TryGetValue(elementType, out var elementMetadata)
    ? elementMetadata
    : IsWithinModel(elementType)
        ? new ElementMetadata(elementType.Name)
        : default(ElementMetadata?);

private bool IsWithinModel(Type type) => typeof(TBaseType).IsAssignableFrom(type) && _assemblies.Contains(type.Assembly);

I debugged it, and _assemblies only contains the "Shared" assembly. And type.Assembly is my solutions assembly, typeof(TBaseType).IsAssignableFrom(type) returns true.

sebastianamaro avatar Jun 19 '24 09:06 sebastianamaro