Граф коммитов

1777 Коммитов

Автор SHA1 Сообщение Дата
jacalvar a68b154808 Issue 1749 - OData V4 service do not properly handle invalid
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.
2014-05-07 15:01:00 -07:00
jacalvar d0c0162ab8 Issue 1749 - OData V4 service do not properly handle invalid
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
2014-05-07 13:50:23 -07:00
jacalvar 6ae0ac74bf Issue 1718 - System.ArgumentNullException is thrown if a raw value of null
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.
2014-05-07 13:09:07 -07:00
jacalvar 84c45e064d Issue 1711 [Part2] - When returning an Entity that contains an ETag
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.
2014-05-07 13:09:05 -07:00
jacalvar f3c840b01d Issue 1711 [Part 1] - When returning an Entity that contains an ETag
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.
2014-05-07 13:09:02 -07:00
jacalvar b75500e8d0 Issue 1753 - OData V4 service should not support DateTime
Added more guards to protect against mapping DateTime accidentally when
using the convention model builder.
2014-05-06 14:23:15 -07:00
dougbu 1eb185277f Remove trailing whitespace introduced in previous commit 2014-05-06 11:44:28 -07:00
fenzhao 9b2e2ed6f3 Support $filter and $orderby with ODL parser 2014-05-06 11:42:38 -07:00
fenzhao 9ac000ebd1 1907: ODataPathRouteConstraint.Match cannot get correct serviceRoot
This will fix IIS error on test branch.
2014-05-06 11:27:36 +08:00
Congyong Su 63b8c911c4 Fix 1839 : Add support to Requesting Entity References 2014-05-06 08:51:57 +08:00
Pranav K 8dd74d2a69 Adding support for overriding unobtrusive validation defaults
Work Item: 1502
2014-05-05 09:59:18 -07:00
fenzhao 278a82b978 support dollar id to specify the key of reference of entities 2014-05-05 10:04:44 +08:00
fenzhao 0ea58af2ac port to ODL parser to parse path and template 2014-05-05 09:48:25 +08:00
Sam Xu a6d00bf35d [Codeplex #1904]: Migrate to ODL V6.3
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.
2014-05-04 10:05:02 +08:00
Sam Xu 5e30c377e1 [Codeplex #1743]: Remove ATOM Support in WebAPI V4
Remove ATOM support in WebAPI V4 owing that ATOM is not in OData V4
standard currently and it is not fully support in OData V4.
2014-05-04 09:45:11 +08:00
jacalvar 0104bf8745 Issue 1810 - V3 fix ODataProperties().Version should be calculated according to
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.
2014-05-02 17:53:44 -07:00
jacalvar b2df7250ee Issue 1810 - V4 fix ODataProperties().Version should be calculated according to
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.
2014-05-02 17:39:16 -07:00
jacalvar afa7236163 Issue 1751 and 1741: Setting odata.metadata ContentType.Charset in OData responses
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.
2014-05-02 17:20:49 -07:00
jacalvar 8709d5c222 Issue 1768 - OData V4 requires disabling ProxyCreation in EF
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.
2014-05-02 08:06:56 -07:00
jacalvar 3ab3820639 Issue 1752 - OData V4 Routes.MapODataRouteAttributes throws the null reference
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.
2014-05-01 15:40:56 -07:00
Tian Pan 0960a69953 Revert "Fix 222: Route specific message handlers are not getting traced."
This reverts commit e4b7b86a6c.
2014-05-01 11:29:48 -07:00
fenzhao 3e6575639d fix 1867: The parameter of enum type in bound function does not work. 2014-04-30 09:51:22 +08:00
Sam Xu c7a00eae82 [Codeplex Issue #1782]: Suppress key convention once [Key] explicitly
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.
2014-04-30 09:37:58 +08:00
Ryan Nowak 72d1d55ae4 Do not treat canceled tasks as unhandled exceptions (fixes #1789). 2014-04-29 11:59:08 -07:00
Ryan Nowak a2fe4a2bd3 Adding IDirectRouteProvider for MVC 2014-04-29 11:43:16 -07:00
jacalvar bffa777419 Issue 1753 - OData V4 service should not support DateTime.
https://aspnetwebstack.codeplex.com/workitem/1753

StructuralTypeConfiguration.AddProperty now throws when the user tries
to add a property of type DateTime.
2014-04-25 12:29:50 -07:00
jacalvar d7afc7a6cd Issue 1756 - options.IfMatch.ApplyTo and options.IfNoneMatch.ApplyTo should
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>).
2014-04-25 10:29:12 -07:00
Ryan Nowak ec06c2ae49 Merge branch 'codeplex-1797' 2014-04-24 15:37:25 -07:00
Ryan Nowak 95b471ec23 Do not cause unhandled exceptions for canceled tasks (fixes #1797).
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.
2014-04-24 15:36:12 -07:00
dougbu 19e78f732f Add scoped `ViewContext.ValidationSummaryMessageElement`
- provides default top-level element when not overridden in
  `ValidationSummary()` calls
- also HtmlHelper access to ValidationSummaryMessageElement setting
2014-04-24 09:19:24 -07:00
Andy Butland 6119dc79c0 Amend validation summary method overrides to use named parameters 2014-04-24 09:17:35 -07:00
Andy Butland 21c99c6f13 Add additional parameter to ValidationSummary extension methods that allow the supply of an HTML tag to use for the summary heading, for improved accessibility 2014-04-24 09:17:33 -07:00
unknown 30a33648d7 [Codeplex Feature #1787]: Support open complex type for WebApi
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.
2014-04-24 14:36:16 +08:00
Pranav K 22c7da8986 Modify unobtrusive ajax to use element instead of passed in context for
callback functions
Work Item: 1702 1506
2014-04-23 10:13:51 -07:00
Pranav K 37636a7032 Adding support for "replace-with" InsertMode to jquery unobtrusive ajax
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
2014-04-23 09:50:19 -07:00
Tian Pan e4b7b86a6c Fix 222: Route specific message handlers are not getting traced. 2014-04-22 19:40:17 -07:00
Tian Pan 2764353b8e Fix 1820: Need a way to support disable <option> or <optgroup> using SelectList. 2014-04-22 12:41:03 -07:00
Tian Pan a195b5b710 Fix 1760: Make MultipartFormDataStreamProvider easier to work with non-FileStreams. 2014-04-22 10:45:01 -07:00
Ryan Nowak 32e2cfb73b Fix for Codeplex-1781 ControllerContext not set in exception
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.
2014-04-22 10:37:19 -07:00
fenzhao 1ae89ae603 1704: Delete ContainerQualifiedName in ProcedureConfiguration 2014-04-22 10:26:25 +08:00
Yishai Galatzer 48285655ae https://aspnetwebstack.codeplex.com/workitem/1762
Registration for disposal happened too late.

Registration was moved up the callstack and now preflight calls dispose correctly.
2014-04-21 13:59:06 -07:00
Pranav K 56a9d42334 Query the BuildManager for file existence when it cannot be located on
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
2014-04-21 11:21:47 -07:00
Yishai Galatzer c38bff24e9 Fix Codeplex issue #1838
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.
2014-04-18 12:49:18 -07:00
sornaks 21015f6ac1 BUG 1589: JQueryMvcFormUrlEncodedFormatter use wrong HttpConfiguration
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.
2014-04-18 10:22:29 -07:00
Congyong Su e4a0d36637 Task #1778 : Containment support to webapi.odata
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
2014-04-18 23:15:04 +08:00
sornaks 11e4c560b9 Introducing a new ValueProviderFactory to handle JQuery inputs. Introducing Lazy loading for initializing NameValueCollectionValueProvider data. Moving away from Lazy<T> 2014-04-17 16:27:08 -07:00
Ryan Nowak df39629e6c Adding phone 8.1 support for formatting 2014-04-17 14:01:34 -07:00
fenzhao d4cb4a90d0 add cast support in query option for primitive/enumeration types 2014-04-11 14:20:06 +08:00
Sam Xu c0a8e8914e [Codeplex taks #1776] Support Singleton feature
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
2014-04-10 13:42:05 +08:00
Sam Xu 7597205f4a [Codeplex Task #1825] Migrate to ODL V6.2
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.
2014-04-08 10:43:42 +08:00
Regis Bittencourt 14af553f99 Missing comma in jquery.unobtrusive-ajax.js creates a Global variable. 2014-04-04 09:59:55 -07:00
fenzhao e9f099a5c1 resolve further comments for lower camel case 2014-04-03 09:41:09 +08:00
Tian Pan 736aae76aa Fix 1737: Make TypeHelper.ObjectToDictionary(routeValues) public. 2014-04-02 13:12:27 -07:00
Tian Pan 22c91621ca Fix 1566: [HelpPage]Change UriParameters display when a parameter with TypeConverter is used
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.
2014-04-02 13:04:31 -07:00
Tian Pan 02ea2b8ca6 Fix 1567(2/2): [HelpPage]Api uri not displaying parameter which is a collection of primitive types and coming from Uri.
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.
2014-04-02 12:46:06 -07:00
Tian Pan 37c3da761e Fix 1567(1/2): [HelpPage]Api uri not displaying parameter which is a
collection of primitive types and coming from Uri.

     - Add support for primitive/complex collection(and arrays).
     - separate helpers and increase readability.
2014-04-02 12:46:05 -07:00
fenzhao 0aed73aa6a 1758: support lower camel case 2014-03-25 15:32:17 +08:00
trdai 4a9a2e8f8f Fix SA1514 on AreaReference.cs 2014-03-20 15:09:47 -07:00
dougbu 38c7ae6c58 Address CR comments on previous commit
- 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
2014-03-20 09:38:59 -07:00
shibayan d41f1ba068 Fixed behavior when combined area and Remote attribute
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.
2014-03-20 09:38:56 -07:00
Tian Pan 28ad38057a Fix 1726: Add ITempDataProviderFactory helping to create new instance per request
in Controller.CreateTempDataProvider().
2014-03-16 22:13:46 -07:00
jinfutan 241d2a639d Fix bug # 1747: FilterBinder treats nullable double as decimal. 2014-03-15 07:06:58 -07:00
Tian Pan 9517c374c0 Fix 1703: Add extra constructors to SelectList/MultiSelectList class making it easier
to create grouped lists.
2014-03-13 11:12:41 -07:00
Tian Pan 2d362ff39f Fix 1110 Trace more information from authentication filter tracers. 2014-03-12 15:42:09 -07:00
Tian Pan 58a4a69a3c Fix Support `disabled` attribute in <option> and <optgroup> from
SelectList.
2014-03-12 15:12:45 -07:00
Tian Pan c304be8994 Partially fix 1692. Using DependencyResolver with IActionInvoker the
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.
2014-03-12 14:26:26 -07:00
jacalvar fd9f0b7432 Added support for JsonProperty in $select and $expand projections
for the JsonMediaType formatter in System.Web.OData (OData v4.0)

DataMember is already supported through ModelAliasing
2014-03-12 11:06:47 -07:00
jacalvar e3503da696 Refactor ISelectExpandWrapper to add a ToDictionary method that takes
in an IPropertyMapper that allows for renaming of the properties during
serialization. (OData v4.0)
2014-03-12 11:06:46 -07:00
jacalvar 40494d378c Enabled model aliasing by default in Web API OData for v4.0.
Moved ModelAliasingEnabled from ODataModelBuilder to ODataConventionModelBuilder.
Refactored the OData model builder conventions to take in an ODataConventionModelBuilder
instance.
2014-03-11 11:21:13 -07:00
jacalvar aebf4868a2 Added support for JsonProperty and DataMember in $select
and $expand projections in the JsonMediaType formatter
in System.Web.Http.OData (OData v3.0)
2014-03-10 13:27:03 -07:00
jacalvar b92c0b7de3 Refactor ISelectExpandWrapper to add a ToDictionary method that takes
in an IPropertyMapper that allows for renaming of the properties during
serialization. (OData v3.0)
2014-03-10 13:26:54 -07:00
Ryan Nowak ced363bb59 Adding support for custom discovery of IRouteFactory
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.
2014-02-27 15:00:38 -08:00
jacalvar a31eab7e87 Issue 1676 - Expose IDictionaryConvertible for advanced query composition
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).
2014-02-26 14:20:31 -08:00
Tian Pan d5af8f5f39 Work Item 1110 Trace more information from authentication filter tracers.
Now it will be logged that a authentication filter short-circuits or sets a principal.
2014-02-25 14:40:33 -08:00
Congyong Su 0287c8256d Fix 1717 : Batch request doesn't work
Do not copy request property "MS_RoutingContext" from batch request to sub-requests.
2014-02-25 16:07:25 +08:00
Max Toro 7106bb356b Fix #1687: [EditorTemplates] Support htmlAttributes as IDictionary<string, object> for dynamic scenarios 2014-02-24 18:06:56 -08:00
Congyong Su a7ef4f5ed4 1715 : Removing EntitySetController and AsyncEntitySetController 2014-02-24 14:01:40 +08:00
Congyong Su 17004866e8 Fix 1690 : IfNoneMatch doesn't work
The expression should be parameterized
The expression should be Not Equal instead of Equal
2014-02-24 13:46:25 +08:00
dougbu a452f2a267 Fix #1693, route resolution failure for /$metadata in SxS scenarios
- Rename ODataMetadataController to avoid route ambiguity
2014-02-21 14:53:19 -08:00
jacalvar 09e8468a33 Issue 1699 - All functions and actions are added as function imports and action imports.
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.
2014-02-21 14:38:20 -08:00
Tian Pan f718787ad4 CR Feedback. 2014-02-21 12:22:28 -08:00
Sam Xu 105a5304a5 [Codeplex #1695]: Only function/action import name used to call an unbound
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.
2014-02-21 09:52:32 +08:00
Tian Pan 0326980c42 Work Item 1486 Support HTML optgroup in DropDownList.
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.
2014-02-20 13:46:24 -08:00
Congyong Su 582809a52b Fix 1578 : Rename method AddEntity to AddEntityType
1. Rename method AddEntity to AddEntityType.
2. Change method Entity() to EntityType().
2014-02-20 15:48:15 +08:00
Sam Xu 82b9599166 [Codeplex #1661] : Unqualified action/function name should fail when call
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. ....
2014-02-20 10:27:46 +08:00
Sam Xu 56f99af3c0 [Codeplex #1685]: Qualified name of action/function should be returned in
advertising.
2014-02-20 09:33:27 +08:00
Pranav K e0a53c23c6 Modify HttpControllerHandler.ConvertRequest to not throw if request can be
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
2014-02-19 12:24:29 -08:00
fenzhao 8d87c8682c fix 1689: KeyValueParser should throw without key or value 2014-02-19 10:35:02 +08:00
Congyong Su 5007766cde Change $link to $ref
$ref is the last segment in v4.

work item: #1582
2014-02-18 22:30:24 +08:00
Sam Xu d0859354f2 [Codeplex #1653]: For bound actions, the combination of action name and
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.
2014-02-18 17:08:17 +08:00
Congyong Su 4a7698d13a Fix 1643 : SelectExpandQueryOption doesn't create the select expand clause properly 2014-02-18 16:41:47 +08:00
Sam Xu 05bd3b0aec Update codes related to codeplex #1672: There are 2 function-import
elements in ServiceDocument if a function is overloaded and exposed as
FunctionImport.
2014-02-18 13:38:30 +08:00
Tian Pan e45d14212e Work Item 1683 [HelpPage] ApiExplorer throws exception when
trying to expand uri parameters.

Set parameterValuesForRoute ignore case and check whether it
contains the key before adding a new entry.
2014-02-17 18:05:43 -08:00
Pranav K c332dafd1a Suppressing CodeAnalysis violation in ODataConventionModelBuilder 2014-02-17 16:17:56 -08:00
Pranav K 4ef8fdae69 Merge remote-tracking branch '561/master' 2014-02-17 13:45:04 -08:00
Pranav K fc79dd536a Merge remote-tracking branches '1598/master', '520/master', 'foo/master' and 'bar/master' 2014-02-17 13:41:41 -08:00
Tian Pan d5d326b8fc Work Item 1530 Add System.Web.Mvc.ModelMetadata.Container property. 2014-02-14 14:10:37 -08:00
jacalvar a12032f07d Issue 1423 - Support ComplexTypeAttribute, AssociationAttribute, TimestampAttribute
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.
2014-02-14 13:00:26 -08:00
jacalvar d88630c387 Issue 1598 - Can filter and order on relationships that are not navigable
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)
2014-02-14 12:58:59 -08:00
jacalvar 3a8db6d83c Issue 1596 - Unsortable query limitation doesn't work for complex objects
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"
2014-02-14 12:57:32 -08:00
jacalvar c5afbeeaca Issue 520 - Provide ability to supply friendly Title for actions
https://aspnetwebstack.codeplex.com/workitem/520

When the user sets the title in the ProcedureConfiguration class,
we'll write that title in json full metadata, atom and json verbose.
2014-02-14 11:00:38 -08:00
jacalvar 458084c767 Codeplex Issue 561 - Conventional builder should throw error when it cannot
find a key for an entity type - https://aspnetwebstack.codeplex.com/workitem/561
2014-02-13 16:56:07 -08:00
Sam Xu 0d72141fc1 [Codeplex # 1672]: There are 2 function-import elements in ServiceDocument
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.
2014-02-13 11:01:10 +08:00
fenzhao 4679a1f19c fix issue 1641: IQueryable<IEdmEntityObject> doesn't get serialized properly 2014-02-13 09:57:20 +08:00
Alex Batishchev 85e133a695 Adding method AddRange() to HttpFilterCollection. Refactoring internals. Adding tests 2014-02-12 15:58:27 -08:00
Sam Xu 1cd759ee8f 1. Codeplex #1650 : It is unable to select the correct function if the
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.
2014-02-12 10:15:06 +08:00
Ryan Nowak f3056a0e03 Optimizing routing performance with many routes
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.
2014-02-11 12:31:57 -08:00
Tian Pan 891791e56d Work Item 1624
[HelpPage Accessibility] Add language attribute to html files.
2014-02-11 10:57:13 -08:00
Tian Pan a37e57720c Work Item 1625 Satisfy Visible Text Contrast requirements. 2014-02-11 10:45:09 -08:00
Congyong Su 5338316577 Fix 1580 : BindRound method binds nullable double as decimal 2014-02-12 00:31:18 +08:00
Congyong Su f3eb6d924c Fix 1608 : ODataUriUtils.ConvertToUriLiteral does not support Enum
Fix ConventionsHelpers.GetUriRepresentationForValue.
ODL beta1 now supports ODataEnumValue in ConvertToUriLiteral
2014-02-11 20:22:54 +08:00
Sam Xu 245a573d6b codeplex 1652: It reports error if an entity set name is followed by a type cast in URL. 2014-02-11 09:33:28 +08:00
fenzhao 395d93595c 1458 Fix parsing single key value which contains '=' in KeyValueParser 2014-02-01 09:35:30 +08:00
Yishai Galatzer 1e6b50cbe2 Fix CodePlex bug: https://aspnetwebstack.codeplex.com/workitem/1658
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.
2014-01-29 17:41:36 -08:00
dougbu 7c3c68dd79 Clear OData classes out of System.Net.Http and System.Web.Http
- 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
2014-01-28 22:25:28 -08:00
Pranav K 3974b68329 Update HttpControllerHandler.ConvertRequest to handle scenarios when the
RequestStream has already been read.

Work Item: 1659
2014-01-28 16:49:59 -08:00
fenzhao 62b36776b6 1494 fix ToArray() calls over-used 2014-01-28 16:11:54 +08:00
fenzhao 98b7ff0611 #1576 Correct typo in comment of EntityTypeConfiguration.Collection 2014-01-27 13:09:02 +08:00
davidmatson 8e9a2d00e5 Don't use ClientDisconnectedToken on unsupported platforms (fixes #1644). 2014-01-24 10:26:41 -08:00
Congyong Su f57492ac70 Remove entity set path from UnboundFunctionPathSegment
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
2014-01-24 00:01:26 +08:00
fenzhao 248649646a Fix isssue #1642:
The enum memeber is not generated by ODataConventionModelBuilder
if the enum type is used by an action or function.
2014-01-23 11:02:53 +08:00
Sam Xu 758e92405d Fix codeplex issues:
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
2014-01-23 09:49:29 +08:00
dougbu 53c3d13f80 Update namespaces in System.Web.OData.dll and System.Web.OData.Test.dll
- 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
2014-01-22 09:53:50 -08:00
Pranav K e663ab6034 Updating id selector generation in AjaxOptions to handle special
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
2014-01-20 16:52:29 -08:00
Pranav K 368c31d1f0 Updating jQuery Unobtrusive Ajax to use preferred and non-deprecated
functions.

Work Item: 1610
2014-01-20 16:41:28 -08:00
Congyong Su 1dfa8567b9 webapi.odata update to v4 beta1 ODL
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
2014-01-17 15:51:42 +08:00
Sam Xu 1a5d673d51 replace streaming to odata.streaming
Codeplex - #1591

change streaming to odata.streaming in media type based on ODL V4.
2014-01-17 15:28:12 +08:00
Sam Xu 70cc98d932 Refine the codes of bound action and function
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.
2014-01-17 14:07:17 +08:00
dougbu 31c7152fbe Correct warnings that show up in some build configurations
- No impact except to clean up those builds
2014-01-16 14:49:02 -08:00
davidmatson fdff766778 Fix IOverrideFilter documentation. 2014-01-15 09:58:56 -08:00
Sam Xu e5c69c1247 Replace $inlinecount to $count based on ODL V4.
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.
2014-01-15 17:44:48 +08:00
Sam Xu e38bca9d66 Codeplex - #1614
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
2014-01-15 16:59:43 +08:00
fenzhao c850136c24 Enum support for Action and Function
Enum with type attribute with different metadata level mode
Enable Enum in FilterQueryValidator
Enum support for raw value
2014-01-14 18:47:54 +08:00
Congyong Su a08bb56452 webapi.odata: v4 work for enum in query $filter
1. Add Enum support in filter binder
2. Add support for Enum "has" operator
3. Update & enable unit tests
2014-01-14 18:25:32 +08:00
fenzhao dc7aabd157 Enum support for ODataModelBuilder, serialization and deserialization
add Enum test for SelectExpandQueryOption
2014-01-14 16:04:18 +08:00
fenzhao d42c993ef9 Enum support for ODataModelBuilder 2014-01-14 15:53:51 +08:00
Pranav K 684f70b716 Modify unobtrusive validation to only attach to forms that have
at least one input field with client validation

Work Item: 1511
2014-01-13 10:56:23 -08:00
Tian Pan 34de12c46f 193 2014-01-10 15:57:35 -08:00
Sam Xu bc54755d54 Unbound function and action
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
2014-01-10 16:59:22 +08:00
Pranav K 6c0de66e22 Set ValidationContext.MemberName and populate ModelValidationResult witha
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
2014-01-09 15:45:36 -08:00
Ryan Nowak 62c061d6f5 Codeplex-1570 - Lazy-Initialize Dictionary on ModelMetadata
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.
2014-01-08 17:22:02 -08:00
Ryan Nowak 1c4e5a9846 Fix for Codeplex-1590
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.
2014-01-08 14:14:51 -08:00
Ryan Nowak d52221c31d Updating our package reference to Microsoft.Owin 2014-01-08 11:16:25 -08:00
Pranav K 9198909c3f MQ: Update System.Web.WebPages.Administration to use RazorGenerator
Work Item: 1477
2014-01-08 10:06:24 -08:00
Ryan Nowak 75a5487f50 Codeplex-1526 - Add support for DisplayNameAttribute to Web API
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.
2014-01-08 00:15:34 -08:00
Pranav K 1e3e68af10 Attempting to bind multiple request values to a single valued property
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
2014-01-07 17:26:59 -08:00
N. Taylor Mullen 6035cafd93 Allow inner insertions in implicit expressions for Razor (fixes #1491).
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.
2014-01-07 14:13:39 -08:00
Pranav K 9baac11a64 Revert "MemberNames specified in CustomValidationAttribute's ValidationResult are"
This reverts commit f3138c8932.
2014-01-07 10:44:40 -08:00
Pranav K 408661f58e Adding an AllowCache option unobstrusive Ajax
This setting allows setting the cache option in jQuery Ajax (See -
http://api.jquery.com/jQuery.ajax).

Work Item: 1531
2014-01-07 10:12:29 -08:00
N. Taylor Mullen d4ed0ea0c4 Modify Razor parser to better handle intellisense commits with '.'.
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.
2014-01-06 15:00:20 -08:00
N. Taylor Mullen ceaca890cc Remove null struct checks and improve parser in System.Web.Razor.
Optimized pieces of the BackgroundParser code path to not do duplicate
conditional checks and to not concat enumerables where it wasn't needed.
2014-01-06 11:57:01 -08:00
Ryan Nowak 0f37ba8ca9 CR feedback 2014-01-03 15:27:44 -08:00
Pranav K d191a06fa2 Json.Encode doesn't encode array properties returned from Json.Decode
Array values need to be unwrapped correctly for JavaScriptConverter to
encode it correctly.

Work Item: 1085
2013-12-31 11:13:40 -08:00
Pranav K 8fdce28acf ASP.NET MVC 3 LoadingElementDuration is not working
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
2013-12-19 14:36:02 -08:00
dougbu 5a701f3441 Address CR comments on comments
- Also clean up VB comment syntax
2013-12-18 21:29:11 -08:00
dougbu d618b46962 Provide hooks to generate sample objects (fixes #1480)
- 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()
2013-12-18 20:53:36 -08:00
Ryan Nowak 39ce2dc499 Fix FxCop break 2013-12-18 12:52:16 -08:00
dougbu 3c305a0baa Correct use of EdmTypeCannotBeNull message (fixes #1558)
- 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)
2013-12-18 11:46:14 -08:00
jacalvar bcd40d2f6b Issue 1372 - ApiExplorer should add query parameters for complex FromUri
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.
2013-12-18 11:09:39 -08:00
Pranav K f3138c8932 MemberNames specified in CustomValidationAttribute's ValidationResult are
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
2013-12-17 17:28:56 -08:00
Ryan Nowak 0bf8e5c701 Codeplex-1431 Support buffered async request stream in web host
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)
2013-12-17 15:59:09 -08:00
Sam Xu af0a611b66 Merge branch 'master' of https://git01.codeplex.com/aspnetwebstack 2013-12-17 17:23:12 +08:00
Sam Xu f023e52699 Improve Queryable limitation 2013-12-17 17:22:04 +08:00
dougbu a912095868 Correct a couple of OData resource strings (fixes #1557)
- 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)
2013-12-16 15:13:18 -08:00
dougbu 4abdcb8d33 Correct typos in HelpPage.css (fixes reactivated #1479)
- Previous iteration accidentally changed selectors to match for example
sample-header elements instead of elements of that class
2013-12-13 09:21:09 -08:00
Congyong Su 8edcb16230 webapi.odata uses OData v4 libraries: phase 1
Phase 1: Use OData v4 6.0.0-alpha2 package from nuget
1. Edm Lib, ODataLib, Spatial Lib namespace changes
2. Interface / method changes, e.g.:
IEdmFunctionParameter -> IEdmOperationParameter
EdmFunctionParameterMode.In is gone
FunctionImport.AddParameter -> EdmOperation.AddParameter
IEdmFunctionBase is gone
Multiplicity  -> TargetMultiplicity
http://schemas.microsoft.com/ado/2007/08/dataservices -> http://docs.oasis-open.org/odata/ns/data
http://schemas.microsoft.com/ado/2007/08/dataservices/metadata -> http://docs.oasis-open.org/odata/ns/metadata
odata.metadata -> odata.context
3. Select&Expand syntax change
Customers&$select=ID,Orders" -> Customers(ID,Orders)
4. Collection syntax change
"propertyName" : { "results":[ 1, 2, 3 ] } -> "propertyName" : [ 1, 2, 3 ]
5. __metadata type -> odata.type
{ '__metadata' : { 'type': NS.TypeName' } -> "{ 'odata.type' : '#NS.TypeName'
6. substringof -> contains
7. edmx version from 1.0 to 4.0
8. missing key, if reading delta
9. request.Headers.Add("OData-Version", "4.0");
10. Use OData V4 Alpha2 packages from nuget.org
11. @Element -> $entity
12. "binary'0102'" -> "binary'AQI='"
12. Use EdmConstants.EdmVersion4
13. OData version from 3.0 to 4.0
14. $format: odata=minimalmetadata -> odata.metadata=minimal etc.
15. url -> odata.id
16. Migrate IEdmFunction and IEdmAction.  Action/Function change, include metadata in payload
17. Select&Expand change
18. decimal.MaxValue issue to ODataLib
19. Fix remaining test breaks:
Fix ODataEntityTypeSerializerTests, InheritanceTests
Fix ODataModelBinderProviderTest
Fix Can_DeserializePayload_InUntypedMode
Fix ReadFromStreamAsync_ReadsDataButDoesNotCloseStream:
ExpectedSampleTypeByteRepresentation
Fix CanParse_BoundFunction_AtEntity
2013-12-13 23:10:23 +08:00
Congyong Su de22e048cd Create webapi.odata projects for v4 OData
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.
2013-12-13 21:36:13 +08:00
dougbu 1fe1c1a57a Correct help page CSS issues (fixes #1479)
- 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
2013-12-12 16:07:19 -08:00
Pranav K 8a2c969ab6 Fix unobstrusive ajax to use the right context in callbacks
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
2013-12-12 14:12:45 -08:00
Ryan Nowak d5188c8a75 Fix for codeplex-324 - Portable PushStreamContent throws on double dispose
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.
2013-12-12 11:18:02 -08:00
Ryan Nowak 827bc5075e Codeplex-777 Delta<T> can't be serialized with JSON.net
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
2013-12-11 13:30:28 -08:00
phenning dfc842be5f Update MVC version number to 5.2 and fix affected tests. 2013-12-11 13:20:29 -08:00
Ryan Nowak cff6169cc7 Codeplex-1465 Allow IHttpActionResult to be used based on the dynamic
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.
2013-12-11 13:14:00 -08:00
Yishai Galatzer 0af7cf7446 Fix CodePlex 1485
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.
2013-12-11 13:02:47 -08:00
Pranav K 9aa310ccff CORS AttributeBasedPolicyProviderFactory provides incomplete context
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
2013-12-11 12:08:10 -08:00
dougbu 03162ad2c2 Help page null checks for ApiParameterDescription.ParameterDescriptor properties (fixes #1484)
- 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.
2013-12-11 11:28:48 -08:00
Pranav K 1eb13543f7 Add client side validation support for MaxLength attribute
- Adding an attribute adapter for the MaxLength attribute
- Unit tests for the newly added MaxLengthAttributeAdapter

Work Item: 1476
2013-12-11 11:21:57 -08:00
dougbu 456c9c968d Run [Required] validators for missing bindings (fixes #1471)
- 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
2013-12-10 22:28:31 -08:00
Pranav K f6d4d1b9da FormDataCollectionExtensions provides incomplete context
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.
2013-12-10 12:06:47 -08:00
davidmatson 9e38ada175 Incorporate code review feedback. 2013-12-09 12:34:57 -08:00
Yishai Galatzer 8044bfbfc6 fix https://aspnetwebstack.codeplex.com/workitem/1472
Step II:
Rename GenerationRoute to LinkGenerationRoute
2013-12-09 12:24:22 -08:00
Yishai Galatzer 1cf5290c8a fix https://aspnetwebstack.codeplex.com/workitem/1472
Step I:
Make the properties forward to the inner route.
Explicitly block GetRouteData method , and Handler property.
2013-12-09 09:24:24 -08:00
davidmatson a194c62ef5 Create interface from DirectRouteBuilder for future extensibility. 2013-12-06 16:33:14 -08:00
davidmatson 5d1a5c5f9c Reserve the name IDirectRouteProvider for future use. 2013-12-06 16:30:26 -08:00
davidmatson 62350d4dd1 Remove outdated class diagram. 2013-12-06 12:12:39 -08:00
Pranav K c5fdac3429 Adding RazorGenerator package to Microsoft.Web.Helpers project
This allows the cshtml files to be precompiled as part of MsBuild rather
than having to do it with a VS Custom Tool

Work Item: 1477
2013-12-04 14:53:23 -08:00
raghuramn ee0c95dd25 Issue 1201: Tracing extension methods should interpret
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.
2013-11-27 13:34:51 -08:00
dougbu 09ae4f6ccb Handle DBNull.Value and simple runtime types in BSON formatter (fixes #1440 & #1457)
- 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
2013-11-27 11:41:24 -08:00
raghuramn f6a83be072 Issue 1340: support modelbinding nonstring data from route data
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).
2013-11-27 10:21:08 -08:00
jacalvar 34b97826ae Issue 1384: Make ODataActionParameters work in untyped mode.
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.
2013-11-27 10:15:07 -08:00
danroth27 0176e15c0f Help page UX cleanup.
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.
2013-11-26 19:10:10 -08:00
raghuramn 608c3446fb Issue 1422: Validation doesn't get triggered for values extracted from
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.
2013-11-26 11:26:16 -08:00
danroth27 09a1bcf2ec Help page should not show void return types (fixes #1446). 2013-11-26 10:28:42 -08:00
dougbu ebd91cdc67 Add TemplateHelpers special case for DateTimeOffset properties (fixes #1442)
- 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
2013-11-25 21:11:03 -08:00
shibayan a1e211da10 Fixed OutputCacheAttribute don't check value of Location property when IsChildAction is true.
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.
2013-11-25 19:10:57 -08:00
Ryan Nowak 03540d8875 Fix for Codeplex-1433 Mime Multipart parser requires an extra CRLF
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.
2013-11-25 18:58:42 -08:00
raghuramn 9a514e49cc Fix the breaking change that c8e263 introduced
Issue 1395: MediaTypeFormatter's ReadFromStreamAsync fails when tracing is
on.
2013-11-25 15:32:19 -08:00
raghuramn 6ba576a9d8 Issue 1415: Overriding writetostreamasync taking CancellationToken do not
get invoked
2013-11-25 14:55:17 -08:00
Ryan Nowak 7136f8912a CR feedback, using full type names in error messsages about constraints 2013-11-22 12:53:14 -08:00
davidmatson 9fb684781d Use ClientDisconnectedToken on web host where reliable (fixes #858). 2013-11-22 12:09:32 -08:00