-
-
Notifications
You must be signed in to change notification settings - Fork 158
Validations Send source.pointer #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validations Send source.pointer #371
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like there were any tests for ModelStateExtensions
. If you have time to write them that would be awesome. Otherwise I'll grab it tonight.
@@ -6,7 +6,7 @@ namespace JsonApiDotNetCore.Extensions | |||
{ | |||
public static class ModelStateExtensions | |||
{ | |||
public static ErrorCollection ConvertToErrorCollection(this ModelStateDictionary modelState) | |||
public static ErrorCollection ConvertToErrorCollection<T>(this ModelStateDictionary modelState, IContextGraph contextGraph) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, that we don't have to release this in a major version, let's leave the original implementation and deprecate it using the [Obsolete("Use the generic overload instead")]
. This prevents us from breaking anyone that is calling this API directly.
Also, I've recently been leaning towards the idea of depending on the static disregard, that's going to be too big of an issue to bite off right now (i.e. there will be broken tests)ContextGraph.Instance
rather than injecting everywhere. I haven't found many reasons the ContextGraph
should change after app start. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 for ContextGraph.Instance
I wonder if that's safe given possible different versions of the API running at once with different context graphs?
If ContextGraph.Instance
is used other places that could still be an issue there, but IDK if we'd want to tie this down too?
@@ -16,10 +16,19 @@ public static ErrorCollection ConvertToErrorCollection(this ModelStateDictionary | |||
|
|||
foreach (var modelError in entry.Value.Errors) | |||
{ | |||
var attrName =contextGraph.GetPublicAttributeName<T>(entry.Key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's do this lookup outside this loop since entry.Key
doesn't change...results in unnecessary enumerations of the graph
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
No description provided.