NickPolyder / NP.ObjectComparison

This repository serves as a library that will make Object Patching and diff easier.
MIT License
2 stars 0 forks source link

Issue Calling object.HasChanges(true); Expression must be writeable (Parameter 'left') #3

Open codepend opened 1 year ago

codepend commented 1 year ago

Hello Sir!

I am having an issue calling the HasChanges method on an ComparisonTracker object.

AFAIK I am doing things correctly, however during a save, I am calling this method to confirm.

if (!record.HasChanges(true)) { return; }

I receive the following exception:

Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111] Unhandled exception in circuit 'S7L-w8ctPi0BLDIsrgGttG5xS98OkotRpAR5I_jsPUc'. System.ArgumentException: Expression must be writeable (Parameter 'left') at System.Linq.Expressions.Expression.RequiresCanWrite(Expression expression, String paramName) at System.Linq.Expressions.Expression.Assign(Expression left, Expression right) at NP.ObjectComparison.Analyzers.Infos.ObjectInfoBuilder1.Build(PropertyInfo publicProperty) at NP.ObjectComparison.Analyzers.Strategies.ObjectAnalyzerBuilderStrategy.Build[TInstance](PropertyInfo propertyInfo, AnalyzerSettings options) at NP.ObjectComparison.Analyzers.AnalyzerBuilder1.Build(AnalyzerSettings options)+MoveNext() at NP.ObjectComparison.Analyzers.ComplexObjectAnalyzer2.Analyze(TInstance originalInstance, TInstance targetInstance) at NP.ObjectComparison.Analyzers.ComplexObjectAnalyzer2.Analyze(TInstance originalInstance, TInstance targetInstance) at NP.ObjectComparison.Analyzers.AnalyzerComposite1.Analyze(TInstance originalInstance, TInstance targetInstance) at NP.ObjectComparison.ComparisonTracker1.Analyze() at NP.ObjectComparison.ComparisonTracker1.HasChanges(Boolean autoAnalyze) at WebUi.Pages.FirewallErrors.SaveRow(ComparisonTracker1 record) in \source\repos\WebUi\Pages\FirewallErrors.razor:line 263 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Radzen.Blazor.RadzenButton.OnClick(MouseEventArgs args) at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

codepend commented 1 year ago

Update... I found that it is some property on the object which i have set to ignore in the analyzer settings, not sure which on yet. Will report back.

codepend commented 1 year ago

Found the culprit. I was another class (property of) on the object. Not exactly sure why this occurred but can work around this. Feel free to close this out or if you want more info, just let me know. I suspect because the class in question does not inherit ICloneable.

NickPolyder commented 1 year ago

Hello @codepend I know a bit late with the comment here. Would it be possible to give me that extra info ? If not easy to replicate not dont worry. I will try to replicate it myself.

Im trying to start up the project again. Have some new ideas around how to build it for .net core.