Commit Graph

296 Commits

Author SHA1 Message Date
sornaks 07043ce1a9 Merge branch 'release' into dev 2014-12-16 14:52:16 -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
Doug Bunting 3e26142de1 Remove use of `Assert.DoesNotThrow()`
- no longer in xunit 😃
2014-12-11 15:51:15 -08:00
Harsh Gupta d7094fd32d Adding Support for TryUpdateModel using include expressions and predicate. 2014-12-05 17:28:43 -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
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
Victor Hurdugaci dbdf2e66ba Update message from DI exception 2014-12-03 13:09:44 -08:00
Victor Hurdugaci 91549e15a5 React to DI changes 2014-12-03 12:09:31 -08:00
Ryan Nowak 0152aac7f4 Fix for #1652 - Make Authorization Filters run first
This change moves authorization filters to be the first filter stage
(before exception filters).
2014-12-02 10:39:50 -08:00
Harsh Gupta 2353bd911a Adding Support for TryUpdateModel using include expressions and predicate. 2014-11-26 17:44:50 -08:00
Harsh Gupta b54c326ee6 Updating Associated Metadata Provider to follow the existing pattern. 2014-11-26 16:56:32 -08:00
Ryan Nowak 8ce069f56a [Fixes #393] [Design] Update ViewComponent result apis to be consistent with Controller
1. Updated ViewComponent to exposes similar properties to the existing ones in controller where
appropiate. We've left out Resolver for being a bad pattern (just inject the dependency on the constructor
or use Context.RequestServices to access it if needed) and Response as although available through the Context
property, it shouldn't be used/modified in a ViewComponent.

2. Updated ViewViewComponentResult to follow a similar pattern as ViewResult where the constructor is
parameterless and elements like ViewEngine are resolved during execution if the user does not set the
associated property on the object.

3. Updated ExecuteAsync in JsonViewComponentResult to remove the unnecessary pragma and async keyword from the
signature and to use Task.FromResult(true) instead.

4. Cleaned up ViewViewComponentResult tests.
2014-11-26 15:56:06 -08:00
Ajay Bhargav Baaskaran 9f1cb655f6 matched classnames with filenames 2014-11-25 11:21:17 -08:00
Victor Hurdugaci 99b5f430ff Add schema version to kproj files 2014-11-25 10:57:58 -08:00
Harsh Gupta d00c7ef597 Adding support for property level binding using IBinderMetadata and enabling FromXXX attributes to be decorated on properties. 2014-11-24 21:33:02 -08:00
Pranav K 0e4ec38efe Replacing Assert.Equal(null, Assert.Equal(true \ false etc with
appropriate Xunit equivalents
2014-11-21 08:28:55 -08:00
Doug Bunting 7eb106676c Add missing license headers
- #EngineeringDay
- license present but incorrect in just a few files
- skip generated files such as Resources.Designer.cs and files under
  test\Microsoft.AspNet.Mvc.Razor.Host.Test\TestFiles\Output
2014-11-20 22:54:05 -08:00
Doug Bunting 315908af5f Apply VS' FormatDocument and RemoveAndSort to all *.cs files
- #EngineeringDay
- VS does not yet format auto-properties nicely; reverted what it did

Also revert changes under
- test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles
2014-11-20 21:15:46 -08:00
Ajay Bhargav Baaskaran 90098411c6 [Fixes issue #1528] default reference assemblies made extensible
- Made ReferenceAssemblies and GetCandidateLibraries virtual
- Added relevant tests
2014-11-20 17:20:27 -08:00
Doug Bunting 5e067cdb9e Delete trailing whitespace
- #EngineeringDay
- Total replaced: 660  Matching files: 270 in *.cs
- Total replaced: 250  Matching files: 32 in all other files
- Total replaced: 22  Matching files: 8 in a few stragglers

Did not change files under following directories
- test\Microsoft.AspNet.Mvc.Razor.Host.Test\TestFiles\Output
- test\Microsoft.AspNet.Mvc.FunctionalTests\compiler\resources
- test\WebSites\TagHelpersWebSite
(Razor generates trailing whitespace in a case or two)
2014-11-20 16:18:09 -08:00
Kirthi Krishnamraju 678226a6bf Merge branch 'Fix298' into dev 2014-11-20 15:49:03 -08:00
Kirthi Krishnamraju a0629f4d23 Fix #298 - Added ModelMetadata.Container property and unit tests. 2014-11-20 15:45:02 -08:00
Ryan Nowak 7c961e3ce8 TODO removal
For each of these TODOs:

- If there's an active bug tracking the work, and the TODO provides
  something of value, I left it and standardized the formatting. I also
  added comments to the bug.

- If the comment provided no value (implement feature X when we do feature
  X), I deleted it with impunity.

- If the comment was stale (won't fix or just out of date), then we
  removed it uncerimoniously.

There was a single TODO that was actually actionable, so I enabled that
test.
2014-11-20 15:01:35 -08:00
Pranav K 8a668eb9d1 Adding unit tests for HtmlHelper.Password
Partial fix for #453
2014-11-20 12:12:29 -08:00
Ryan Nowak ed8ba5ae9c Fix for #1194 - Error using [HttpPost] and [Route] together
This change enables some compatibility scenarios with MVC 5 by expanding
the set of legal ways to configure attribute routing. Most promiently, the
following example is now legal:

[HttpPost]
[Route("Products")]
public void MyAction() { }

This will define a single action that accepts POST on route "Products".

See the comments in #1194 for a more detailed description of what changed
with more examples.
2014-11-19 15:52:20 -08:00
ianhong 59b7352e8e Update per comment 2014-11-18 15:35:40 -08:00
ianhong 7b58d569eb ReadOnly attributes for Action, Controller, and Parameter 2014-11-18 15:35:39 -08:00
Ryan Nowak 38b3b61485 update due to breaking changes in routing 2014-11-18 12:37:47 -08:00
Ryan Nowak 5fd453f07d Revert "Fix for MVC #1539 - Deal with the case where request services are not set"
This reverts commit d9a3c265ea.

This was the wrong commit, did not intent to merge this.
2014-11-17 18:33:56 -08:00
Ryan Nowak d9a3c265ea Fix for MVC #1539 - Deal with the case where request services are not set
Rather than throwing here, this does what routing does. If request
services aren't set, we just create our own scope.

This will NOT create an extra scope if request services are already set.
2014-11-17 17:30:41 -08:00
Doug Bunting 7e8870cb9f Per PR discussion
- clean up "the the" in XML comments
- simplify refactoring VS did when I renamed `GetHtmlHelperForViewData()`
 - fix existing issue in `HtmlHelperCheckboxTest.CheckBoxReplacesUnderscoresInHtmlAttributesWithDashes()`
   (was using a `HtmlHelper<ViewDataDictionary<TestModel>>`)
2014-11-12 21:56:11 -08:00
Doug Bunting 1d3ae83507 Address PR comments in test code
- add missing license headers
- make "post" more obvious
- use `Assert.IsAssignableFrom()`

nit: remove unused `using`s in `HtmlHelperLinkGenerationTest`
2014-11-12 21:56:03 -08:00
Doug Bunting 2982c72547 Add `Html.BeginForm()` and `Html.BeginRouteForm()` tests
- helps w/ #453 since `Html.BeginForm()` wasn't previously tested
- provide a `DefaultTemplatesUtilities.GetHtmlHelper()` overload with an
  `IHtmlGenerator` parameter
- update `DefaultTemplateUtilities` to use `DefaultHttpContext`
 - stop using a mock for this purpose; provides a non-`null` `Request`

nit:
- `DefaultTemplatesUtilities.GetHtmlHelperForViewData()` -> `...GetHtmlHelper()`
  for consistency with other overloads
2014-11-12 21:55:48 -08:00
Doug Bunting 22fafe298c Add `BeginRouteForm()` HTML helper
- refactor `DefaultHtmlGenerator.GenerateForm()` to support new method

nits:
- correct XML comments
- add a few more code comments
2014-11-12 21:55:40 -08:00
kanchanm 4598505652 Fix to special case Dispose method to be treated as non-action 2014-11-12 14:52:19 -08:00
Ryan Nowak e9d8c845d6 Create a new routedata for each 'router' for MVC
This is the MVC companion to https://github.com/aspnet/Routing/pull/122

As routing flows, routes replace the route data and mutate a copy. This
allows users to make changes that dirty the data without affecting
undesired state changes.

We also add the 'next' router for diagnostic purposes.
2014-11-12 11:10:21 -08:00
Harsh Gupta 6b2f331e8d Adding support for excluding types for validation, based on type names for body bound models. 2014-11-06 11:00:50 -08:00
SonjaKhan 27e0323a8a renaming TraceType to LogLevel 2014-11-06 09:24:02 -08:00
Doug Bunting f7ef604b86 Regenerate .kproj files
- does not seem to have a negative impact
- e.g. sample web projects run / debug fine
2014-11-04 22:41:53 -08:00
Ryan Nowak e37f1ad85f Fix #1502 - Remove duplicate unit tests 2014-11-04 13:30:15 -08:00
Doug Bunting 90e41b905a Add `ModelMetadata.HtmlEncode` property
- use new `ModelMetadata.HtmlEncode` property in HTML helpers
 - specifically in default HTML display and editor object templates (e.g.
   `@Html.DisplayFor()`) when value is non-`null` and the template is invoked
   with template depth greater than 1
- similar to MVC 5.2 commit [2b12791aee4f](https://aspnetwebstack.codeplex.com/SourceControl/changeset/2b12791aee4ffc56c7928b623bb45ee425813021)

nits:
- remove dupe `null` check in `DefaultDisplayTemplates.ObjectTemplate()`
- move backing fields initialized with constants together in `ModelMetadata`
2014-11-03 12:23:33 -08:00
Ryan Nowak 0ccfcc4316 Fix for breaking API change from routing 2014-10-31 18:23:19 -07:00
Ryan Nowak 105c99cbf2 Fix #1370 - Always use the provided formatter in JsonResult
The change here is to always use the provided formatter, instead of using
it as a fallback. This is much less surprising for users.

There are some other subtle changes here and cleanup of the tests, as well
as documentation additions.

The primary change is that we still want to run 'select' on a formatter
even if it's the only one. This allows us to choose a content type based
on the accept header.

In the case of a user-provided formatter, we'll try to honor the best
possible combination of Accept and specified ContentTypes (specified
ContentTypes win if there's a conflict). If nothing works, we'll still run
the user-provided formatter and let it decide what to do.

In the case of the default (formatters from options) we do conneg, and if
there's a conflict, fall back to a global (from services)
JsonOutputFormatter - we let it decide what to do.

This should leave us with a defined and tested behavior for all cases.
2014-10-31 14:30:31 -07:00
sornaks d178200795 Adding functional tests for Filters. 2014-10-31 08:36:31 -07:00
Doug Bunting 5420b9d382 More `ViewDataDictionary` tests
- separate and extend `ViewDataDictionary<TModel>` tests
2014-10-29 19:19:09 -07:00
Doug Bunting c89bca5924 Adjust tests to handle new `ViewDataDictionary` invariants
- ensure `ViewDataDictionary` constructors are not passed a `null` or
  `Mock.Of<IModelMetadataProvider>()` instance
 - `ViewDataDictionary` constructors always use the `IModelMetadataProvider`
- `viewData.ModelMetadata` now never `null`
- `ViewDataDictionary<int>.Model` no longer throws if read before it's written
- `ViewDataDictionary.ModelMetadata` now copied to new instances in fewer cases
 - e.g. don't use unusual `object` datatype with customized `ModelMetadata`
2014-10-29 19:18:59 -07:00
Ryan Nowak 83187945d1 Fix for #1052 - ViewComponents should support fully qualified names
This change adds the concept of a full-name to viewcomponents. View
components can be invoked using either the short name or long name. If the
provided string contains a '.' character, then it will be compared against
full names, otherwise it will be matched against short names only.

The short name is used for view lookups.

If the name is explicitly set via ViewComponent attribute, then the full
name is the name provided. The short name is the portion of the name after
the last '.'. If there are no dots, then the short name and full name are
the same.

If the name is not set explicitly, then it is inferred from the Type and
namespace name. The short name is the Type name, minus the 'ViewComponent'
suffix (if present). The full name is the namespace of the defining class,
plus the short name.
2014-10-29 17:34:01 -07:00
Ryan Nowak 305dd87b9b Fix for #1442 - Find better names for ApiExplorerProperties
Taking the suggestion here to move these to a sub-object. This is future
proof in the event that we need to capture more data for ApiExplorer, and
reads better.
2014-10-28 13:03:19 -07:00
Ryan Nowak 46897037e9 TODO removal part 1 - ActionExecutorTests 2014-10-28 12:54:14 -07:00
Ryan Nowak 9a77c2bc1e Fix for #1448 - ViewComponents must be public top-level classes
ViewComponents and Controllers now follow the same rules exactly for what
types of classes they can be.

Also corrected a bug in a test for controllers. Closed-generic types can
be controllers, the test was wrong.
2014-10-28 12:36:07 -07:00