liubiao4123 / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 0 forks source link

Issue with Deserialization when class contains a read only property #55

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi !

Congratulations for this great project. I am a big fan !

What steps will reproduce the problem?

I have a class like this one :
public class SomeClass
{
    public int Prop1 {get; set;}

    private Dictionary<int, SomeOtherClass> _dictionary = new Dictionary<int, SomeOtherClass>();

    public SomeOtherClass this[int id]
    {
        get { return _dictionary[id]; }
    }

[...]
}

and I store many instances of it in Redis. (using ServiceStack.Redis).

What is the expected output? What do you see instead?

When getting a value from Redis, I have an exception :

Message : Operation could destabilize the runtime

   at lambda_method(Closure , SomeClass)
   at ServiceStack.Text.Common.WriteType`2.WriteProperties(TextWriter writer, Object value) in ..\Redis\ServiceStack.Redis\ServiceStack.Text\Common\WriteType.cs:line 101

What version of the product are you using? On what operating system?

Windows 7,
Unfortunately, and i am ashamed of that, but i don't remember what version i 
downloaded. Sorry about that, and i hope this is not an issue that is resolved 
in an earlier version.

Please provide any additional information below.

I managed to correct the source code by modifying 
ServiceStack.Text.Common.WriteType class.
I modified the Init method, when PropertyWriters is initialized. I only take 
write enabled property.

var propertyInfos = typeof(T).GetSerializableProperties().Where(p => 
p.CanWrite).ToArray();

Maybe i'm doing something wrong here, and i may not use the library correctly.

Please let me know if you need more information !

Thanks,
Guillaume

Original issue reported on code.google.com by Gouff...@gmail.com on 2 Feb 2011 at 2:55

GoogleCodeExporter commented 8 years ago
Hi Guillaume,

Thanks for your interest!

Note: ServiceStack has now moved to GitHub with the latest version split out 
into more modular separate projects (The main ServiceStack.dll or 
ServiceStack.Redis.dll still includes an amalgamation of the required 
assemblies - so structurally its still the same and in most cases you can 
upgrade my replacing dlls):

Can you check out the latest version of the project in GitHub and let me know 
if this is still a problem? Thankx

All ServiceStack sub projects can be found at:
https://github.com/mythz

You will probably be more interested in:

https://github.com/mythz/ServiceStack.Text - JsonSerilaizer
https://github.com/mythz/ServiceStack.Redis - Redis Client

https://github.com/mythz/ServiceStack - combination of all sub projects

Original comment by demis.be...@gmail.com on 2 Feb 2011 at 3:39

GoogleCodeExporter commented 8 years ago
Thanks for your answer. Indeed, I should have checked the latest version before 
posting an issue. But now that I have, I still have the same issue !

Original comment by Gouff...@gmail.com on 2 Feb 2011 at 4:11

GoogleCodeExporter commented 8 years ago
Hi Guillaume,

No worries, it smells a lot like the bug I may have co-incidentally fixed last 
night in the ServiceStack.Text project :)

Anyway, I'll try get this setup in a test-case and fixit tonight, but a new 
Redis client build wont be cut until @boxerab has finished adding the new 
message queuing features into the client. I'll send you a link to a nightly 
build when I sort it out.

Cheers,
Demis

Original comment by demis.be...@gmail.com on 2 Feb 2011 at 4:49

GoogleCodeExporter commented 8 years ago
Great !

Thanks for your reactivity and support.

Cheers,
Guillaume

Original comment by Gouff...@gmail.com on 2 Feb 2011 at 4:58