-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Removed binaryformatter replaced with json serializer #2264
Removed binaryformatter replaced with json serializer #2264
Conversation
f40a54c
to
4a37969
Compare
{ | ||
formatter.Serialize(outputStream, sourceObject); | ||
var jsonSerializer = new JsonSerializer(new JavaScriptSerializer()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we really new this up every time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why haven't we #ifdef'ed this to use BinaryFormatter
where available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because JS will work for both I guess
e1fe850
to
6714147
Compare
81a5de9
to
86b71c5
Compare
@@ -1531,6 +1537,9 @@ | |||
<Link>Diagnostics\Views\login.sshtml</Link> | |||
</EmbeddedResource> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="packages.config" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see this anywhere?
8fa36e7
to
19afc01
Compare
IDictionary<string, object> expando = new ExpandoObject(); | ||
|
||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(value.GetType())) | ||
expando.Add(property.Name, property.GetValue(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing { }
So the one thing here is that this does not seem to handle object graphs. The |
@@ -34,8 +35,10 @@ public CsrfFixture() | |||
this.pipelines = new MockPipelines(); | |||
|
|||
this.cryptographyConfiguration = CryptographyConfiguration.Default; | |||
|
|||
this.objectSerializer = new DefaultObjectSerializer(); | |||
var fakeAssCatalog = A.Fake<IAssemblyCatalog>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People might get offended by the word 'Ass'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 This is the same as the adq
variable, why shorten it? fakeAssemblyCatalog
is waaaaay more descriptive. 👍 for changing this, even if it's not for the same reason @phillip-haydon pointed out ;)
19afc01
to
bf5bba8
Compare
@thecodejunkie seems to be ok or are you thinking more complex https://dotnetfiddle.net/0RDcN1 |
bf5bba8
to
2592da4
Compare
ff26612
to
68216cc
Compare
648c517
to
89f2f34
Compare
d158036
to
55391d6
Compare
I stand corrected :D |
Looking at AppVeyor, we should get #2274 in first and then rebase this? |
@@ -66,7 +66,7 @@ protected override void ApplicationStartup(TinyIoCContainer container, IPipeline | |||
|
|||
this.Conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("moo", "Content")); | |||
|
|||
CookieBasedSessions.Enable(pipelines); | |||
CookieBasedSessions.Enable(pipelines, container.Resolve<IAssemblyCatalog>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.AssemblyCatalog
should be all that is needed here, no?
fef04ee
to
98ff683
Compare
98ff683
to
14ac689
Compare
Removed binaryformatter replaced with json serializer
using (var outputStream = new MemoryStream()) | ||
private dynamic AddTypeInformation(object sourceObject) | ||
{ | ||
var sourceType = this.assemblyCatalog.GetAssemblies().Select(assembly => assembly.GetType(sourceObject.GetType().FullName)).FirstOrDefault(type => type != null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jchannon this can be replaced by sourceObject.GetType().AssemblyQualifiedName
can't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already do that a few lines below, this is finding the type in the list of assemblies to get the assembly qualified name as the object being serialized might be in a project just with pocos for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is finding the type in the list of assemblies to get the assembly qualified name
But why do you need to find it in a list of assemblies when you got the type right there? It's even used to get the FullName
of the type...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe AssemblyQualifiedName is empty if its a class in a separate poco lib or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You think? 😝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think thats some sarcasm I'm not getting 😄 We need to find the type in the assemblies to get the AQN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't think, you need to know.
The only way AssemblyQualifiedName
returns null
is if it's a generic type parameter. From MSDN:
The assembly-qualified name of the Type, which includes the name of the assembly from which the Type was loaded, or null if the current instance represents a generic type parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well if you hadn't insisted on one commit message per PR then I might have
something that jogs my memory why I added it.
Remove it, run the tests and if all is ok then consider me told
On Tuesday, 23 February 2016, Kristian Hellang [email protected]
wrote:
In src/Nancy/DefaultObjectSerializer.cs
#2264 (comment):
using (var outputStream = new MemoryStream())
private dynamic AddTypeInformation(object sourceObject)
{
var sourceType = this.assemblyCatalog.GetAssemblies().Select(assembly => assembly.GetType(sourceObject.GetType().FullName)).FirstOrDefault(type => type != null);
You can't think, you need to know.
The only way AssemblyQualifiedName returns null is if it's a generic type
parameter. From MSDN:The assembly-qualified name of the Type, which includes the name of the
assembly from which the Type was loaded, or null if the current instance
represents a generic type parameter.[image: image]
https://cloud.githubusercontent.com/assets/582487/13261618/49c94f20-da61-11e5-8eb1-937c659111c6.png—
Reply to this email directly or view it on GitHub
https://github.com/NancyFx/Nancy/pull/2264/files#r53822433.
address #2220