In a context where nullable references are enabled and set to trigger errors a class that provides a custom predicate causes such an error in the generated CreateEntityContainer method.
I guess instead of the as operator one should use an exception-throwing cast. An exception would be thrown in the null-case anyway.
Example system:
public partial class Test : AEntitySetSystem<float>
{
public Test(World world) : base(world) { }
[WithPredicate]
private bool Filter(in int _) => false;
[Update]
private void Update(float state, in int _) { }
}
Generated CreateEntityContainer method:
[CompilerGenerated]
private static EntitySet CreateEntityContainer(object sender, World world) => world
.GetEntities()
.With<int>()
.With<int>((sender as Test).Filter) // CS8602: Dereference of a possibly null reference.
.AsSet();
In a context where nullable references are enabled and set to trigger errors a class that provides a custom predicate causes such an error in the generated
CreateEntityContainer
method. I guess instead of theas
operator one should use an exception-throwing cast. An exception would be thrown in thenull
-case anyway.Example system:
Generated
CreateEntityContainer
method: