Hi,
doing this would give the possibility to check for leaks of NativeContainer’s in Unit Test via assertions.
I tried to access m_StackTrace via reflection, but it always returns null. So no chance to assert this.
// Log unit test leaks of native containers
public class ECSLeakTestsFixture : ECSTestsFixture
{
AtomicSafetyHandle m_Safety;
DisposeSentinel ds;
[SetUp]
public override void Setup()
{
base.Setup();
DisposeSentinel.Create(out m_Safety, out ds, 0, Allocator.Invalid);
}
[TearDown]
public override void TearDown() {
FieldInfo stackTraceField = ds.GetType().GetField("m_StackTrace", BindingFlags.Instance | BindingFlags.NonPublic);
object stackTrace = stackTraceField.GetValue(ds); // Always null. Even when DisposeSentinel.Dispose() log errors to the console
DisposeSentinel.Dispose(ref m_Safety, ref ds);
base.TearDown();
}
}