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

NullReferenceException when creating one specific binding #6

Open
jhm-ciberman opened this issue Dec 16, 2023 · 0 comments
Open

NullReferenceException when creating one specific binding #6

jhm-ciberman opened this issue Dec 16, 2023 · 0 comments

Comments

@jhm-ciberman
Copy link

jhm-ciberman commented Dec 16, 2023

I have came up with a strange case that fails with a NullReferenceException:

THIS fails:

// class constructor
this._bindings = new EBinding
{
    () => this.Position == this._vm.PreviewPosition,
};

THIS works:

// class constructor
this._bindings = new EBinding
{
    () => this.Position == this._vm.PreviewPosition + Vector3.Zero,
};

The view class is:

public class BuildModeFurniturePreviewNode : Node3D

The base class Node3D is the one defining the Position property, not the BuildModeFurniturePreviewNode class. I think this is the cause of the error but I am not sure.

This is the stack trace:

Unhandled exception. System.Exception: Error in entry 0 at line #34:
`() => BuildModeFurniturePreviewNode.Position == _vm.PreviewPosition`
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at EBind.TriggerDelegate.<>c.<.ctor>b__1_1(Object t, Object h)
   at EBind.ExpressionBinding.Subscribe(IEnumerable`1 triggers, Action action)
   at EBind.EqualityBindings.EqualityBinding`1..ctor(Expression left, Expression right, BindFlag flags, Configuration configuration)
   at EBind.EqualityBindings.EqualityBindingFactory`1.Create(Expression left, Expression right, BindFlag flags, Configuration configuration)
   at EBind.EqualityBindings.EqualityBinding.Create[T](Expression`1 expr, BindFlag flags, Configuration configuration)
   at EBind.ExpressionBinding.Create[T](Expression`1 expr, BindFlag flag, Configuration configuration)
   at EBind.EBinding.Add[T](Expression`1 specification, Int32 sourceLineNumber)
   --- End of inner exception stack trace ---
   at EBind.EBinding.Add[T](Expression`1 specification, Int32 sourceLineNumber)
   at LifeSim.Game.Visuals.BuildMode.BuildModeFurniturePreviewNode..ctor(FurnitureTabViewModel vm) in C:\repos\medieval-life\src\LifeSim.Game\Visuals\BuildMode\BuildModeFurniturePreviewNode.cs:line 32
   at LifeSim.Game.Visuals.BuildMode.FurnitureTabView..ctor(FurnitureTabViewModel vm) in C:\repos\medieval-life\src\LifeSim.Game\Visuals\BuildMode\FurnitureTabView.cs:line 17
   at LifeSim.Game.Visuals.BuildMode.BuildModeView.OnCurrentTabChanged() in C:\repos\medieval-life\src\LifeSim.Game\Visuals\BuildMode\BuildModeView.cs:line 52
   at LifeSim.Game.Visuals.BuildMode.BuildModeView..ctor(BuildModeActivityViewModel vm) in C:\repos\medieval-life\src\LifeSim.Game\Visuals\BuildMode\BuildModeView.cs:line 24
   at LifeSim.Game.GameScene.GetActivityNode(GameActivityViewModel activity) in C:\repos\medieval-life\src\LifeSim.Game\GameScene.cs:line 91
   at EBind.MethodDelegates.FunctionDelegate`3.Invoke(Func`3 del, Object[] parameters)
   at EBind.MethodDelegates.DelegateBase`1.Invoke(Object[] args)
   at EBind.ExpressionInterpreter.<>c__DisplayClass10_0`1.<TryBuildMethodGetter>b__0()
   at EBind.EqualityBindings.EqualityBinding`1.OnSideChanged(Func`1 getter, Action`1 setter)
   at EBind.EqualityBindings.EqualityBinding`1.<.ctor>b__9_0()
   at EBind.TriggerDelegate.<>c__DisplayClass1_1.<.ctor>b__3(Object s, PropertyChangedEventArgs e)
   at LifeSim.ViewModels.GameViewModel.ChangeActivity(GameActivityViewModel activity) in C:\repos\medieval-life\src\LifeSim.ViewModels\GameViewModel.cs:line 93
   at LifeSim.ViewModels.GameViewModel.SwitchGameMode() in C:\repos\medieval-life\src\LifeSim.ViewModels\GameViewModel.cs:line 113
   at LifeSim.ViewModels.GameViewModel.Input_ActionPerformed(Object sender, ActionPerformedEventArgs e) in C:\repos\medieval-life\src\LifeSim.ViewModels\GameViewModel.cs:line 78
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

1 participant