-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
Hi @ryanbrandenburg, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! The agreement was validated by .NET Foundation and real humans are currently evaluating your PR. TTYL, DNFBOT; |
@@ -1,6 +1,7 @@ | |||
// Copyright (c) .NET Foundation. All rights reserved. | |||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | |||
|
|||
using System; |
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.
This snuck in from another PR, I'll remove it when I rebase.
9067ce7
to
b6ae7f3
Compare
[Fact] | ||
public async Task ExecuteResultAsync_ViewResultAllowNullViewDataAndTempData() | ||
{ | ||
var context = GetActionContext(); |
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.
we usually decorate tests with // Arrange
, // Act
and // Assert
. Have a look at other tests in this class.
Aside from the small comments, |
Assert.Null(controller.ViewContext.TempData); | ||
} | ||
|
||
private class TestController |
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.
Move this test to ViewExecutorTest.cs
. You shouldn't need a Controller to verify this.
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.
Ah that's actually a good point. Can just new up the type and call Execute from within the test.
⌚ |
^^^ - was thinking the same thought earlier about this bug. There's too much stuff that will maybe read |
Am I signed off then? |
{ | ||
throw new ArgumentNullException(nameof(htmlHelperOptions)); | ||
tempData = new TempDataDictionary(new HttpContextAccessor(), new SessionStateTempDataProvider()); |
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.
The HttpContextAccessor
might need to point to the current ActionContext.HttpContext
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.
We should be service-locating ITempDataDictionary
and IModelMetadataProvider
here - this isn't a unit-test-only scenario.
a4f1507
to
ca69d76
Compare
@rynowak Do those changes satisfy the dependency injection problems? |
} | ||
var service = actionContext.HttpContext.RequestServices; |
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.
services
bea9fea
to
3e2ec3d
Compare
@rynowak is that better? |
{ | ||
throw new ArgumentNullException(nameof(htmlHelperOptions)); | ||
throw new ArgumentNullException(nameof(tempData)); |
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.
Restore these null
checks in their original order. That nicely matched the parameter order.
Wondering whether we should leave all but the main |
⌚ |
public async Task ExecuteAsync_ViewResultAllowNull() | ||
{ | ||
bool tempDataNull = false; | ||
bool viewDataNull = false; |
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.
var
⌚ |
Doug, about consolidating into the ViewContext, @rynowak is of the opinion, and he convinced me, that contexts should be dumb bags of objects that don't have any logic in them. Your suggestion would certainly simplify things a bit, but at the expense of having the Context violate its dumbness. |
I believe I've addressed everything now, is there a ship it? |
@@ -6,6 +6,7 @@ | |||
using Microsoft.AspNet.Mvc.ModelBinding; | |||
using Microsoft.AspNet.Mvc.ViewEngines; | |||
using Microsoft.AspNet.Mvc.ViewFeatures; | |||
using Microsoft.Extensions.DependencyInjection; |
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.
Minor but you don't need this anymore. That is, revert everything in this file.
once the CI builds start working. Problem looks like something propagating through our builds and not at Coherence yet. But it could hide something real.
|
f94ae7f
to
8565b2f
Compare
8565b2f
to
0b8fe87
Compare
If you're manually constructing a ViewResult you shouldn't have to pass in a ViewData and TempData just for us. This change allows them to be left null, the behavior on a resulting page being that references to ViewData just don't put anything out and references to TempData cause a 500.