OData-Version header values (V3 version)
https://aspnetwebstack.codeplex.com/workitem/1749
This fix adds a version constraint to the ODataRoute that will prevent
it from matching any request with a v4 version header or a request with
a v1-v3 version header whose value is outside of the range of this
constraint. The default range for the constraint is 1.0 to 3.0, but this
can be changed by removing the constraint and adding a different one
with a different range. This constraint will still match any request
without version headers.
OData-Version header values (V4 version)
https://aspnetwebstack.codeplex.com/workitem/1749
This fix adds a version constraint to the ODataRoute that will prevent
it from matching any request with a v3 version header or a request
with a v4 version header whose value is different than 4.0.
This constraint will still match any request without version headers.
Conflicts:
test/System.Web.OData.Test/HttpRouteCollectionExtensionsTest.cs
is requested.
https://aspnetwebstack.codeplex.com/workitem/1718
This change fixes the broader problem by handling null values in general,
not just for raw values. We replaced ODataNullValueAttribute with
ODataNullValueMessageHandler. This message handler will convert null
requests for individual entities or singletons into 404 responses and
will convert null requests for non collection properties (navigation
or structural) into 204 responses. This behaviour is not enabled by
default. The user needs to plug in the message handler as a per route
handler when he registers the OData route.
annotation, the ETag header should also be set.
https://aspnetwebstack.codeplex.com/workitem/1711
Created a specific MapODataServiceRoute overload to make registering
per route HttpMessageHandlers in OData routes easier.
annotation, the ETag header should also be set.
https://aspnetwebstack.codeplex.com/workitem/1711
Created an ODataETagMessageHandler to take care of calculating and
adding the ETag Header to the response when it's a successful response
that returns a single resource with an ETag defined and the response
status code is different than NoContent.
ODL 6.3 is released and available on nuget along with the source code.
Here is the change summary of ODL in this release:
1. Fix a bug for serializing floating-point values to NaN, INF, and -INF.
2. EdmLib & ODataLib now supports model reference.
3. ODataLib now supports reading and writing delta response.
4. EdmxReader supports ignoring the unknown attribute/element in new
TryParse API.
5. ODataUriParser adds support for parsing relative Uri without service
root
So, The summary in this migration is:
1. Update to ODL V6.3 package
2. Fix the test cases.
the spec. https://aspnetwebstack.codeplex.com/workitem/1810
The actual issue is that the version that was being calculated is the one for the
response and the codeplex issue describes the algorithm that calculates the request
version.
This change refactors the current v4 implementation for calculating the response by
moving the constants for the version headers to HttpRequestMessageProperties,
defining separate internal properties for the values of the OData-Version and
OData-MaxVersion and moving the logic for calculating the version to use in the
response to the ODataMediaTypeFormatter.
the spec. https://aspnetwebstack.codeplex.com/workitem/1810
The actual issue is that the version that was being calculated is the one for the
response and the codeplex issue describes the algorithm that calculates the request
version.
This change refactors the current v4 implementation for calculating the response by
moving the constants for the version headers to HttpRequestMessageProperties,
defining separate internal properties for the values of the OData-Version and
OData-MaxVersion and moving the logic for calculating the version to use in the
response to the ODataMediaTypeFormatter.
Issue 1751: OData V4 Responses MUST include the odata.metadata parameter(odata.metadata=full,
odata.metadata=minimal or odata.metadata=none) to specify the amount of metadata
included in the response in V4
https://aspnetwebstack.codeplex.com/workitem/1751
Issue 1741: Charset parameter should not show in Content-Type in response if Accept in request
don't has it
Rewrote SetDefaultContentHeaders in ODataMediaTypeFormatter to fix both issues.
https://aspnetwebstack.codeplex.com/workitem/1768
Reverted a change that made the internal cache of EdmStructuredObject
use a tuple of the property name and the IEdmStructruredType instead
of a tuple of the property name and the object type as the key for the
cache.
The issue was caused because the GetOrCreatePropertyGetter method
incorrectly cached a getter delegate using the EF dynamic proxy and
later on it tried to use that same getter with the actual type, which
resulted on a cast exception.
Reverting the cache to use the type instead of the IEdmStructuredType
will solve that problem as each type will have it's own getter. This is
also the behaviour the system exposed before model aliasing was
introduced.
exception without EnsureInitialized.
https://aspnetwebstack.codeplex.com/workitem/1752
This fix changes the behavior to be the same exposed by Web API, which is
throwing an InvalidOperationException with the same error message as in Web API.
apply at *any* properties.
In OData Convention Model Builder, it will the property
that is annotated with the Key attribute and follows the "schema Id |
TypeName + Id".
We should suppress the convention rule if any properties were annotated
with [key].
Here is the example which can illustrate this modification:
Suppose we have the CLR type as:
=========================================
public class Customer
{
[Key]
public string Path { get; set; }
public long CustomerId { get; set; }
...
}
Then, we use OData Convention Model builder to build the EdmModel:
=========================================
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Customer>("Customers");
....
builder.GetEdmModel();
In $metadata, there are two keys existed:
=========================================
<EntityType Name="Customer">
<Key>
<PropertyRef Name="CustomerId" />
<PropertyRef Name="Path" />
</Key>
<Property Name="Path" Type="Edm.String" Nullable="false" />
<Property Name="CustomerId" Type="Edm.Int64" Nullable="false" />
Originally, User is explicitly decorated [Path] as the key, so, the
[CustomerId] shouldn't treat as key. So, this modification will suppress key
convention once [Key] explicitly apply at *any* properties.
return IQueryable<T> instead of IQueryable.
https://aspnetwebstack.codeplex.com/workitem/1756
Added a generic overload on Etag<T> (The type of the IfMatch and IfNoneMatch
properties on ODataQueryOptions<T>).
HttpTaskAsyncHandler should not ever exceptions except in the case
of a really unfixable error. This change will call request.Abort() and
terminate gracefully instead of reporting an error.
issue-#1789 must also be fixed for this to handle all cases. Right now
this can only handle cases where we fail deep in infrastructure methods.
- provides default top-level element when not overridden in
`ValidationSummary()` calls
- also HtmlHelper access to ValidationSummaryMessageElement setting
This feature is to support open complex type in WebAPI.
Open Complex Type is a complex type with declared and dynamic properties.
The user can use IDictionary<string, object> to define a property in his
complex type (CLR class), then the WebApi model builder can build this
complex type as open complex type. The end user can post their dynamic
properties for this open complex type to the service in the payload, then
he can get their dynamic properties from the service in the future to do
futher process.
The Replace option currently available in AjaxOption replaces the contents
but not the element itself. The newly introduced ReplaceWith option
matches the replaceWith semantics of jQuery.
Work Item: 1500
handling/logging
The issue here is that when an action (or ApiController infrastucture)
throws an exception, it might be handled along one of two code paths
depending on whether or not any exception filters are configured.
If any exception filters are present, the logging/handling will take
place inside the 'IExceptionFilters' block. Otherwise logging/handling
will take place inside the 'HttpControllerDispatcher' block.
The 'IExceptionFilters' block would correctly provide a ControllerContext,
and the 'HttpControllerDispatcher' block did not.
The fix is to, when possible, provide a ControllerContext in the
'HttpControllerDispatcher' catch block. Note that it is only possible to
provide a ControllerContext when an exception was thrown the controller or
action itself. If an exception is thrown during controller selection or
controller activation, there is no context, and thus none provided.
disk
When dealing with precompiled 'non-updateable' applications, deleting
marker files was allowed in earlier iterations of Mvc. This change
restores this behavior.
Work Item: 1709
https://aspnetwebstack.codeplex.com/workitem/1838
Improve error message for the following case:
@if (true)
{
<script> var a= '<script></script>' </script>
}
The user code is wrong, and the script will be broken.
The browser will terminate the script at the first </script> inside
the string but will not report an error.
Razor catches it correctly, but the error message does not provide
enough clues to what went wrong.
Changes to support passing the original config in JQueryMVCFormUrlEncodedFormatter
Move Make HttpConfiguration constructor pass the
configuration into the JQueryMVCFOrUrlEncodedFormatter constructor and then pass it down to the FormDataCollectionExtensions.
Wrap the Configuration's Services to return only the necessary Services when ReadAs is called.
Adding Unit Tests.
1. Able to build an Edm model has a contained navigation property, using
convention model builder
Add a [Contained] attribute to mark a navigation property as containment.
2. Able to build a model has a contained navigation property, using model
builder
EntityTypeConfiguration<T>: ContainsMany, ContainsRequired,
ContainsOptional
These, and existing HasMany etc. can be used to override convention model
builder.
3. Able to build a model with a base type has a contained navigation
property, and the navigation property is inherited by a derived type,
using model builder and convention model builder.
4. Able to route for fundamental scenarios
../MyOrders(orderId)/OrdersLines
../MyOrders(orderId)/OrdersLines(lineId)
5. Able to serialize / des-serialize containment
6. Containment in expand
7. Calculate links via ODL
In derived scenario, when generate ID link (should be a Uri as per spec,
instead of string,) we should not append type cast at the end.
Previously, when webapi.odata generates an Id link, it will check if a
derived type has a nav prop, if yes, it will append a type cast (even if
the actual type is the same to the request one.)
After we leverage ODL for edit link generation, the edit link will be:
./service_root/es(key)/cast/cast
As per v4 spec, the editlink/readlink does include the type-cast; however,
according to convention the Id does NOT include the type-cast:
8. Fix test cases about editLink
9. Verify containment after composable function / action
Singleton is the new concept in OData V4. The meaning of it is to allow
user to create a special (unique) entity and such entity can be addressed
directly by its name. The behaviour of Singleton is very similar with
the behaviour of entity set but has different meanings.
Here is the scope of singleton feature:
1. Support Singleton configuration
2. Support Singleton manipulation on ODataModelBuilder
3. Support Singleton manipulation on ODataConventionModelBuilder
4. Support Singleton convention routing & attribute routing
5. Support Singleton serialization / dieselization
6. Support Singleton query option
7. Support Singleton navigation property
8. Support Singleton in Service document
9. Support Singleton action and function
The summary of migrating to latest ODL V6.2 from ODL V6.0 beta 1 :
1. Use ODL v6.2 RTM assemblies.
2. In ODataError, MessageLanguage is gone.
3. EnumNode is gone.
4. ElementType is gone -> EntityType().
5. WriteEntityReferenceLink -> one param.
6. EntityContainers() is gone -> EntityContainer, FindContainer is gone.
7. ReadEntityReferenceLink takes no param.
8. ParseOrderBy/Filter/SelectExpand static method is gone.
9. Version is gone in metadata.
10. IsAlwaysBindable is gone for action an function,SetIsAlwaysBindable is gone
11. GetServiceVersion is gone.
12. SetServiceDocumentUri is gone.
13. String function parameter should be single quoted.
14. Content-ID header check.
15. Change Enum value binder.
16. ODataUriNullValue -> ODataNullValue.
17. If an action or function is requested in a selectItem using a
qualifiedActionName or a qualifiedFunctionName and that operation cannot
be bound to the entities requested, the service MUST ignore the selectItem.
18. Only support Base64 format for binary.
19. Change to ODL V6.2 new UriParser for query option.
Since we do not know how the string will be parsed with a TypeConverter when generating the
sample query string, just do not display member properties of the type which is associated
with a TypeConverter. Instead, the type itself will be displayed.
This is a separated PR fixing 1567:
- Add support for generating query string of type Dictionary and KeyValuePair.
- Replace '.' with '-' in GetFriendlyId. Otherwise, RelativePath with . (like ModelType.Foo or ModelType[0].Foo)
will break the help page's uri
- Change the css of help page to make a long path more readable.
collection of primitive types and coming from Uri.
- Add support for primitive/complex collection(and arrays).
- separate helpers and increase readability.
- add XML comments
- use named parameters in added test methods (clarify nulls)
- rename added test methods to make expectations clear
- add three new tests to cover gaps
By adding a AreaReference enum, to be capable of setting Remote attribute or use the area which.
So, fix the problem of not being able to refer to the controller outside the area from inside the area.
resolved instances are only created once and then shared.
This fix only aims at the CreateActionInvoker() in the MVC Controller.
CreateTempDataProvider() will be fixed in a separate issue.
Moved ModelAliasingEnabled from ODataModelBuilder to ODataConventionModelBuilder.
Refactored the OData model builder conventions to take in an ODataConventionModelBuilder
instance.
The new IDirectRouteProvider api supports discovering IRouteFactory
on controller descriptors and action descriptors with arbitrary criteria.
DefaultDirectRouteProvider is given as a base class for customizing a
single aspect of the process.
Since criteria for whether or not an action/controller is attribute
routed is now arbitrary, I've added a marker to the descriptors. This
required some refactoring of the action selector, now caching proceeds in
two phases.
1. Existance of actions and descriptors are cached
2. Details used for action selection are cached.
2) will happen when requests come in, so attribute routing is allowed to
mark the descriptors before they are cached.
scenarios.
Renamed IDictionaryConvertible to ISelectExpandWrapper, made the
interface public public and changed the return type of its ToDictionary
method to IDictionary in order to allow using custom JsonConverters with
$select and $expand projections in both assemblies (v3 and v4).
https://aspnetwebstack.codeplex.com/workitem/1699
Per protocol bound action/function should not be added as
actionImport/functionImport. But now they become imports.
This bug is a regression from a previous checkin. I've fixed the bug and added
the respective unit tests to cover the cases that weren't tested and that caused
the behavior change to go undetected.
action/function.
ODL Spec Says:
11.5.3.1 Invoking a Function
...To invoke a function through a function import the client issues a GET
request to a URL identifying the function import and passing parameter
values using inline parameter syntax. The canonical URL for a function
import is the service root, followed by the name of the function import.
...
11.5.4.1 Invoking an Action
...To invoke an action through an action import, the client issues a POST
request to a URL identifying the action import. The canonical URL for an
action import is the service root, followed by the name of the action
import.
Add property `Group` into SelectListItem. Now DropDownList
, along with other kinds of select list, can render the <optgroup>
tag wrapping options if `Group` is set.
this action/function
[ODL spec says in 11.5.3.1 Invoking a Function]
To invoke a function bound to a resource, the client issues a GET request
to a function URL. A function URL may be obtained from a previously
returned entity representation or constructed by appending the namespace-
or alias-qualified function name to a URL that identifies a resource whose
type is the same as, or derived from, the type of the binding parameter of
the function. ....
read from Request.InputStream
If the result of GetBufferedInputStream was completely read, the buffered
stream is available via Request.InputStream. We can attempt to use instead
of proactively throwing.
Work Item: 1696
the binding parameter type MUST be unique within a namespace.
In this fix, a validation function added in GetEdmModel() to validate the
action overload:
1. For bound action overload, each overload action must have differnt
bingding type.
2. For unbound action, each unbound action must have different action
name.
Thanks.
and ConcurrencyCheckAttribute in ODataConventionModelBuilder
https://aspnetwebstack.codeplex.com/workitem/1423
Added support for ComplexTypeAttribute and TimestampAttribute, support for
ConcurrencyCheckAttribute already existed. Support for AssociationLinkAttribute
requires changes on the way we build the model that are out of the scope of
this fix.
https://aspnetwebstack.codeplex.com/workitem/1598
Setting is not navigable should also set IsNonFilterable and IsUnsortable
but not the opposite (setting IsNavigable should not set IsSortable or
IsFilterable)
Given a model with an entity, and a complex object. When we limit ordering in
the complex object it doesn't get respected and the following query succeeds
instead of returning bad request.
"/odata/QueryLimitCustomers?$orderby=HomeAddress/ZipCode"
if a function is overloaded and exposed as FunctionImport.
This fix is follow up the following ODL Spec:
The edm:FunctionImport for a parameterless function MAY include the
IncludeInServiceDocument attribute whose Boolean value indicates whether
the function import is advertised in the service document.
function is overloaded and bound to a derived entity.
2. Codeplex #1654 : In convention routing mode, the same method in a
controller is selected if action overloads for a collection of base type
and one for derived type are requested.
This change splits the 'sanitization' of a request URL into a separate
helper function and ensure that it only occurs once per request.
Sanitizing the request URL is responsible for about 60% of routing
execution time in today's routing code.
There's also an optimization applied to perform faster validation of the
virtual path portion of the URL.
Url.Action overloads (and similar) ignore inherited properties.
This fix affects both WebAPI HttpRouteValueDictionary,
Overloads that take anonymous objects to construct a routevaluedictionary
and overload that takes anonymous objects to create HtmlAttributes.
The fix reverts the behavior to MVC5/WebAPI2/WebPages3 behavior where it will allow for derived properties to show up.
But it maintains the performance characteristics of MVC5.1/WevAPI2.1/WebPages3.1.
- Allow side-by-side use of all v3 / v4 extension methods and classes we previously injected into these namespaces
Move extension methods to System.Web.Http.OData.Extensions and System.Web.OData.Extensions
- Rename these methods to let users referencing the v3 assembly continue using them as extension methods
- Make most HttpRequestMessage extension methods properties of a new HttpRequestMessageProperties class
- Leave old locations in v3 assembly for binary compatibility but deprecate them to help users find the new locations
Narrow scope of a few internal extension methods
- Move RemoveRange to ODataFormattingAttribute (otherwise unused)
- Move one CreateErrorResponse overload to ODataActionSelector (otherwise unused)
Type forward SingleResult and SingleResult<T> to System.Web.Http.dll
- Currently special-cased only in OData [EnableQuery] scenarios but could be used elsewhere
Move remaining classes in System.Net.Http and System.Web.Http to System.Web.Http.OData and system.Web.OData
- Rename QueryableAttribute (the remaining public class) to EnableQueryAttribute
Other cleanup
- Run Remove and Sort Usings power tool, touching a few otherwise-unchanged files
- Remove implementations of MediaTypeFormatterCollection extension methods (moved to System.Web.Http.dll in earlier change)
- Improve wording of XML Comments, especially in EnableQueryAttribute and HttpRequestMessageExtensions
- Wrap to shorten long lines
1. Remove check for "if (serializer.ODataPayloadKind != ODataPayloadKind.Error)", since 669 is fixed.
2. Remove entity set path from UnboundFunctionPathSegment as per ODL v4 spec.
Work Item: #1632
1. #1620: FunctionImport doesn't apppear in the service document even
if IncludeInServiceDocument is true.
2. #1601: Add FunctionImports and Singletons to service document
3. #1636: Don't build action/function import for bound
action/function
- System.Web.Http.OData -> System.Web.OData
- Merge System.Web.Http.OData.TestCommon and System.Web.Http.TestCommon into System.Web.OData.TestCommon
- Add usings for System.Web.Http where necessary
- Remove and sort usings
Move AddRange and InsertRange extensions to base MediaTypeFormatterCollections class
- Feature is now available to all MediaTypeFormatterCollections users
- Obsolete extension methods in System.Web.Http.OData.dll
- Remove most of ODataMediaTypeFormatterCollectionExtensions extension class in System.Web.OData.dll
Will handle remaining extension methods in System.Net.Http and System.Web.Http namespaces in a separate review
characters
According the HTML5 specs, all characters besides space characters are
allowed in DOM ids. Consequently we need to ensure that certain characters
such as dot, colon and square brackets which can be interpreted as other
forms of jQuery selectors are correctly escaped.
Work Item: 1617
Update from v4 alpha2 to beta1 ODL:
1. ODataWorkspace -> ODataServiceDocument
2. Collection Type ref: isNullable inferred from element type ref
3. EdmTypeKind.Row is gone
4. Single container: IsDefaultContainer is gone
5. entry.Id is now a Uri
6. ODataMessageWriterSettings.BaseUri -> PayloadBaseUri
7. SetMetadataDocumentUri is gone -> SetServiceDocumentUri
8. ContainerQualifiedWildcardSelectItem is gone -> NamespaceQualifiedWildcardSelectItem
9. ParseSelectAndExpand parameter change
entitySet -> entitySetBase
10. navMapping.TargetEntitySet -> Target
11. SetIsDefaultEntityContainer is gone
EdmRowTypeReference is gone
12. IEdmRowTypeReference is gone
13. ReturnType of Function in csdl
Child element, instead of an attribute
14. Context url change: http://localhost/$metadata#Collection(Edm.Boolean)
15. Self link is gone, if the same to edit link
16. ServiceDocument is now default to json, instead of atom
17. MessageWriter by default writes json, instead of atom
18. Collection's nullablity is determined by its element
If no value is specified for a property whose Type attribute does not specify a collection, the Nullable attribute defaults to true
19. ODataMessage writer settings require a service document uri
20. "@odata.type":"Edm.Binary" -> "@odata.type":"#Binary"
21. Select action of a derived type from a base type, need to use type cast before action
22. Action should be prefixed with namespace
Work Item: #1632
Codeplex - #1622
1. Rename the ActionPathSegment to BoundActionPathSegment
2. Rename the FunctionPathSegment to FunctionPathSegment
3. Change IEdmActionImport to IEdmAction
4. Change IEdmFunctionImport to IEdmFunction
5. Modify helper codes in FunctionResolver and ProcedureHelper
6. Modify test cases and add more test casesn.
Codeplex - #1585
1. In ODL V4, It has changed $inlinecount to $count.
2. The value for $count is only true or false.
3. The true and false is case-insensitive.
Match the function name first, then the parameter in the function path
segment template
1. add the matching logic about the function name
2. add test cases
1. Follow up ODL V4 to use the IEdmActionImport and IEdmFunctionImport for
unbound action and function.
2. Unbound action and function routing is based only on attribute routing.
3. Add test cases for attribute unbound routing
ValidationResult.MemberNames if available.
This change sets the MemberName property for the ValidationContext passed
to validation attributes when validating. Additionally, we set the
MemberName on the returned ModelValidationResult if the validation
result indicates the validated member is different from the model being
validated.
Work Item: 729 1534 1606
We construct very many model metadata instances for the average request,
the current code creates a dictionary for each one that's used to store
context properties. None of the framework code uses these dictionaries,
they are provided for 3rd party extensibility -- so they will likely never
be read by most users' code.
As to the safety of this change, ModelMetadata has two different uses:
1. As a long-lived object that is cached
2. As a short-lived object that is only used by a single operation, on a
single thread
For #1, any intialization of the 'AdditionalValues' collection should
occur on creation - any other writes to AdditionalValues will have bugs in
the currrent implementation.
For #2, any reads/writes to 'AdditionalValues' are part of the same
operation and will not operate on shared data.
I've also included several instances of returning a readonly 0-length
array instead of a new 0-length array. This is always safe to optimize,
and these show up as hot spots when profiling memory usage of validation.
This change adds a ToArray call to the cached value for
GetQueryNameValuePairs, which should avoid reparses and remove a large
allocation for request-scoped memory.
Web API was missing support for this attribute in model metadata, which
MVC has had for some time. The support here is intended to be consistent
with MVC (DisplayAttribute takes precedence).
Use it like:
public class MyModel
{
[DisplayName("Zip Code")]
public int HorriblePropertyName { get; set; }
}
to provided a human-readable name for a property that will be used in
validation/error messages.
You can also subclass and override the DisplayName property to support
dynamically computing text or pulling it from a resource.
results in incorrect assignment
The conversion code in ValueProviderResult is duplicated from Mvc and
expects array types for request parameters with multiple values. However
WebAPI uses List<T> to represent these values. Consequently the conversion
code falls through resulting in incorrect representation.
This change updates the ValueProviderResult to expect instances of IList
which should address both array and List<T> types.
Work Item: 1563
Broke the existing IsAcceptableInsertion into two parts, a "inner" and
"end" insertion check. An inner insertions only allows '.' insertions
within the middle of spans. Also added 2 tests to verify correctness.
Added a new accept case in the ImplicitExpressionEditHandler's
CanAcceptChange method to accept potential intermediate steps
of selecting intellisense with characters such as '.'. Included 4 test
cases to verify functional accuracy.
jQuery expects a numeric value load duration. However unobstrusive ajax
passes it the attribute value (a string type) when it is set. This
change ensures we parse the value as a decimal if it's set.
Work Item: 1520
- https://aspnetwebstack.codeplex.com/workitem/1480
- "SampleGeneration in HelpPage not working for PageResult<T>"
- General gap is support for creating complex objects lacking a parameterless
constuctor.
- Implemented approach also supports overriding data used in (say) an
ICollection<T>
- New SampleObjectFactories list extends previous ObjectGenerator.GenerateObject()
fallback and is checked after the type-specific SampleObjects property
- Avoids subclassing HelpPageSampleGenerator just to override GetSampleObject()
- https://aspnetwebstack.codeplex.com/workitem/1558
- "[OData] Incorrect use of EdmTypeCannotBeNull message"
- Make three uses of this resource string consistent
- PLOC issue primarily in EntityInstanceContext.GetPropertyValue() because message
mentioned "an System.Web.Http.OData.IEdmObject"
- Problem more than a PLOC issue since ODataSerializerContext.GetEdmType() would
throw NRE not intended Exception and ODataMediaTypeFormatter.GetSerializer()
would reference incorrect Type in Exception message
- Also add tests covering these sad paths (2 were missed)
types to the RelativePath
https://aspnetwebstack.codeplex.com/workitem/1372
The scope of this fix is for complex types that have FromUri attribute on
the parameter or on the class and for which all their properties are
convertible from a string. By design, it will skip complex parameters with
properties that are not convertible from string as it's not a common
scenario and complicates the fix.
For actions that have more than one complex type that matches the criteria
above, we will emit prefixes to avoid ambiguity, in any other case, we wont.
ignored
ValidationResult returned by a ValidationAttribute may reference one or more
member names which are currently ignored. We'll address this by
translating this as a ValidationResult for each of the members if
specified.
Work Item: 1534
This change allows WebAPI to use the async buffered request stream
in web host.
There are two ways to get a buffered request stream in webhost:
- GetBufferedInputStream(): is async, and buffered, but not seekable
- InputStream: is buffered and seekable, but not async
This causes a problem, because async is good... but we need seekable
streams, as we've surfaced this functionality to the user-code.
Conveniently, once you've read to the end of the GetBufferedInputStream,
it will also fully populate the buffer of InputStream. The fact that the
buffer of InputStream is fully populated means that its non-async
operations become preferrable once the buffer is finished loading, so we
have a stream that's seekable, and buffered, and we no longer care about
async at that point.
The solution is to wrap up both of these streams, so that once we've read
to the end of the 'async' stream, we start using the 'non-async' stream.
This offers the performance advantages of both cases, while preserving
seekability.
The special case we have to handle for seek is when the 'non-seekable' stream
is being used, we finish reading the end and then swap to the 'seekable'
stream. This needs to be done syncronously because of the contract for
Seek. This will only really occur in cases where user code gets the stream
and manually does seek operations instead of just reading it. Basically we
don't expect this case to be common, and it should perform about as well as it
currently does.
Katana already has a similar solution in place, and I borrowed some ideas
from them - our version is a bit simpler because we have simpler
requirements.
(cherry picked from commit addff083c4cf60c390ccb1e217fde4a369004b99)
- https://aspnetwebstack.codeplex.com/workitem/1557
- "Fix errors in OData resource strings"
- Basic PLOC issue
- Also pick up missed addition to repositories.config for new OData projects
(VS keeps insisting)
1. Copy System.Web.Http.OData to System.Web.OData
2. Copy System.Web.Http.OData.Test to System.Web.OData.Test
3. Generate new project guids
4. Set new src project InternalsVisibleTo to new test project
5. Update with latest changes from System.Web.Http.OData and the test project
6. Add 2 new projects to SkipStrongNames.xml
7. AssemblyTitle change
8. Move SuppressMessage from AssemblyInfo.cs to GlobalSuppressions.cs
9. Not change test project System.Web.OData.Test's RootNamespace (System.Web.Http) for now, since test resource files depend on it.
10. Suppress CA1704:IdentifiersShouldBeSpelledCorrectly for Unsortable.
- https://aspnetwebstack.codeplex.com/workitem/1479
- "Help page font flickers on navigating to service url or help page home"
- Problems arise due to lousy HelpPage.css link placement and application of
help page styles to site banner and footer
- Scope styles in HelpPage.css to elements beneath one with the help-page
(or existing help-page-table) class
- Correct HelpPage.css style for the <body/> element to apply to the
<div id="body"/> element in all three help page views
- Move HelpPage.css link to the top of the help page views, avoiding current
placement at the bottom of the page when using application layout
- Use help-page class at top of the help page views
The request invoker in jquery.unobstrusive-ajax.js did not specify a
context. Consequently callback functions specified using AjaxOptions would
be executed in the context of the Ajax options object which is
uninteresting. Fixing this so that the context points to the triggering
element.
Work Item: 1487
An earlier change here makes the PushStreamContent call dispose on any
stream that's passed in to its SerializeToStreamAsyncMethod (only in
portable library). The comments indiciate that this is necessary because
HttpContent doesn't 'own' the stream.
When the stream is disposed, that makes it unreadable for callers, so any
type of system that tries to buffer PushStreamContent is inherently
broken. HttpContent does this by default in a variety of cases including
simply sending a message with HttpClient.
If a dispose call is really needed, it should be performed by whichever
object 'owns' the stream, and definitely not by the PushStreamContent,
which doesn't own the stream. In all the use cases I could find, the
stream is disposed by HttpContent - additionally, in all of these cases
the provided stream is a MemoryStream, which holds no native resources.
This feature is totally broken right now for portable, if there are cases
where the resource ownership model changes for portable as a result of
this fix, we should discuss those, as most scenarios with this class are
broken right now -- it can hardly get worse.
This is a partial fix for Codeplex-777, which asks that we make Delta<T>
work with the JsonSerializer.
This fix is only partial, because our implementation of GetMember and
SetMember don't perform conversions. So if you provide an int to a
property that wants a double, then it won't serialize that property. A
full fix for this requires some advanced use of JSON.Net's API and will be
published in a sample
return type.
This change unifies the handling of actions with an IHttpActionResult
return type with other actions. Previously we've treating methods
declaring the return type to be IHttpActionResult (or derived) to be
treated specially.
- Only methods with IHttpActionResult return type can use
IHttpActionResult
- Handling of HttpResponseException is different for methods with return
type of IHttpActionResult.
These choices were intentional, but now we're reversing them based on
feedback. Now it's possible to return NotFound() or a data object, or an
HttpResponseMessage from an action method with return type of object.
This means that IHttpActionResult is checked before calling into the
action's IActionResultConverter. The documentation for
IActionResultConverter already documents this, and it doesn't really need
to be updated. The difference is that the logic is now based on dynamic
type instead of static type.
Remove empty constructors that where there for unit testing only, but where not critical for unit tests as Exception and CatchBlock are very easy to mock.
Thus removing multiple unnecessary unit tests, and unnecessary tests in the code to verify that the unit tests constructors are not called by users.
We were using a unit test only constructor in
AttributeBasedPolicyProviderFactory that resulted in some of the
properties being not set for a ControllerContext.
Work Item: 1286
- https://aspnetwebstack.codeplex.com/workitem/1484
- "[HelpPage]Null ref exception when using UriPathExtensionMapping"
- Problem is more general than reported issue: NREs occur when loading help
pages whenever routes contain undeclared (i.e. unused) parameters.
- nit: Add Contract.Assert() when creating ApiParameterDescription for
declared parameters.
Known issues with optional unused parameters (aka "undeclared" though they're
declared in the route template -- just not in the action method) and those with
default values in the route configuration: These parameters will not be
included in the route template strings (eliminated deep in HttpParsedRoute.Bind())
or the URI parameter table (skipped in ApiExplorer.AddUndeclaredRouteParameters()).
These corner cases can't be fixed without breaking changes.
- https://aspnetwebstack.codeplex.com/workitem/1471
- "WebApi validation ignores ErrorMessage in Required Data Annotation attribute"
- Problem was specific to MutableObjectModelBinder and only visible when using
[FromUri] binding ([Required] validators are not normally special-cased)
- Update that binder to execute [Required] validators when appropriate
- Add tests for missing required property cases in ProcessDto()
- nit: Improve efficiency of HashSet of missing required properties
This problem can't be fixed; there's public surface area to model bind
this data without providing a request. For now, we'll resolve this issue
by identifying the problematic use case in in the constructor.
HttpResponseException
1) GetTraceLevelAndException defaults to the callers trace level which is
incorrect. Using TraceLevel.Error as default while tracing exceptions
instead of the callers trace level.
2) minor refactoring.
- http://aspnetwebstack.codeplex.com/workitem/1440
- "Roundtripping DBNull value using Bsonformatter thrown an error"
- https://aspnetwebstack.codeplex.com/workitem/1457
- "Bsonformatter throws an error when passing simple types as ObjectContent"
- Switch checks for serialization as Dictionary<string, object> to use runtime type
- Special-case DBNull.Value on write (serialize empty content) in
BsonMediaTypeFormatter.WriteToStream()
- Special-case DBNull type and empty content on read (return DBNull.Value) in new
BsonMediaTypeFormatter.ReadFromStreamAsync() override
- Add unit tests for round-trips with minimal type information and with DBNull values
- Use new unit test helper for round-trip tests
Initial fix for this issue is done with commit a14733ff07 which has a
breaking change. Commit 6b64e226a has the non-breaking change but it
didn't revert the breaking change done in commit a14733ff07. This change
just reverts the inital fix (a14733ff07).
This commit is a fix on top of a previous fix that addresses
deserializing collection parameters.
The ODataActionPayloadDeserializer has been refactored to use the
ODataCollectionDeserializer internally when deserializing collection
parameters.
Resource type should not be repeated for simple types (fixes#1461).
Show XML documentation for request body parameter (fixes#1460).
Fix font size for h3 tags.
NameValuePairsValueProvider
TypeMatchModelBinder doesn't do model validation. This used to be fine in
most cases as the default value providers only support primitive value
types that require no validation. Now that ODataController supports a
valude provider that can store complex objects(ODataValueProvider), we
should do model validation in TypeMatchModelBinder as well.
- http://aspnetwebstack.codeplex.com/workitem/1442
- "EditorFor converts DateTimeOffset property to text type instead of datetime type"
- Enable use of same default editing template for DateTimeOffset as for DateTime
- Also fill unit test gap: Confirm view names for more value types
This change will allows child actions to be used when a global value has
been set for the outputcache 'location'. Current we don't allow you to
customize the location on a child action - which can block the use of
child actions entirely. This change will allow you to set any of the
'non-server' cache locations on child actions.
The Mime spec does not require the last part of the request to be
terminated with a CRLF. Our parser current requires this extra CRLF, but
we've discovered some popular tools which don't append it. This fix will
bring our parser up to spec for this case.
The end of a Mime multipart message is detected by the presense of the
'boundary' token followed by the literal '--' and then optional whitespace
and an optional CRLF.
Ex: (boundary is 'endsection' in this example)
BEGIN
--endsection
some content
--endsection
more content
--endsection--
END
So, the final line '--endsection--' may or may not be terminated with a
CRLF (newline) in a legal request.
The complication with this fix is that we require the last part of the
parse to consume the end of the input stream. It's not enough to see
'--endsection--' and declare that we've seen the end of the message, we
want to capture any text or invalid characters following the final
boundary.
In order for this to be possible, we need to reinvoke the parser with the
empty array when we run out of bytes to signal the end of the parse. This
requires some changes to validation logic to facilitate the re-entry of
the parser for this special case.
Also added a DebuggerDisplay for the parser's state to make things easier
to visualize.