Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After serialization/deserialization indexed components don't work #15

Closed
Belzebbuz opened this issue Sep 7, 2024 · 2 comments
Closed

Comments

@Belzebbuz
Copy link

Belzebbuz commented Sep 7, 2024

After serialization/deserialization indexed components don't work

[Fact]
public void AddTwoEntitiesWithDifferentIndexesThenSaveIt_ShouldReturnSingleIndexedValue()
{
  var id1 = Guid.NewGuid().ToString();
  var id2 = Guid.NewGuid().ToString();
  var store = new EntityStore();
  var entityA = store.CreateEntity();
  entityA.AddComponent(new Index() { value = id1 });
  var entityB = store.CreateEntity();
  entityB.AddComponent(new Index() { value = id2 });
  
  var newStoreEntity1 = store.GetEntitiesWithComponentValue<Index,string>(id1).ToArray();
  newStoreEntity1.Length.Should().Be(1); // THIS OK
  
  using var stream = new MemoryStream();
  var serializer = new EntitySerializer();
  serializer.WriteStore(store,stream);
  
  var readStore = new EntityStore();
  serializer.ReadIntoStore(readStore, stream);
  readStore.Count.Should().Be(2);

  var readEntity1 = readStore.GetEntitiesWithComponentValue<Index,string>(id1).ToArray(); 
  readEntity1.Length.Should().Be(1); // THIS FAILED
}
private struct Index() : IIndexedComponent<string>
{
  public string value;
  public string GetIndexedValue() => value;
}
friflo added a commit that referenced this issue Nov 4, 2024
@friflo
Copy link
Owner

friflo commented Nov 4, 2024

Fixed by: 784c765

@friflo friflo closed this as completed Nov 4, 2024
@friflo
Copy link
Owner

friflo commented Nov 12, 2024

Fixed in 3.0.0-preview.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants