signumsoftware/framework

ObjectDumper throws exception on non Entity class

ghockx1p opened this issue · 3 comments

I'm using the ObjectDumper to log the state of classes when they are put in an MSMQ messagebody. These are simple classes not inhereting from Entity and they only contain attributes.
In October the ObjectDumper has been modified in such a way that it now produces the following exception on Dumping my class:

System.InvalidOperationException occurred
HResult=-2146233079
Message=Entity {0} has auto-property {1}, but you can not use auto-propertes if the assembly iy not processed by 'SignumTask'
Source=Signum.Entities
StackTrace:
at Signum.Entities.Reflection.Reflector.CheckSignumProcessed(FieldInfo fieldInfo) in C:\Projects\git\SailingForecast\Framework\Signum.Entities\Reflection\Reflector.cs:line 304

Adding SignumTask to the project breaks the build with an "Object reference not set to an instance of an object." exception.
To me it looks that even though the Dump ExtensionMethod is declared on object, it actually requires an object of type Entity.

So I have two questions:

  • Why is the check of SignumTask built in?
  • What do I need to do make it work on all objects again?

The check is there to guide a developer in the common case of using Reflector.TryFindPropertyInfo for entities, but ObjectDumper uses it for general objects.

What should be the behavior for POCO classes, serializing the properties or the fields?

If case of properties probably changing the line:

if (t.IsAnonymous())

By

if(!typeof(ModifiableEntity).IsAssignableTo(t))

Should work.

In case of fields is more complicated, and probably will be better to change Reflector.TryFindPropertyInfo to avoid the check for non-entities and keep the old behavior.

Check what works better for your case. Pull requests accepted :)

Von meinem iPhone gesendet

Am 30 mar 2016 um 10:54 schrieb ghockx1p notifications@github.com:

I'm using the ObjectDumper to log the state of classes when they are put in an MSMQ messagebody. These are simple classes not inhereting from Entity and they only contain attributes.
In October the ObjectDumper has been modified in such a way that it now produces the following exception on Dumping my class:

System.InvalidOperationException occurred
HResult=-2146233079
Message=Entity {0} has auto-property {1}, but you can not use auto-propertes if the assembly iy not processed by 'SignumTask'
Source=Signum.Entities
StackTrace:
at Signum.Entities.Reflection.Reflector.CheckSignumProcessed(FieldInfo fieldInfo) in C:\Projects\git\SailingForecast\Framework\Signum.Entities\Reflection\Reflector.cs:line 304

Adding SignumTask to the project breaks the build with an "Object reference not set to an instance of an object." exception.
To me it looks that even though the Dump ExtensionMethod is declared on object, it actually requires an object of type Entity.

So I have two questions:

Why is the check of SignumTask built in?
What do I need to do make it work on all objects again?

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

Hi, anyway the error message seems crappy (lacks FormatWith and typo error)

Thanks for the pull request!