Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Conversation

@sornaks
Copy link

@sornaks sornaks commented Jul 29, 2014

Functional tests for Output Formatters are not a part of this PR. Will follow up with Functional Tests after @harshgMSFT's conneg check-in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on current Web API's xml media type formatter, this could throw in case the serializer doesn't support the given type...as in Web API should there be a check in CanWriteResult?...yeah, Json formatter doesn't do this check and it eagerly says true for all the types...the side effect of this here is that we do not let other formatters which can indeed handle the type...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WriterSettings.Encoding = context.SelectedEncoding;

This isn't thread-safe. Also a bad idea to mutate instance state based on per-request data. I think we'll need to make a copy of the writer settings if the encoding is different.

@yishaigalatzer
Copy link
Contributor

:shipit: when @rynowak is happy.

@harshgMSFT
Copy link
Contributor

:shipit: when @rynowak is happy.

Addressing some PR comments.
@sornaks
Copy link
Author

sornaks commented Aug 15, 2014

@rynowak - I've updated the PR Ryan. Please have a look :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this right below the other formatters in the file. See how it's already divided into sections?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI you can just do this like so:

[HttpPost]
public DummyClass GetDummyClass(int sampleInput)
{
    var result = new ObjectResult(new DummyClass { SampleInt = sampleInput });
    result.Formatters.Add(new XmlSerializerOutputFormatter());
    return result;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this level of fine-grained control is in the sweet spot of object result

@rynowak
Copy link
Member

rynowak commented Aug 15, 2014

:shipit:

@sornaks
Copy link
Author

sornaks commented Aug 15, 2014

Checked in - 2920c55

@sornaks sornaks closed this Aug 15, 2014
@sornaks sornaks deleted the XmlOutputFormatters branch August 18, 2014 23:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants