Closed garcipat closed 1 month ago
Thanks for reporting this issue, can you please provide a failing test and if a or would be grateful.
Of course:
public class FileStorageTests
{
[Fact]
public async Task SaveObject_ShouldSaveObjectClean()
{
using var storage = new FolderFileStorage(new FolderFileStorageOptions() { Folder = "Output" });
var file = $"test-{Random.Shared.Next()}.json";
var longTextInstance = new TestClass
{
TestProperty = "VeryLongString"
};
var shortTextInstance = new TestClass
{
TestProperty = "Short"
};
await storage.SaveObjectAsync(file, longTextInstance);
await storage.SaveObjectAsync(file, shortTextInstance);
var storedTestClass = await storage.GetObjectAsync<TestClass>(file);
}
public class TestClass
{
public required string TestProperty { get; set; }
}
}
I have not tested it with other implementations. As a workaround im deleting the existing file before writing the same again.
When I'm Serializing an object with SaveObjectAsync in a folder where there alrady has been an object serialized, there are leftover characters. The existing content is not cleared.
Example: First Serializing output:
Second serialization: