Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

ArgumentNullException when using [BindProperty] on a private property #6400

Closed
sebastienros opened this issue Jun 15, 2017 · 4 comments
Closed

Comments

@sebastienros
Copy link
Member

sebastienros commented Jun 15, 2017

This is not supported, but the result shouldn't be an exception with this trace:

ArgumentNullException: Value cannot be null.
 Parameter name: metadata
Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer.GetExplorerForExpression(ModelMetadata metadata, Func<object, object> modelAccessor)
Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ExpressionMetadataProvider.FromLambdaExpression<TModel, TResult>(Expression<Func<TModel, TResult>> expression, ViewDataDictionary<TModel> viewData, IModelMetadataProvider metadataProvider)
Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpressionProvider.CreateModelExpression<TModel, TValue>(ViewDataDictionary<TModel> viewData, Expression<Func<TModel, TValue>> expression)
@rynowak
Copy link
Member

rynowak commented Jun 16, 2017

I don't think this has anything to do with [BindProperty], it's the use of a private property in a tag helper like input that would generate a call stack like this

@rynowak
Copy link
Member

rynowak commented Jun 16, 2017

but yes, this is bug

@Eilon Eilon added this to the 2.0.0 milestone Jun 19, 2017
@rynowak
Copy link
Member

rynowak commented Jun 26, 2017

So what I'm planning to do here is add error checking and explain that you should not try to use tag helpers with private properties. We don't support private properties for model binding (they are ignored) so using them for tag helpers won't really have the desired effect.

rynowak added a commit that referenced this issue Jun 26, 2017
If you give ModelExpressionProvider a lambda with a private property
you'll end up here. This wasn't common before, but it seems like users
are more likely to try it with pages.

Model Metadata and Model Binding don't handle private properties, so
supporting it in Model Expressions seems less than useful.

This isn't a breaking change because this case would have resulted in a
null-ref. Addresses #6400
rynowak added a commit that referenced this issue Jul 2, 2017
If you give ModelExpressionProvider a lambda with a private property
you'll end up here. This wasn't common before, but it seems like users
are more likely to try it with pages.

Model Metadata and Model Binding don't handle private properties, so
supporting it in Model Expressions seems less than useful.

This isn't a breaking change because this case would have resulted in a
null-ref. Addresses #6400
rynowak added a commit that referenced this issue Jul 4, 2017
If you give ModelExpressionProvider a lambda with a private property
you'll end up here. This wasn't common before, but it seems like users
are more likely to try it with pages.

Model Metadata and Model Binding don't handle private properties, so
supporting it in Model Expressions seems less than useful.

This isn't a breaking change because this case would have resulted in a
null-ref. Addresses #6400
@rynowak
Copy link
Member

rynowak commented Jul 4, 2017

a23307e

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants