Commit Graph

687 Commits

Author SHA1 Message Date
Anthony Sneed 1118315a9d [Resolves #1887] XmlDataContractSerializer Input and Output Formatter Tests Cleanup. 2015-01-30 10:02:33 +01:00
Doug Bunting 8779cafbab Use `[Display(Order=x)]` to sort validation messages and properties
- #964
- compute `ModelMetadata.Order` based on `[Display]` attribute
 - property affects e.g. `@Html.DisplayFor()` generation for complex objects
 - also affects order of messages in validation summaries
- test new scenarios involving `ModelMetadata.Order`
 - per-property `ModelMetadata` and related tests
 - validation and `HtmlHelper` tests
 - add `HtmlHelperValidationSummaryTest` (which touches on #453)
- update ModelBinding functional test to show use of `[Display(Order = x)]`

nits:
- move more `NullDisplayText` bits into proper slots (just above `Order`)
 - add doc comments for `ComputeNullDisplayText()`
- add more assertions in tests using `ModelStateDictionary.HasReachedMaxErrors`
- remove some trailing whitespace
- avoid `Assert.True()` & `Assert.False()`; split some assertions up
- `""` -> `string.Empty` in affected test classes
- rename "DefaultEditorTemplatesTest~~s~~" class and file to follow guidelines
- rename "ModelBindingTest~~s~~" class and file to follow guidelines

FYI #1888 covers a predictable (or even just stable) order in the UI
2015-01-29 09:31:05 -08:00
Youngjune Hong 70efc5ae0a Creating UrlUtility for IsLocalUrl, and cleaning up UrlHelper 2015-01-29 05:51:46 -08:00
Ryan Nowak 42df4cf2ed Fix for #1538 and #1891
Changes here are all focused around MaxModelErrors on
ModelStateDictionary.

MaxAllowedErrors now defaults to 200 (same as options). This means that
constructing a new ModelStateDictionary with the default constructor will
use this default. There's a new constructor for creating a
MaxAllowedErrors with a non-default value.

The ControllerActionArgumentBinder is now responsible for setting the
value from options onto ActionContext.ModelState. This results in better
layering and guarantees the option is respected if someone uses
extensibility to call model binding.

ModelStateDictionary.CanAddErrors is renamed to MaxErrorsReached. We
wanted to change the behavior of this property, but realized that it's
very useful inside the model validation code, so opted to renamed.

There's also a bunch of doc cleanup inside ModelStateDictionary to
simplify things and improve clarity.
2015-01-28 16:53:28 -08:00
Anthony Sneed 4821108307 Add SerializerSettings property to Xml DataContractSerializer input and output formatters. 2015-01-28 23:50:16 +01:00
NTaylorMullen 3e3dd0215d React to aspnet/Razor#94.
- Implemented ITagHelperinterface for TagCloudViewComponentTagHelper in the TagHelperSample.
2015-01-27 20:20:14 -08:00
Harsh Gupta 2d15f083da Porting few tests for JsonOutputFormatter 2015-01-27 16:48:54 -08:00
Kirthi Krishnamraju f1c62ef302 Fix for #1837 - Determine model type at runtime for TryUpdateModel and added a test 2015-01-27 16:36:47 -08:00
Kirthi Krishnamraju cbed666cba Added functionaltests for ModelMetadataType attribute and moved TryValidateModel tests actions to ValidationWebSite 2015-01-27 15:56:49 -08:00
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
N. Taylor Mullen 074eae6059 Fixed Microsoft.AspNet.Mvc.Common unneeded assemblyinfo. 2015-01-23 16:29:31 -08:00
Wei Wang af3044a3d1 Merge branch 'release' into dev 2015-01-23 13:21:30 -08:00
Wei Wang 5407ff3bd6 React to kpm renaming 2015-01-22 17:35:46 -08:00
Pranav K 4d77f670f6 Merge branch 'release' into dev 2015-01-22 16:47:54 -08:00
Pranav K 6c21b40894 EntryLinkHelpers.ContentLink should be available to use for user code
inside of a cache tag helper's body.

Fixes: #1867
2015-01-22 16:37:11 -08:00
Kiran Challa 5c2dc5db11 [Fixes#1792]Separate XML serializers to Microsoft.AspNet.Mvc.Xml 2015-01-22 15:09:20 -08:00
Doug Bunting bf00f478e5 Add another view to MvcTagHelpersWebSite using HTML helpers
- with some `<text>` hacks, generated HTML is almost identical to tag helper version
 - attribute order (HTML helpers consistently order alphabetically) is primary difference
- bit more testing, therefore related to #453

nits:
- remove some trailing whitespace
- clean up style in `MvcTagHelperTest[s]` and `MvcTagHelper_HomeController`
 - e.g. more init syntax, fewer duplicate variables
- correct "MvcTagHelperTest~~s~~" file / class name
- remove unused `Order.OrderNumber` property in MvcTagHelpersWebSite project
- correct one spelling mistake
2015-01-22 14:21:25 -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
damianedwards 759fbbd661 Added the EnvironmentTagHelper:
- #1553
2015-01-22 10:17:25 -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
Pranav K 7667eba34e Layouts for partials
Fixes #1621
2015-01-20 11:44:48 -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
Ajay Bhargav Baaskaran 67b078862e Fixed content-disposition quoted filename bug 2015-01-19 13:15:18 -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
Pranav K 80ada8d01b Introducing 'cache' tag helper
Fixes #1552
2015-01-16 16:57:33 -08:00
N. Taylor Mullen eb1eca9e1a Modify TagHelper tests to abide by new content mode design.
- React to aspnet/Razor#221
- Modified existing TagHelper tests to no longer rely on ContentBehavior.
- Updated signatures of TagHelperExecutionContext and TagHelperContext pieces.
2015-01-16 15:56:03 -08:00
N. Taylor Mullen 7b52559366 Modify TagHelpers to use new content mode design.
- React to aspnet/Razor#221
- Modified existing TagHelpers to no longer rely on ContentBehavior and to instead utilize GetChildContentAsync, PreContent, Content and PostContent.
2015-01-16 15:50:27 -08:00
Youngjune Hong 2cf56c7c83 Merge branch 'fix1771' into dev 2015-01-16 15:30:42 -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
Doug Bunting 9b2a9e3976 Change `ValidationSummaryTagHelper`'s property to `ValidationSummary` enum
- #1685
- move `ValidationSummary` type to the `Microsoft.AspNet.Mvc` namespace
- update tests and samples to match
- remove tests for case-insensitivity of `ValidationSummary` property values
2015-01-16 15:09:27 -08:00