Commit Graph

347 Commits

Author SHA1 Message Date
Ryan Nowak 08a578d01f Issue #1525 - Enhancements to ActionContext
- Adding a new constructor that takes ModelState.
 - Removing an extra constructor that's not needed
 - docs
 - test cleanup
2015-01-27 14:35:31 -08:00
Ajay Bhargav Baaskaran 17aa21dc25 Added StatusCode property to OutputFormatterContext
- Fixes issue #1809
 - Added relevant tests
2015-01-26 17:32:04 -08:00
Ajay Bhargav Baaskaran 8e85d53c88 Provided a way to add data to ActionDescriptor from ApplicationModel.
- Added Properties to Action, Controller and Application model
 - Added relevant tests
2015-01-26 15:20:02 -08:00
Ryan Nowak ee419e2442 Add ApiExplorer details to ApplicationModel
This change allows you to set global defaults for ApiExplorer on the
ApplicationModel. Additionally, we're more lenient about configuring
ApiExplorer = on with conventional routing. If you turn on ApiExplorer at
the application level, we'll just skip over all conventionally routed
controllers instead of throwing.
2015-01-26 14:47:11 -08:00
Ryan Nowak 8399dc5f4e Add a custom collection type for ModelMetadata.Properties
This is a cleanup PR to improve the common usage of
ModelMetadata.Properties.

We found placed in code where both .Count and the ability to index by
property name would be useful. I was able to cascade this and simplify the
ModelBindingContext as well.
2015-01-26 14:36:40 -08:00
Pranav K f93d0d82c3 Merge branch 'release' into dev 2015-01-23 17:12:16 -08:00
Pranav K 071c697318 Modify BuilderExtensions.UseMvc to not add any routes by default
Fixes #1879
2015-01-23 16:51:38 -08:00
Kiran Challa 5c2dc5db11 [Fixes#1792]Separate XML serializers to Microsoft.AspNet.Mvc.Xml 2015-01-22 15:09:20 -08:00
N. Taylor Mullen baa70d284d Merge branch 'release' into dev 2015-01-22 14:02:50 -08:00
Ryan Nowak 7fbe0ce307 Merge branch 'release' into dev 2015-01-22 14:02:17 -08:00
N. Taylor Mullen 14bd7dcd5e Handle trailing semicolon after @inject.
- Made @inject handle trailing semicolons identical to @using; essentially ignores it.
- Added parser, runtime/designtime codegen and functional tests.
- Added Microsoft.AspNet.Mvc.Common.Test.
- Transitioned pre-existing Microsoft.AspNet.Mvc.Common tests to the new test project.
- Updated transitioned tests to also work in CoreCLR (except ones with moq).

#1857
2015-01-22 14:01:10 -08:00
Ryan Nowak 09928a2818 Adds parameter information to ApiExplorer
This change makes ApiDescription and ApiParameterDescription aware of all
of the new features we built into model binding for enhanced DTO support
(uber-binding).

The main change is that instead of sticking just to the declared
parameters on the action itself, we now traverse model metadata and break
the parameters down based on their logical data source.

This means that a model like the below will yield 3 parameters:

public class ProductChangeCommandDTO
{
    public int Id { get; set; }

    [FromBody]
    public ProductDetails Changes { get; set; }

    [FromQuery]
    public string AdminComments { get; set; }

    [FromServices]
    public IProductRepository Repository { get; set; }
}

The 'Repository' will be hidden, as it's not related to user input.

Additionally, we treat different sources differently. In the
above example, 'Changes' is from the body and will be treated as a
leaf-node.

However if you use nested DTOs that are bound from the query string (using
[FromQuery]) or similar, we'll recursively explore to find as much
structure as possible.

This information is combined with data from the route template to give a
much more complete picture than we ever could in the past for parameters,
especially when DTO/Command pattern is used.
2015-01-22 13:30:41 -08:00
Doug Bunting 54f88ab190 [cleanup] Update .gitignore and reset .kproj files
- add a couple more exclusions to .gitignore (recent VS additions)
- remove `<ProjectExtensions/>` elements
- update files that don't have the correct output directories
- remove dangling PrecompilationWebSite.kproj file
2015-01-21 22:03:23 -08:00
Kiran Challa 0e9091f0eb [Fixes #1841] Change XML DCS and XmlSerializer output formatters to not derive from the base XmlOutputFormatter 2015-01-20 17:22:04 -08:00
Chris Ross d51dad9560 Handle IFileSystem rename. 2015-01-20 12:16:30 -08:00
Kirthi Krishnamraju 9299565706 Revert "Revert "Added SetAntiForgeryCookieAndHeader method that sets cookie token and header""
This reverts commit c8a13087a6.
2015-01-20 10:51:44 -08:00
Kiran Challa eda4b16cc5 [Fixes #1836]SupportedMediaTypes for output formatters are incorrectly updated with charset data during requests 2015-01-20 06:50:06 -08:00
Pranav K c8a13087a6 Revert "Added SetAntiForgeryCookieAndHeader method that sets cookie token and header"
This reverts commit 951ed05893.
2015-01-20 00:49:15 -08:00
Kirthi Krishnamraju 951ed05893 Added SetAntiForgeryCookieAndHeader method that sets cookie token and header 2015-01-19 17:58:12 -08:00
Stephen Halter d34554e3ff Handle HttpFeature rename 2015-01-18 21:06:12 -08:00
Ryan Nowak 0c5a702245 Changing when controllers are created
This change moves controller creation to the stage immediately before
model binding. The controller will be disposed/released before Resource
Filters run their 'OnResourceExecuted' method. Previously the controller's
lifetime surrounded all filter invocation.

Additionally, the Controller property is now gone from ActionContext, and
is moved to the 4 filter contexts that should have access to it
Action*Context and Result*Context.
2015-01-16 20:23:39 -08:00
Ryan Nowak 12c2759cec Fix for #384 - And some other changes to controller as filter
This is a major change to how we handle the scenario where a controller is
a filter. We want to change the lifetime of the controller object, by
scoping it around action filters and result filters. This means that a
controller class can only implement action filters and result filters.

To implement #384 - we're creating a delegating filter class
'ControllerFilter' which will forward calls to the implementation of the
controller. This is discovered in the controller model and added to the
filter collection. This filter is removable as an opt-out of this feature.

The ControllerFilter only implements action filter and result filter, so
the new restriction about filter types on Controller is in place. A future
change will move the instantiation of the controller to after resource
filters.
2015-01-16 19:15:59 -08:00
Ryan Nowak 51e7812e7e Fix for #1722 - FromHeader does not respect default value
This change adds support for our three-valued logic to the default value
handling part of the MutableObjectModelBinder.

The issue is that we want to look up a default value when a 'greedy' model
binder returns true but doesn't find a value.

We also don't want to call the property setter unless there is:
1). A value from model binding OR
2). A default value
2015-01-16 17:59:00 -08:00
Ryan Nowak 692a07240c Some cleanup of ActionResults - #657
In general all properties are get/set so filters can change them.
 - some validate for not-null
 - where we use services it's get/set also

Services are resolved in the Execute method if not provided.

A few more ActionResults that return a body have the ability to set a
status code now (optional).
2015-01-16 17:29:56 -08:00
Kirthi Krishnamraju e41e5066f9 Added support for TryValidateModel and its corresponding tests 2015-01-16 17:23:59 -08:00
Doug Bunting 12565daf88 Correct `CheckBoxFor` to ignore `ViewData`
- #1483
- update tests to match

nits:
- cover a couple more `CheckBoxFor` test cases
- capitalize "CheckBox" consistently
2015-01-16 17:20:34 -08:00
Youngjune Hong ba1c011bcb [ControllerUnitTest] Make the controller class not to throw an exception for simple unit tests 2015-01-16 15:22:04 -08:00
Harsh Gupta 60fa4a6f45 Adding Support for consumes.
Consumes has overriding behavior and the one closest to action wins.
2015-01-16 14:15:08 -08:00
Youngjune Hong 0d2a819255 Remove Controller.ViewEngine property+unit tests and simplify the Content method 2015-01-16 13:44:03 -08:00
Ajay Bhargav Baaskaran b02dea98e7 Using set instead of add in Created ActionResults 2015-01-16 12:34:40 -08:00
Ajay Bhargav Baaskaran 7c0eb56e59 ContentResult sets Charset along with ContentType
- Sets default ContentType and Charset if null
- Added relevant unit and functional tests
2015-01-16 12:24:44 -08:00
Yishai Galatzer 9ac37fbc7a Rename TextPlainFormatter and remove other minor warnings
#1631
2015-01-16 12:09:53 -08:00
Hao Kung 7b2fb55ef6 React to Security Auth changes 2015-01-15 23:41:52 -08:00
sornaks 262bb9a732 Changes introducing ResponseCache to cache content in the client/proxy. 2015-01-15 16:51:22 -08:00
Kiran Challa 02f4ca9f05 [Fixes #1791]Remove XML formatter from defaults 2015-01-15 15:46:49 -08:00
Chris Ross 9aff289dfe Handle PipelineCore rename. 2015-01-15 15:25:17 -08:00
Chris Ross 91d7e382d1 Consume new strongly typed headers. Remove temp implementations. 2015-01-14 15:51:34 -08:00
Doug Bunting 89fd1abc58 Nit: Clean up duplicate tests
- lead to errors during test discovery in VS
2015-01-13 12:49:26 -08:00
Ryan Nowak 08b83fefc3 Some cleanup of action invoker and related code
The action invoker no longer needs access to model metadata or to the
input formatter selector. This change removes the same as constructor
parameters and cleans up tests which use the invoker.
2015-01-12 16:44:39 -08:00
Ryan Nowak 5ac5c53c09 Adding Resource Filters
This is a new filter stage that surrounds the existing model binding,
action, and result parts of the pipeline. Resource Filters run after
Authorization Filters.

The other major change is to support one of the primary scenarios for
Resource Filters. We want a filter to be able to modify the inputs the
model binding (formatters, model binders, value providers, etc) -- this
means that those changes need to be held on a context object and preserved
so that they can be used in the controller.

So, IActionBindingContextProvider is removed - the ActionBindingContext
will be created by the invoker. For now it will be part of the action
context.
2015-01-12 14:18:20 -08:00
Hao Kung 157b633758 React to IContextAccessor -> IScopedInstance 2015-01-12 10:25:21 -08:00
Ajay Bhargav Baaskaran 52a984c52d react to aspnet/HttpAbstractions#146 changes 2015-01-07 17:53:35 -08:00
Doug Bunting 6df288bce7 Correct StyleCop violations
- StyleCop working again (handles C# 6.0 additions) though only locally for me
- disable some new rules:
 - ConstFieldNamesMustBeginWithUpperCaseLetter
 - InstanceReadonlyElementsMustAppearBeforeInstanceNonReadonlyElements
 - StaticReadonlyElementsMustAppearBeforeStaticNonReadonlyElements
 - StaticReadonlyFieldsMustBeginWithUpperCaseLetter
 - PrefixCallsCorrectly
- correct remaining violations
 - lots of long lines for example
 - use more `var`; some manual updates since StyleCop doesn't check seemingly-unused blocks

nit: remove new trailing whitespace (was paranoid about adding it w/ fixes)
2015-01-06 16:23:57 -08:00
Ryan Nowak 0a473b0600 Remove ParameterModel.IsOptional
The ParameterModel and ParameterDescriptor have had a notion of
optionality for a while now, even though all parameters are treated as
'optional' in MVC.

This change removes these settings. Optionality for overloading in webapi
compat shim is reimplemented via a new binder metadata.
2015-01-06 15:22:13 -08:00
Ryan Nowak fb21b736ee Issue #1754 - Change List to IList in application model 2015-01-06 15:16:04 -08:00
sornaks 5262dfd577 Adding SerializableError - a serializable container for the purpose of output conneg. 2015-01-06 14:07:45 -08:00
Ajay Bhargav Baaskaran eb7283fced added BadRequest and Created Action Results with related unit and functional tests. 2015-01-05 11:07:42 -08:00
Ryan Nowak e2a4b1ec72 Remove IsActionNameMatchRequired
This change removes IsActionNameMatchRequired from the action model. The
WebAPI shim uses a custom route data constraint to get the same effect.
2014-12-31 15:21:50 -08:00
Ryan Nowak ae9fc793ec Adding IRouteConstraintProvider and supporting it on actions
This change adds an interface for the functionality provide by
RouteConstraintAttribute, and adds support for configuration constraints
on actions/action-model.
2014-12-31 14:50:33 -08:00
SonjaKhan c936ae80ca Logging assemblies, controllers, and actions 2014-12-18 10:52:20 -08:00