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.
- Now in changeHttpRouteExtensions, ToRoute() would return a HttpWebRoute
containing a System.Web.Routing.StopRoutingHandle for the ignored route.
- Add unit tests with constraints for IgnoreRoute on WebHost, OWIN, Self-Host.
- move `TranslateHttpResponseException` from `SystemDiagnosticsTraceWriter`
to `TraceWriterExceptionMapper.cs`.
- Both assemblies of System.Web.Http and System.Web.Http.Tracing link to
`TraceWriterExceptionMapper.cs`, `TraceWriterExceptionMapperResources.resx`,
and `TraceWriterExceptionMapper.Designer.cs`.
- modify `catch` block for HttpResponseExceptions in TraceBeginEnd* methods.
- add unit tests for each mehtod.
This change prevents the use of {controller} in all attribute routes, and
the use of {action} in attribute routes on action methods. This validation
is in place to prevent scenarios where a user takes a working traditional
route and copy-pastes it into attributes.
Use of these route parameters in the scenarios where it's now prohibited
is very very likely to be a mistake and won't do anything useful. For any
valid scenarios that are blocked by this, the workaround is to use a
different parameter name.
- https://aspnetwebstack.codeplex.com/workitem/1434
- "Remove EditorFor HTML attribute handling inconsistencies"
1. Remove special cases for collections and complex types
2. htmlAttribute renamed to htmlAttributes
- https://aspnetwebstack.codeplex.com/workitem/1215
- "Trace exceptions in DefaultHttpControllerTypeResolver"
- Only change to DefaultHttpControllerTypeResolver public API is to make
IsControllerTypePredicate property virtual (this allows tracer override);
property remains protected
nit: Update old comments mentioning GetExportedTypes
This fix solves an issue for link generation in MVC where a
controller-level route can generate links for actions that cannot be
reached through that route in mixed-routing scenarios. If the
controller-level route has a 'better' template than the action-level route
then it will always take precedence.
This change considers whether or not a route is to an action as a criteria
before considering route precedence.
There are still some scenarios here that are problematic, like when
actions
with the same name are reachable with a controller-level route and an
action-level route. It's possible to use order to override this behavior,
or to just use named routes - the goal of this change is eliminate an easy
to hit bad behavior.
OWIN does not call Dispose on middleware; instead, it signals a
host.OnAppDisposing cancellation token. Register the Web API OWIN
middleware for cleanup with that mechanism.
This change adds validation to the constraints provided to MapRoute and
IgnoreRoute in MVC. This allows us to provide an error message about
invalid constraint types at startup on the common paths.
Note that MVC doesn't own the types involved (Route, RouteCollection) so
this fix is less thorough than the WebAPI version.
This change attempts to block creating a route with a route constraint
that we can't handle is some common scenarios (MapRoute, Attribute
Routes).
There are still plenty of ways to create a route with invalid constraints,
and due to extensibility scenarios we can't protect against those. In
those cases there will still be an exception throw when the route is
executed.
MVC Changes to follow.
- http://aspnetwebstack.codeplex.com/workitem/479
- "EditorFor Date Value Does Not Output Correct Date Format As Per RFC 3339"
- Reported issue was a bug in HtmlHandler.Html5DateRenderingMode handling
- Code previously assumed any use of an edit format string indicated an
explicit [DisplayFormat] attribute
- Instead track whether edit format string came from [DataType] attribute
in new ModelMetadata.HasNonDefaultEditFormat property
- FxCop required me to refactor DataAnnotationsModelMetadataProvider slightly
Disposing the HttpRouteCollection will now dispose the HttpMessageHandler
instances owned by those routes.
We want to fix this for use in scenarios where an API might have a limited
lifetime, which is possible in selfhost/owin.
"MVC5 Bug: Views are not compatible with Virtual Path Providers"
- https://aspnetwebstack.codeplex.com/workitem/1362
- Should never cache HostingEnvironment.VirtualPathProvider; this property
may change at any time.
- This bug is a regression from MVC4.
"MVC bug: Bad performance of views if ViewEngines.Engines is initialized
without HttpContext"
- https://aspnetwebstack.codeplex.com/workitem/1366
- ViewEngines.Engines may be read before HttpContext.Current is initialized,
leading to inefficient use of the NullViewLocationCache instance.
- https://aspnetwebstack.codeplex.com/workitem/1407
- "EDDL() shows extra blank option in addition to option label"
- Special-case in EDDL(); don't pass option label to helper methods
- Add tests for these situations
- Add tests using an empty enum
Description: Add query support in portable library,
the original support was missing because the namevaluepair
class does not exist in the portable version of .NET
This fix attempts re-use the same files and tests.
on
tracer tests that validate that the tracers override all the base class
methods do not take method overloads into account while verifying. Fixing
the test identified more issues with existing traces which are fixed as
well in this change.
Delta<T> doesn't know the IEdmType or the IEdmModel of the T. Hence
Delta<T>.Put resets the navigation properties to null as it cannot
distinguish between navigation and structural properties. This is
incorrect behavior according to OData spec and also causes issues with EF
as resetting the navigation properties might cause ForeignKey constraint
violations.
Fixing this by adding a ctor that takes the list of updatable
properties and resetting only them in Delta<T>.Put. The OData formatter
when it constructs Delta<T> during deserialization passes the structural
properties for this list.
We discussed two solutions to this issue. Earlier commit a14733ff07 had
the wrong solution. Reverting those changes and pushing the approved fix
with this change.
- https://aspnetwebstack.codeplex.com/workitem/1396
- "Web API Help Pages show garbled samples if BSON formatter is enabled"
- Support HelpPageSampleGenerator with only media type; type no longer needed
- Fallback GetActionSample() lookup to use just media type as a last option
- Provide SetSampleForType() extension which also lacks type parameter
- Initialize ActionSamples to include special case for application/bson
Also use VB short-circuit logical operators where they avoid bugs. (Not sure
And or Or are worth using except for bitwise operations but I left the rest.)
Current display in application/bson samples is a TextSample containing
"Not displaying binary application/bson content." Suggestions appreciated.
Nit: Reduce duplication between HelpPageSampleKey constructor overloads.
- Prefer VS 2013 (v12.0) version of MSBuild.exe and fallback to v4.0 when necessary
- Do not rely on %Path% since that limits us to VS developer cmd windows
- Match Microsoft.Build.Tasks*.dll version to MSBuild.exe, not type of cmd window
- Have tested building in VS 2013, VS 2013 dev cmd window, and bare cmd window
Requires either a FxCopCmd.exe.config binding redirect or David's "VS2013 FxCop
compatibility" change for full VS 2013 support.
In all WebAPI scenarios ParseMediaTypeHeaderValue is instantiated many times per request during the negotiation process and is used inside sorting and comparison operations. The change removes the 3 heap allocations per instantiation and optimizes the CPU path. Should improve high throughput scenarios by about 1%.
In WebAPI scenarios involving paramters, there are repeated calls to extract the same set of paramters on the long lifetime ReflectedHttpActionDescriptor. This changes caches them and will prevent one array allocation per request and should improve throughput by 0.3-0.5% depending on the scenario.
- Back to previous MaxDepth handling
- ... but seal property overrides in BaseJsonMediaTypeFormatter subclasses
- Remove unnecessary suppressions; add a couple that were missing
- https://aspnetwebstack.codeplex.com/workitem/1373
- "Error message is not clear when enum that has flags attribute calls EnumDropDownListFor html helper"
- Add new message for case where ModelType has a [Flags] attribute
- Provide EnumHelper.HasFlags(Type) internal method to make determination easy for EDDL()
- Leads to a duplicate call to Nullable.GetUnderlyingType(Type) but only in the failure case
- $(VisualStudioVersion) has value '12.0' in this command window; copied from environment
- build.cmd consistently builds using MsBuild.exe v4
- But VS uses its native MsBuild version and this .targets file works within VS
- Guard v12 settings using $(BuildingInsideVisualStudio)
Whether or not an exception can be handled depends of the catch block
code, so the CallsHandler properly belongs on the catch block class
rather than varying per context on the exception logger context class.
- https://aspnetwebstack.codeplex.com/workitem/1389
- "EnumDropDownListFor helper throws unhandled exception when model state is invalid and create page is loaded again "
- EnumDropDownListFor() attempted to convert ModelState.Value.RawValue to general Enum type
- Fix is to use actual ModelType
This change allows users to configure the casing behavior of simple
membership provider. The simple membership provider will by default
generate a database query that normalizes the case of usernames on the
database side.
This comes with the side effect of obviating any index that the user may
have configured for the user name column.
The fix is to make this behavior configurable. With the new option, it
will be possible to turn off casing normalization, and allow the database
to handle it specific to its collation.
- Update PCL project files
- Correct usings to provide all necessary types
- Hack a TypeDescriptor.GetConverter(type).CanConvertFrom(typeof(string)) substitute for PCL
Nit: Remove one unused using
- https://aspnetwebstack.codeplex.com/workitem/241
- Refactor JsonMediaTypeFormatter, moving much of it into new BaseJsonMediaTypeFormatter
- All DataContractJsonSerializer support remains in JsonMediaTypeFormatter
- Add new BsonMediaTypeFormatter, another BaseJsonMediaTypeFormatter subclass
- Add (non-standard) MediaTypeConstants.ApplicationBsonMediaType
- Add Dictionary<string, T> and null test data variations -- gaps in previous formatter round-trip tests
Note BSON-specific special cases for null (empty content) and for simple
types and byte[] (Dictionary<string, object> with a single property named
"Value"). May want to publish these workarounds as well as issues with
decimal, uint, and ulong (see BsonMediaTypeFormatterTests.cs).
Nits:
- Make JsonMediaTypeFormatter comments more consistent
- Tighten JsonMediaTypeFormatter contract enforcement
- Merge adjacent #if blocks
- Correct comments referencing JsonMediaTypeFormatter
Test nits:
- Refactor MediaTypeFormatterTestBase slightly to support testing with binary serializations
- Correct value of CommonUnitTestDataSets.ValueAndRefTypeTestDataCollection and remove duplicates from tests using it
- Remove unused DataContractJsonMediaTypeFormatterTests.ValueAndRefTypeTestDataCollectionExceptULong
- Remove unecessary exclusion of TimeSpan data set in HttpAssert.CanRoundTrip(); formatters instead have trouble with DateTime (losing Kind property value)
CancellationToken not being invoked
HttpContent.SerializeToStreamAsync doesn't take in a CancellationToken.
So, there is no easy way to get the CancellationToken to the formatter
while writing response. We are cheating here by passing fake cancellation
tokens. We should fix this when we fix HttpContent.
routes.
Duplicate names for traditional routes already give a good error message,
which explains that you can't do that, and what the duplicate name is.
Prior to this change duplicate names on attribute routes would fail with a
generic 'duplicate key' message without telling you the key.