Commit Graph

987 Commits

Author SHA1 Message Date
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
Pranav K 3aaeebd9c5 Revert "Revert "Added a functional test for view precompilation""
This reverts commit 6b2ab32885.
2014-10-30 14:38:44 -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
Doug Bunting 97aaa7049e Correct code checking for `ViewDataDictionary.ModelMetadata==null`
- `null` checks can generally be removed but in one case needed to
  special-case metadata for `object`

nit: remove duplicate empty `string` check in
`ExpressionMetadataProvider.FromStringExpression()`
2014-10-29 19:18:31 -07:00
Doug Bunting e73655229c Correct some `ViewDataDictionary` constructor calls
- ensure correct `ViewData.ModelState` value in a `RazorPage` instance
- let view components inherit `ViewData.Model` from surrounding context
- do not create an isolated `ViewDataDictionary<TModel>` in one HTML helper
 - allows previous `ViewDataDictionary<TModel>` constructor to be `internal`
  - also add comments for that constructor
- change two `ViewDataDictionary` copy constructor calls to avoid uselessly
  copying `Model` and related information from source
2014-10-29 19:18:20 -07:00
Doug Bunting a3b07dacdb Rework `ViewDataDictionary` constructors to ensure `ModelMetadata` is never `null`
- `ViewDataDictionary<TModel>` constructors now pass `typeof(TModel)` to base
  `protected` constructors
 - move type compatibility checks into base `ViewDataDictionary`
 - remove `ViewDataDictionary<TModel>.ModelMetadata` override
- don't retrieve `ModelMetadata` twice in a single constructor invocation
- remove newly-unused `protected` properties and use `private` fields in copy
  constructors

Address longstanding problems found (see #1466)
- avoid reusing `ModelMetadata` after `Model` value changes
 - reset `ModelMetadata` backing field in `Model` setter
 - `Model` and `ModelMetadata.Model` could previously get out of sync
- carry `ModelMetadata` forward from an outer scope only if `Model` matches
 - previously two scopes could have different `Model` values but share their
   `ModelMetadata` (and `ModelMetadata.Model`)
 - related to previous item but didn't require `Model` setting; switching
   to a property of the same type as containing `Model` was enough
- avoid NRE if `ViewDataDictionary<int>.Model` is read before it's written
 - problem affected all non-`Nullable` value types
- `ViewDataDictionary.ModelMetadata` setter should throw if value is `null`

nits:
- add and reword doc and code comments
 - `ViewDataDictionary<TModel>` constructors should only inherit base's
   parameter descriptions; have more information in the derived class
- make a few `ViewDataDictionary` properties get-only
- clean up `using` statements in `ViewDataDictionary<TModel>`
- make two constructors `internal`
2014-10-29 19:03:58 -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
Kirthi Krishnamraju dc1aaf0664 Merge branch 'release' into dev 2014-10-29 13:42:56 -07:00
Kirthi Krishnamraju 028a2359a4 Added description in project.json for all projects 2014-10-29 13:40:31 -07:00
Pranav K 5f8c410d0b Merge branch 'release' into dev 2014-10-29 10:23:13 -07:00
Pranav K 07ff6eb3be Update to JSON.Net 6.0.6
Fixes #1473
2014-10-29 10:18:55 -07:00
jacalvar 6b2ab32885 Revert "Added a functional test for view precompilation"
This reverts commit 310feeb826.
2014-10-28 19:14:50 -07:00
jacalvar 310feeb826 Added a functional test for view precompilation 2014-10-28 18:38:15 -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
Pranav K 1e5fd25375 Merge branch 'release' into dev 2014-10-28 12:31:23 -07:00
Pranav K e25e4c4a5d Change logging in Mvc to log with TraceType.Verbose
Fixes #1457
2014-10-28 12:11:33 -07:00
Pranav K cfd38d2845 Merge branch 'release' into dev 2014-10-28 06:57:23 -07:00
Pranav K d35057deea Reacting to Roslyn version changes 2014-10-28 06:34:06 -07:00
Pranav K 6c4462a76f * Porting Hidden and HiddenFor unit tests
Partial fix to #453
2014-10-27 17:54:56 -07:00
Doug Bunting 1f670bf3a7 Merge branch 'release' into dev 2014-10-27 16:43:02 -07:00
Doug Bunting cfcb1f2e2f Add more unit tests of `ViewDataDictionary` copy constructors 2014-10-27 16:26:04 -07:00
Doug Bunting 4bde6f6caf Add "/home/nulluser" view to MVC sample
- exercises display and editor helpers when `Model==null`
2014-10-27 16:25:48 -07:00
Doug Bunting 8d2a1c47e5 Change `ViewDataDictionary` copy constructor to ensure `ModelMetadata` is
never that for `object`
- `ViewDataDictionary<TModel>.ModelMetadata` was for `object` after base
 copy constructor got value from `ViewDataDictionary<object>`
- problem led to #1426 symptoms
- with copy constructor leaving `base.ModelMetadata==null` more often,
 `ViewDataDictionary<TModel>.ModelMetadata` usually tracks `TModel` if
 `Model==null`

nit:
- fix existing comment in main `ViewDataDictionary` copy constructor
2014-10-27 16:25:24 -07:00
David Fowler 653d31b336 Don't lock metadata references 2014-10-27 16:14:32 -07:00
Pranav K e0116bab30 Modifying ArgumentNullOrEmpty message to be consistent with Mvc 5 \
testing code.
2014-10-27 15:07:53 -07:00
N. Taylor Mullen 7934c432c8 React to case insensitive TagHelperOutput.Attributes.
- Cleaned up some existing bad code that worked around case sensitive TagHelperOutput.Attributes.
- Modified MergeAttributes to be case insensitive when it comes to merging class attributes.
- Added a test to verify the new MergeAttribute case insensitive class merging.

aspnet/Razor#186
2014-10-26 13:32:11 -07:00
N. Taylor Mullen 09af7bb77b Change TagBuilder Attributes and HTML Helper dependencies to be case insensitive.
- This involved adding the StringComparer.OrdinalIgnoreCase comparer to the TagBuilder's Attributes dictionary.
- Added tests to validate that all methods that made use of TagBuilder.Attributes abide by the new ignore case mechanic.
- Added two sets of tests to validate the new functionality of Object => Dictionary HTML helper tests.
- Modified a functional test that utilizes HTML Helpers to provide same attribute-different case objects.
- Fixed existing HTML helper tests to account for new ordering of attrbutes (dictionary no longer adds key value pairs, it sets them).

#1328
2014-10-26 13:15:09 -07:00
Pranav K 1e3828eb7d Changing NewtonSoft.Json version to 6.0.6 2014-10-24 01:16:32 -07:00
Pranav K e174b66b4f Reacting to System.Collections.Concurrent versioning change 2014-10-23 23:10:18 -07:00
Ryan Nowak 0a3ad09466 Rename GlobalModel -> ApplicationModel
This also comes with a rename of the namespace
Microsoft.AspNet.Mvc.ApplicationModel to
Microsoft.AspNet.Mvc.ApplicationModels.

Also tuned up some parameter and variable names for increased
understandability.
2014-10-23 16:03:55 -07:00
Ryan Nowak 7012b3fc2b Fix for #996 - ViewComponentInvoker should get TypeActivator from DI. 2014-10-23 13:48:11 -07:00
Ryan Nowak 7ae5e66ccd Refactoring the ControllerActionDescriptorProvider 2014-10-23 12:25:25 -07:00
Pranav K 756f8be49c CompositeValueProvider.GetKeysFromPrefixAsync throws null if provider is not an
IEnumerableValueProvider

Fixes #1419
2014-10-23 11:05:06 -07:00
Pranav K 26cd8df577 Adding functional tests to verify round tripping of names generated by
HtmlHelpers
2014-10-23 10:12:02 -07:00
David Fowler c39efc88aa Merge branch 'release' into dev 2014-10-22 23:23:09 -07:00
David Fowler 4cddf880ec React to KRuntime change 2014-10-22 23:21:41 -07:00
YishaiGalatzer 4efdae2190 Merge branch 'release' into dev 2014-10-22 17:15:41 -07:00
YishaiGalatzer f9661dfcd0 Fix pdb generation for win7/coreclr 2014-10-22 17:09:39 -07:00
Pranav K 9e3a92e569 Revert "Mvc should not pull in the K.Roslyn package"
This reverts commit 6050d73554.
2014-10-22 15:27:16 -07:00
Pranav K 1bbdc7c1c9 Merge remote-tracking branch 'origin/release' into dev 2014-10-22 15:26:35 -07:00
sornaks 1dd1652dcf Issue #220 - Flags enum does not bind
Fix - After TypeConverter support this works. Adding tests for the same.
2014-10-22 13:55:28 -07:00
Pranav K 6050d73554 Mvc should not pull in the K.Roslyn package
Fixes #1427
2014-10-22 11:15:57 -07:00
Pranav K 78bda87730 Replacing ViewResultBase with ViewExecutor 2014-10-22 08:47:22 -07:00
Harsh Gupta eccefaffba Fix for #291 : Reacting to addition of Base64UrlDecode and Base64UrlEncode in webUtilities. 2014-10-21 11:26:17 -07:00
Pranav K 79ad19f8bd Porting CheckBox and CheckBoxFor unit tests
Partial fix to #453
2014-10-20 11:12:10 -07:00
Doug Bunting d31e107619 Add `SelectTagHelper` tests 2014-10-19 22:29:50 -07:00