I'm testing MemoryPack (latest .NET 7) with a class that has multiple constructors, and I marked one of the constructors as '[MemoryPackConstructor]'.
However, the project doesn't compile and shows an error during compilation:
"Error CS0234 The type or namespace name 'Formatters' does not exist in the namespace 'Tests.MemoryPack' (are you missing an assembly reference?)"
And it points to line 44 in generated code:
Here is my full test code:
using MemoryPack;
namespace Tests.MemoryPack
{
[MemoryPackable]
public partial class TestObject
{
public string testString { get; set; } = "";
[MemoryPackConstructor]
public TestObject() { }
public TestObject(string ignore) { }
}
class MemPackTest
{
public static void Main()
{
TestObject test_object = new();
test_object.testString = "ABC";
Console.WriteLine("Initial value before serializing: " + test_object.testString);
byte[] serialized_object = MemoryPackSerializer.Serialize(test_object);
TestObject? deserialized_object = MemoryPackSerializer.Deserialize<TestObject>(serialized_object);
if (deserialized_object != null)
{
Console.WriteLine("Final value after deserializing: " + deserialized_object.testString);
}
Console.WriteLine("Test completed. Press any key to exit");
Console.ReadKey();
}
}
}
I'm testing MemoryPack (latest .NET 7) with a class that has multiple constructors, and I marked one of the constructors as '[MemoryPackConstructor]'. However, the project doesn't compile and shows an error during compilation: "Error CS0234 The type or namespace name 'Formatters' does not exist in the namespace 'Tests.MemoryPack' (are you missing an assembly reference?)"
And it points to line 44 in generated code:
Here is my full test code: