Commit Graph

894 Commits

Author SHA1 Message Date
Ajay Bhargav Baaskaran 088bb18eed Added support for binding FormCollection
- Added FormCollectionModelBinder
 - Added relevant unit and functional tests
2015-02-13 11:14:50 -08:00
Pranav K a33e83f363 Adding IView.Path and ViewContext.ExecutingPagePath
Fixes #1940
2015-02-13 06:12:15 -08:00
Doug Bunting 3ced6016a1 Deep copy user's select list before making changes
- #524
- add tests of `DropDownList` and `ListBox` HTML helpers
- extend tests of `<select/>` tag helper
- add scenario to a functional test

New `HtmlHelperSelectTest` does not cover everything. In future (see #453):
- use non-`null` `optionLabel` and `htmlAttributes` arguments
- confirm value sources and their priorities
- mock an `IHtmlGenerator` and confirm how it is called
- mock an `IHtmlHelper` and confirm how extension methods call that
2015-02-12 20:56:53 -08:00
Pranav K 2169ba0c8f Reacting to ANIs going away 2015-02-12 14:52:17 -08:00
Doug Bunting ca65b1b6ed Correct recent checkins
- correct typo in 3303286288
 - really seal `CachedModelMetadata.Properties`
- make a couple of test methods `public` (!!)
- add Microsoft.AspNet.PageExecutionInstrumentation to Mvc.sln
- remove `<RootNamespace/>`, `<ProjectExtensions/>`, etc. from .kproj files
2015-02-12 08:53:17 -08:00
Pranav K f89c716dba Fixing build break 2015-02-11 17:54:04 -08:00
Ajay Bhargav Baaskaran 13e1c9d5e1 added InputFormatter base type 2015-02-11 16:48:56 -08:00
Pranav K e1e43e1e8c ControllerActivator should be able to use controllers registered as
services

* Added WithControllersFromServiceProvider that replaces the default
  controller activator with a service based one.
* Move activation to DefaultControllerFactory
* Modify [Activate] behavior so that it no longer activates services. Use
  [FromService] attribute to hydrate services

Fixes #1707
2015-02-11 16:41:59 -08:00
Ryan Nowak 7cb6c1065c Fix for #1913 - Improve attribute route link generation for areas
Attribute route link generation will now have a slight preference for
entries that can use ambient values (vs ignoring an ambient value). This
means that areas will be more 'sticky' with regard to link generation
without the need to specify a better Order.
2015-02-11 15:59:48 -08:00
Ryan Nowak 1721d90065 Fixes for changes in routing
Routing now requires the RouteOptions in the service provider.
2015-02-11 15:58:47 -08:00
Doug Bunting 7e166295ba Simplify `<select/>` tag helper `multiple` attribute handling
- #1516
- `allowMultiple == true` when model has a collection type
 - ignore any `multiple` attribute in Razor source when generating element
- simplify tests too: fewer error cases

Note Razor author could allow browser user to submit values model binding
will likely ignore: Could mix a `multiple` attribute with a non-collection
`asp-for` expression.
2015-02-10 19:01:30 -08:00
Yishai Galatzer dd3f67c93f Update dictionary initializer in ScriptTagHelperTest to C#6 2015-02-10 18:12:20 -08:00
Ryan Nowak b4d1eec87a Makes attribute routing respond to AD updates
This change makes the attribute route capable of responding to updates in
the action descriptor collection.

The change moves the actual route implementation to InnerAttributeRoute.
AttributeRoute now wraps an InnerAttributeRoute - when processing a route,
AttributeRoute will now check with action descriptor collection if its
InnerAttributeRoute is still 'current' and rebuild it if necessary.
2015-02-10 16:01:22 -08:00
Mugdha Kulkarni 09b0aa5182 fixing a build break due to change in the error message in Routing 2015-02-10 14:46:40 -08:00
Pranav K 70ce04ff21 Results of parsing _ViewStart files should be cached
Fixes #1016
2015-02-10 13:48:33 -08:00
sornaks d2c3985cd6 Issue #1445 - Cleanup on MvcOptions.ApplicationModelConventions. 2015-02-10 13:17:19 -08:00
Kiran Challa f474f7116a Temporarily fix build break related to XmlSerailizer tests failing in Core CLR. 2015-02-10 12:41:48 -08:00
Pranav K 8ed522de64 Revert "Temporarily skip MvcSampleTests scenario to workaround System.Dynamic.Runtime issue"
This reverts commit b3c38bc573.
2015-02-10 08:32:46 -08:00
Doug Bunting f93fca1077 PR comments
- change `AdditionalValues` type to `IDictionary<object, object>`
- copy `ModelMetadata.AdditionalValues` in `AssociatedMetadataProvider` sub-classes

nits:
- add XML comments
- correct indentation in `CachedModelMetadata`
2015-02-09 16:24:28 -08:00
Doug Bunting 3303286288 Add `ModelMetadata.AdditionalValues` property bag
- #1758
- provide the property bag in `ModelMetadata`; seal it in `CachedModelMetadata`
- add unit tests
- include use of `AdditionalValues` in model binding functional test

nits:
- expose `AdditionalValues` as an `IDictionary` though MVC 5 uses `Dictionary`
- seal `ModelMetadata.Properties` collection as well
- cover a few properties previously missed in `CachedDataAnnotationsModelMetadataTest`
- correct two `ModelMetadataTest` method names
2015-02-09 15:59:34 -08:00
Pranav K b3c38bc573 Temporarily skip MvcSampleTests scenario to workaround System.Dynamic.Runtime issue 2015-02-09 15:19:14 -08:00
Pranav K 6ef5518f8a Remove IRazorFileProviderCache and rely on file expiration triggers to
file change expiry.

Fixes #1969
2015-02-09 15:08:26 -08:00
Kiran Challa 4ecbe8c709 [Fixes #1065] Need a way to specify "just type" with produces 2015-02-09 10:46:24 -08:00
Anthony Sneed 2c21c7c9c7 [Resolves Issue #1787] Added InstanceOf, InstanceOfOrDefault, InstancesOf extension methods to IEnumerable<IOptionDescriptor<object>>.
Added RemoveTypesOf extension method to OutputFormatterDescriptor, ModelBinderDescriptor, ValueProviderFactoryDescriptor.
2015-02-09 10:46:01 +01:00
Youngjune Hong 57c04835de Updating ActionContext for the default constructor and the setter methods 2015-02-06 20:27:42 -08:00
Kiran Challa 2e938a51f8 [Fixes #1878] Investigate Xml formatters tests failures on Windows 2008 R2 OS 2015-02-06 13:23:12 -08:00
Youngjune Hong c7d09d7ad7 Introducing UrlActionContext and UrlRouteContext, and updating IUrlHelper accordingly 2015-02-05 19:41:21 -08:00
Ajay Bhargav Baaskaran ac6a1a6a80 Replaced status code number with constants 2015-02-05 16:43:59 -08:00
Yishai Galatzer e94cec51fa Script Tag Helper
Implement Script TagHelper
Add functional test

Resolved #1576
2015-02-05 14:35:02 -08:00
Ryan Nowak 12f8f23ccb Make BindingSource extensible
This is a major refactor of how IBinderMetadata interacts with model
binders and value providers. We're doing this to support better
extensibility for metadata in ApiExplorer.

You'll notice a bunch of deleted code in DefaultApiDescriptionProvider
that maps metadata marker interfaces to a fixed list of Api sources. This
is replaced now with IBindingSourceMetadata - which also replaces the
hierarchy of marker interfaces. Now user code can create an arbitrary
binding source and have a consistent API for model-binders,
value-providers and full-visibility in ApiExplorer as
well.

Additonally, there's some error checking in place that better enforces the
constraints we already have in the system. IE you can't create a 'greedy'
model binder that uses value-provider data.

Two additional enhancements are planned for followup PRs:
1. Add a BindingSource property to model-metadata. This will remove some
duplication, but I want to delay it because it would touch another 10 or
so files.

2. Add an extensibility interface for our 'special' model binders like the
file binder so these can show up in ApiExplorer as well.
2015-02-05 13:41:31 -08:00
Kiran Challa 8c32d9e207 Removed misplaced test files due to bad merge.
The latest version of these files are already present in Microsoft.AspNet.Mvc.Xml.Test.
2015-02-05 13:21:33 -08:00
Ajay Bhargav Baaskaran 5e704cd5ef Added custom exception message for Format Exception 2015-02-05 10:51:32 -08:00
Pranav K 59db8143da Updating CompilerCache to use IMemoryCache and file system watcher to
expire files in razor file cache.

Add a functional test to ensure the compiler cache does not get
initialized until the first request to a View.

Fixes #1708
2015-02-05 09:52:17 -08:00
Yishai Galatzer 5a3863d562 Implement StreamOutputFormatter
Include Functional tests and unit tests

Resolves #1653
2015-02-04 16:04:02 -08:00
sornaks 4691823a50 Issue #1785 - Changes to add CacheProfiles for response caching. 2015-02-04 15:25:45 -08:00
sornaks 6e8cc6ba74 Adding extension methods ConfigureMvcOptions and ConfigureRazorViewEngineOptions. 2015-02-04 14:07:07 -08:00
Harsh Gupta e805e67b4c [Fix for #1929] HeaderModelBinder needs to honor explicit name. 2015-02-03 19:36:48 -08:00
sornaks 2c5ae68ab6 Issue #1944: Move DelegatingStream to internal namespace and rename to NonDisposableStream. 2015-02-03 13:34:42 -08:00
N. Taylor Mullen c3006f6b21 React to aspnet/Razor#285.
- Cannot only provide assembly name to @addtaghelper.
2015-02-03 12:33:30 -08:00
damianedwards ad66a71eeb LinkTagHelper activates ILogger directly from DI:
- #1948
2015-02-03 11:41:50 -08:00
damianedwards 3d33418f31 Add the LinkTagHelper:
- #1580
2015-02-03 10:12:38 -08:00
Kiran Challa 49294b7d28 Removed custom object result accepting status code as out of box ObjectResult provides this already. 2015-02-02 10:20:20 -08:00
Ryan Nowak 514460b801 Making FormatFilter a Service and some test changes 2015-01-31 23:51:58 -08:00
Mugdha Kulkarni d7f2630ad2 Making FormatFilterAttribute an IFilterFactory 2015-01-31 23:18:30 -08:00
Mugdha Kulkarni 6a0f471a42 Adding ClearMediaTypeMappingForFormat to FormatterMappings and other PR comments 2015-01-31 23:18:24 -08:00
Mugdha Kulkarni addd8dd5d2 Changing produces and format filter interaction 2015-01-31 23:18:18 -08:00
Mugdha Kulkarni 7ee80020e1 Incorporating PR comments - 1/19 2015-01-31 23:15:19 -08:00
Mugdha Kulkarni c8b911b596 Adding functional tests and attribute route tests.
Incorporating PR coments.
2015-01-31 23:15:13 -08:00
Mugdha Kulkarni d91b7776b3 This is MVC part of feature URL Extensions. It does following:
1. Creates a filter called FormatFilter. This will look at the format parameter if present
   in the route data or query data and sets the content type in ObjectResult
2. It adds new options called FormatterOptions, that contains the map of format to content tyepe
3. A method in MVC options to add the formatter mapping
2015-01-31 23:15:04 -08:00
Kiran Challa e5176d22f6 [Fixes #1121,#1508] Wrap objects for serialization/deserialization and DelegatingEnumerable<> support for IEnumerable<T> and IQueryable<T> 2015-01-30 18:10:01 -08:00
Pranav K 7c7eaa264d Use CRC32 instead of MD5 for hashing the file content.
Fixes #1800
2015-01-30 18:01:24 -08:00
Doug Bunting 6524930778 React to quick cleanup in Routing
- `DefaultInlineConstraintResolver` has no need of a `IServiceProvider`
2015-01-30 17:52:10 -08:00
Harsh Gupta 8e91c1ada6 [Fix for #1850]Produces, Consumes and ObjectResult throw if there is a match all content type. 2015-01-30 15:54:58 -08:00
Doug Bunting 6cc5cfeae2 Download and install jQuery Unobtrusive Validation and its dependencies
- avoids checking these external .js files into our repo
- limit jQuery*.js versions to single value, mostly the latest but don't
  cross over to jQuery.js 2.0.x range (incompatible with IE 6, 7, 8)
2015-01-30 12:33:12 -08:00
Doug Bunting 1a62f104b4 Add functional test of `[Remote]`
- #439 (3 of 3)
- extended the Validation web site to include use of `[Remote]`
- also confirm operation of the validation actions (which all reject their input)
2015-01-30 12:33:00 -08:00
Doug Bunting 80b004678d Get `[Remote]` and supporting classes building
- #439 (2 of 3)
- correct namespaces
- correct `Resources` class and member names; add new resources
- add `RequestServices` property to `ClientModelValidationContext`
- adjust to modern `IUrlHelper` API
- add `IClientModelValidator` support in `DataAnnotationsModelValidator`
- move previously-unused `StringSplit()` to `RemoteAttribute` and rename
- rewrite `RemoteAttributeTest`
 - improve test method names

Reduce number of `[Remote]` constructor overloads
- remove `AreaReference` enum and related `[Remote]` constructor overload
 - use `null` or empty `string` as explicit reference to the root area
- generally reduce parameter validation; match `UrlHelper`

Cleanup
- correct Engineering Guidelines violations
 - especially: add doc comments
- correct spelling error in `_additonalFieldsSplit`

nits:
- minimize `null` checks in `AdditionalFields`
- make `GetClientValidationRules` `virtual`; some subclasses use `new` today
- add tests of `DataAnnotationsModelValidator.GetClientValidationRules()`
- remove `builder.ToString()` calls since it appears
  https://roslyn.codeplex.com/workitem/246 has been resolved or Moq has
  worked around that issue.
2015-01-30 12:26:48 -08:00
Doug Bunting 1af1583302 Copy `[Remote]` and supporting classes from MVC 5.2
- #439 (1 of 3)
2015-01-30 10:05:53 -08:00
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
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
David Fowler 90f2ece84d Work around dependency resolution problem 2015-01-16 03:01:51 -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
Doug Bunting d2fe1ebad7 Allow `@Model` in bound tag helper attribute value
- part II of #1253
- an expected case in template .cshtml files
- expression has name `""`; led to `ArgumentException` in `ModelExpression`
- test `@Model` and `@model.Property` in unit and functional tests
- update baselines to match

nits:
- remove a few unecessary `@`s in .cshtml files
- correct field names & ids in ProductList.cshtml (`foreach` confuses MVC)
 - led to correct valiation attributes as well
2015-01-15 16:47:27 -08:00
Doug Bunting a77d071830 React to aspnet/Razor#268 changes
- part I of #1253 using new Razor capabilities
- update baselines to match latest code generation
- use new `CodeBuilderContext` and `TagHelperAttributeValueCodeRenderer` signatures
- test complex expressions in bound non-string attribute values
2015-01-15 16:47:22 -08:00
Ryan Nowak 3dea6b11a3 Issue #1695 - Create a pattern for a 'greedy' model binder.
See #1695 for a detailed explanation. This change builds support into the
system for the case that a model binder returns true without setting a
value for the Model.

In this case, validation will be skipped if it's a top-level object.

Note that explicitly setting null will still run validation.
2015-01-15 16:32:50 -08:00
Ryan Nowak 623b733eaa Adding a sample (test) for using custom IRouter implementation with MVC
This is a demonstration of how to inject an IRouter in between traditional
routes and MVC's handler. This allows you to accomplish a variety of
things that were possible with WebAPIs handlers, but inside the routing
system.

The example here turns a header representing the user into a locale, which
is used to select a controller. You could do other things like reject the
route match or change link generation.

There is one subtle project change here, to allow the same to be possible
for attribute routing, we need to create the attribute route after running
the user's routing configuration code.
2015-01-15 16:31:21 -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
Pranav K bef9af4679 Fixing build break
* Run ModelBinding test that uses Moq to run under ASPNET50
* Update AssociatedValidatorProviderTest to reflect API changes
2015-01-15 14:20:00 -08:00
Pranav K fe1bcc7a24 ElementalValueProvider performs incorrect prefix check in
ContainsPrefixAsync

Fixes #1814
2015-01-15 14:02:41 -08:00
Ajay Bhargav Baaskaran 437eb93bde File upload model binder
- Support for binding posted file to type IFormFile
- Support for multipart/form-data in FormValueProviderFactory
- Updated Mvc Sample
- Added relevant unit and functional tests
2015-01-15 13:41:14 -08:00
Kirthi Krishnamraju 6a824a4394 Added ModelMetadataType Attribute and logic to get attributes from ModelMetadata class 2015-01-15 13:19:10 -08:00
Pranav K 6641997836 Add support for `@removeTagHelpers` inheritance from _ViewStart files
Fixes #1657
2015-01-15 12:12:00 -08:00
Harsh Gupta 106b9fc30c Adding proper descriptions in readme.md files for functional tests. 2015-01-15 11:12:48 -08:00
Chris Ross 91d7e382d1 Consume new strongly typed headers. Remove temp implementations. 2015-01-14 15:51:34 -08:00
N. Taylor Mullen 8529ea2f0d React to aspnet/Razor#240.
- Updated tests to account for new casing.
2015-01-13 22:35:43 -08:00
NTaylorMullen 4c20352e2a Updated test files to react to aspnet/Razor#260. 2015-01-13 21:32:05 -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
Doug Bunting c0d27ee56d Add `CultureReplacerMiddleware` for use in functional test web sites
- #1766
- use `ReplaceCultureAttribute` to avoid `CultureReplacer` thread consistency checks
- also update test expectations to match new formats

nit: use `UseMiddleware()` extension method rather than `app.Use()`
2015-01-13 12:49:02 -08:00
Youngjune Hong 40e479c915 MvcTagHelpers tests for
1) A few `<input/>` tag helpers in a partial view invoked (`@Html.PartialAsync()`) in a loop within a `@for` inside an `using @Html.BeginForm()` block.
2) A custom template e.g. EditorTemplates/MyType.cshtml containing a mix of `<input/>`, `<select/>`, and various input HTML helpers invoked (`@Html.Editor[For]()`) in a loop within a `@for` inside an `using @Html.BeginForm()` block.
3)  `<select/>` tag helpers with an `using @Html.BeginForm()` block
4) HTML helpers in the <form/> tag helper
2015-01-13 10:12:19 -08:00
Pranav K b7d44666b8 Adding support for flowing compilation errors to Diagnostics middleware
Fixes #872
2015-01-13 07:32:58 -08:00
Ajay Bhargav Baaskaran 62b6ab8721 Added missed license header and removed unused file 2015-01-12 17:42:05 -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 61d9c2cbf8 fix build break 2015-01-12 14:36:21 -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
Ajay Bhargav Baaskaran 3dedef422a Merged compiler/resources with Compiler/Resources 2015-01-12 13:29:37 -08:00
Ajay Bhargav Baaskaran 191af4a5a9 added activation tests for tag helpers 2015-01-12 12:51:41 -08:00
Hao Kung 157b633758 React to IContextAccessor -> IScopedInstance 2015-01-12 10:25:21 -08:00
Youngjune Hong f8cb519c2f Adding the functional tests for MvcTagHelpers (1) 2015-01-08 17:23:42 -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
Kiran Challa 227f564098 Logging functional tests using ElmLogger 2015-01-06 16:16:12 -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 51567194dc deleted duplicate action results in WebapiCompatShim 2015-01-06 11:07:22 -08:00
Kiran Challa 391816eb71 [Fixes #1713]WebApiCompatShim doesn't work with Transfer Encoding: chunked 2015-01-05 21:52:13 -08:00
Bruce Bowyer-Smyth af9e9f9113 Remove boxing of chars when concatenated with strings 2015-01-05 19:05:14 -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
Kirthi Krishnamraju 9ea5350271 Added more coverage in functional tests for FlushAsync 2015-01-05 10:36:37 -08:00
Pranav K 68fcb2bfca Temporarily disabling running
UpdateVehicle_WithXml_BindsBodyServicesAndHeaders until we get a
resolution for DataContractSerializer behaving differently in CoreCLR.
2015-01-05 10:15:27 -08:00
Pranav K 110ee28e3e Adding support for flowing compilation settings to views
Fixes #871
2015-01-02 15:34:52 -08:00
Pranav K 62b9db93b6 Removing unused code from UnclassifiedCodeSpanConstructor to fix build 2015-01-02 14:34:57 -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
Ajay Bhargav Baaskaran a818240d8a React to aspnet/Razor#263 changes 2014-12-23 16:34:13 -08:00
N. Taylor Mullen 6afd8710fa React to aspnet/Razor#207 changes. 2014-12-22 10:58:23 -08:00
Pranav K 9df8a1e73f Reacting to FileSystem changes v2 2014-12-19 18:10:57 -08:00
SonjaKhan c936ae80ca Logging assemblies, controllers, and actions 2014-12-18 10:52:20 -08:00
Ajay Bhargav Baaskaran 04c37a8d51 added few taghelper functional tests 2014-12-17 16:31:24 -08:00
Pranav K 22ac7c45e5 Update Mvc to use official xunit runner 2014-12-17 11:27:07 -08:00
sornaks 07043ce1a9 Merge branch 'release' into dev 2014-12-16 14:52:16 -08:00
Kai Ruhnau e0beec90f4 Fixed folder name casing of Compiler/* 2014-12-16 12:32:35 -08:00
Pranav K ce8d840cc6 Adding additional functional tests for ModelBinding 2014-12-16 12:25:37 -08:00
sornaks 1570e198ef Bug #1354 - ViewComponent View() fails on CoreCLR with IEnumerable<> passed in.
Fix - When the model is passed in to a View, ViewDataDictionary sets it. During this process, we recurse through all the properties and create FastPropertyGetters for each of them. In this case, since it is an enumerable, the properties which we recurse through are not the elements of the collection but the properties of the Enumerable instead. i.e - Enumerable.Current. Creating getters for these properties are not necessary. The fix moves the property iteration step to a place where the properties are actually requested.
- Splitting TypeInformation class into two and separating their caches appropriately.
2014-12-16 12:19:38 -08:00
Pranav K e078076408 Adding functional test for RazorViewEngineOptions.FileSystem 2014-12-16 12:08:40 -08:00
Ryan Nowak 6390bad0d3 Adding a pattern for returning 'unhandled' exception information via
middleware.

This should be used where posssible instead of throwing an exception and
catching in a test, as that only works in memory.
2014-12-15 16:29:08 -08:00
Ryan Nowak 1a617eb533 Fix an inadvertent 204 in activator tests
On a web server, this test ends up giving back a 204 because of the MVC
behavior when an action is declared to return void. The fix is to use
EmptyResult.
2014-12-15 11:18:39 -08:00
Pranav K ba5712c824 Merge branch 'release' into dev 2014-12-12 16:56:54 -08:00
DamianEdwards 263e75c8a6 Update tests for Razor Tag Helpers Unique ID feature:
- aspnet/razor#241
2014-12-12 16:27:41 -08:00
Pranav K edc2c2d18c Removing transitive references from aspnetcore50 to unblock build 2014-12-12 12:53:27 -08:00
Doug Bunting 3e26142de1 Remove use of `Assert.DoesNotThrow()`
- no longer in xunit 😃
2014-12-11 15:51:15 -08:00
Praburaj 3dfcc884fe Changes to address IFileSystem.Watch method addition
Absorbs the new IFileSystem interface. This change is to just address the breaking change introduced in IFileSystem.
Razor has to do the necessary changes to subscribe to the Watch event for expiring the modified files.
2014-12-11 10:00:46 -08:00
Ryan Nowak 09b01d8f32 update comment about precompilation (cr feedback) 2014-12-11 09:41:52 -08:00
Ryan Nowak c6bc97afbf Update precompilation to use the library manager instead of relative
paths.

This website is written to assume that $pwd is always in the functional
tests directory when it's launched. This works fine for the functional
tests, but causes issues in many other contexts, including VS.
2014-12-11 09:31:38 -08:00
Ryan Nowak f338f70e06 Update WebAPI shim functional tests to use a header for payload
The issue is that responses to HEAD cannot have a body. When running these
tests on a real server, they break because the server throws when you try
to write to the body.
2014-12-11 09:18:05 -08:00
Ryan Nowak b4975b779c Update names of WebSite projects for consistency
Project/Assembly names are all like 'FeatureWebSite' root namespaces
updated accordingly. This makes processing all of the functional tests and
deploying the web sites much simpler.
2014-12-11 09:10:24 -08:00
Ryan Nowak e65218d6df Adding servers and wwwroot folder to test websites
Adding dependencies and commands for iis, web listener and khestrel to each
site.

Each website comes with a readme.md to 'anchor' the otherwise empty
folder. We have another work item tracking adding content to these.

Once VS sees a project with a wwwroot, it wants to assign a port for iis,
so I let it.
2014-12-10 14:16:11 -08:00
Ryan Nowak 1631ca1a47 Fix for #1681 - Model state errors are wrong with attributes like [FromHeader]
The issue here is that a model state error is added with the model name
'doubled'. This is on a fairly obscure code path and the code dates back
to the original WSR git checkin of webapi. There are no wsr tests that
verify this behavior.

The cause here is that our 'greedy' model binders (like
FromHeaderModelBinder) return 'true' whether or not they successfully
found a model, because they don't want other model binders to run.

This also has an effect on the validation system. That means that
validators will run and attempt to validate the model (which may be null).
That's that rare case where we get to this code path.
2014-12-10 14:03:51 -08:00
Ryan Nowak 9468d741ee Fix for #1671 - Adding [FromHeader] attribute 2014-12-08 11:42:57 -08:00
Harsh Gupta d7094fd32d Adding Support for TryUpdateModel using include expressions and predicate. 2014-12-05 17:28:43 -08:00
Ryan Nowak ca714c5149 CR feedback from [ModelBinderAttribute] 2014-12-05 16:10:07 -08:00
Doug Bunting f94bd53464 Add functional test of MVC tag helper sample
- ensure future changes don't break this sample
2014-12-05 15:48:43 -08:00
Doug Bunting 27beca7738 Fix #1618, Add asp- prefix to custom attributes of MVC tag helpers
- update XML docs to reflect new HTML / custom attribute separation
- update `Exception` messages to use new attribute names
- update MVC tag helper sample to use new custom attribute names
- add missing `<input/>` tag helper `throw`s test

nits:
- reword a few comments and messages for clarity and consistency
- use `<exception/>` sections to describe what's thrown
- add "Reviewers" comments about current throws
 - note `<a/>` and `<form/>` are slightly inconsistent with others: `throw`
   if unable to override specified `href` or `action` attributes; rest
   `throw` only if custom attributes are inconsistent e.g. `<input/>` with
   `asp-format` but no `asp-for`
- create test tag helpers after all property values are available
2014-12-05 15:48:33 -08:00
N. Taylor Mullen b666cce854 Reacted to aspnet/Razor#215 changes. 2014-12-05 15:31:35 -08:00
Pranav K 6ec85baa22 Fixing build break
Change the casing of _ViewStart.cshtml to match the expected case.
2014-12-05 15:16:27 -08:00
Kirthi Krishnamraju d8455c3e64 Make Flush work without requiring curly braces
Fixes #1547
2014-12-05 14:53:09 -08:00
Pranav K 275d03a958 Compilation of Views should be affected by changes to _ViewStart files
that are applicable to the view.

Fixes #974
2014-12-05 14:44:36 -08:00
ianhong 5b1eae494e Update templates\samples\tests to use ensure viewstart.cshtml and views directory names are cased appropriately. #1559 2014-12-05 13:27:22 -08:00
Ryan Nowak 00ce7dcfcc Fix build break 2014-12-05 12:24:19 -08:00
Harsh Gupta e9bcc3f0e8 Adding support for ModelMetadataAttribute in core. 2014-12-05 12:00:19 -08:00
Mugdha Kulkarni ba8cf3ca46 Changed to use OptionalRouteConstraint created by Routing to use for inline optional parameters in attribute routing. Also added tests for inline parameters. 2014-12-04 11:00:48 -08:00
Kiran Challa 00b61ec1e6 [Partial fix for #1372]Added SimpleTypesExcludeFilter to exlcude validation on simple types and also added tests to cover scenarios. 2014-12-03 14:09:51 -08:00
Victor Hurdugaci d788e87a94 React to DI changes part 2 2014-12-03 13:36:54 -08:00
Victor Hurdugaci dbdf2e66ba Update message from DI exception 2014-12-03 13:09:44 -08:00
Pranav K 7b20909a60 Revert changs to Flush point tests made as part of 4ad3e9
This should resolve timing issues that are currently being seen.
2014-12-03 12:56:14 -08:00
Victor Hurdugaci 91549e15a5 React to DI changes 2014-12-03 12:09:31 -08:00