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

model bind for type like datetime guid always failed. #18

Closed
Eilyyyy opened this issue Jul 27, 2017 · 9 comments

Comments

@Eilyyyy
Copy link

commented Jul 27, 2017

when you send message type that can simplely convert from string like guid, datetime, you always get a format exception that not valid value for this type. the problem is than you publish message always use json string , but you can't just use typeconvert convert json string to a object.

@Eilyyyy

This comment has been minimized.

Copy link
Author

commented Jul 27, 2017

i think you can fix this problems by serialize simple type of message just use to string method, or always treat as complex type.

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Jul 27, 2017

Hi @Eilyyyy , thanks for your feedback.

I have already fixed this bug at commit 297cecf.

I will release a new version later.

@Eilyyyy

This comment has been minimized.

Copy link
Author

commented Jul 27, 2017

tim 20170727155751
i'm sure i'm on this commit but the problem is still here.

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Jul 27, 2017

you mean that you are using this void Publish<T>(string name, T contentObj) overloaded method to publish message with datetime or guid?

@Eilyyyy

This comment has been minimized.

Copy link
Author

commented Jul 27, 2017

yes, PublishAsync

@Eilyyyy

This comment has been minimized.

Copy link
Author

commented Jul 27, 2017

i think the problem is here
var isComplexType = !TypeDescriptor.GetConverter(type).CanConvertFrom(typeof(string));

this type can convert from string , so you treat it as simple type.you serialize a 134 you got 123, but you serialize a guid you got a "xxxx-xxxxxx-xxxx", notice you have a quotation marks and this cause you can't convert from the content.

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Jul 27, 2017

Yes, I didn't consider this kind of situation, I will fix it later, thank you.

@yang-xiaodong yang-xiaodong added bug and removed fixed duplicate labels Jul 27, 2017

yang-xiaodong added a commit that referenced this issue Jul 28, 2017

@yang-xiaodong yang-xiaodong added the fixed label Jul 28, 2017

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Jul 28, 2017

Hi @Eilyyyy
I fixed this problem and removed the overloaded method of publishing string content.

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Aug 4, 2017

fixed at v1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.