[release/10.0] Source code updates from dotnet/dotnet - #1
Conversation
Code Review by Qodo
1. [TestMethod] used in xUnit tests
|
| [TestMethod] | ||
| [QuarantinedTest("https://github.com/dotnet/aspnetcore/pull/63708/")] |
There was a problem hiding this comment.
1. [testmethod] used in xunit tests 📘 Rule violation ✓ Correctness
• The updated test method NavigationException_InAsyncContext_DoesNotBecomeUnobservedTaskException() is annotated with MSTest’s [TestMethod], and the file adds Microsoft.VisualStudio.TestTools.UnitTesting. • This violates the requirement that test projects use xUnit attributes (e.g., [Fact], [Theory]), and may cause the test to be undiscoverable/incorrectly executed under the repository’s standard test runner configuration.
Agent prompt
## Issue description
A test method was converted to MSTest (`[TestMethod]`) and the file now imports `Microsoft.VisualStudio.TestTools.UnitTesting`, but repository compliance requires xUnit.
## Issue Context
This file already uses xUnit patterns elsewhere (e.g., `[Theory]`, `[InlineData]`), so MSTest usage is inconsistent and violates the compliance rule.
## Fix Focus Areas
- src/Components/test/E2ETest/ServerRenderingTests/RedirectionTest.cs[7-10]
- src/Components/test/E2ETest/ServerRenderingTests/RedirectionTest.cs[287-298]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| public void NavigationException_InAsyncContext_DoesNotBecomeUnobservedTaskException() | ||
| { | ||
| AppContext.SetSwitch("Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException", false); | ||
| AppContext.SetSwitch("Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException", true); | ||
|
|
||
| // Navigate to the page that triggers the circular redirect. | ||
| Navigate($"{ServerPathBase}/redirect/circular"); |
There was a problem hiding this comment.
2. Missing aaa comments in test 📘 Rule violation ✓ Correctness
• The modified test method NavigationException_InAsyncContext_DoesNotBecomeUnobservedTaskException() does not include explicit // Arrange, // Act, and // Assert comments to delineate phases. • This reduces test readability and makes it harder to maintain/extend the test consistently with the repository’s test structure standard.
Agent prompt
## Issue description
The updated test method does not include explicit Arrange/Act/Assert comments, violating the required AAA structure for test readability.
## Issue Context
The method includes setup (`AppContext.SetSwitch`), execution (`Navigate(...)`), and verification (`Browser.Equal(...)`) but does not label them as `// Arrange`, `// Act`, and `// Assert`.
## Fix Focus Areas
- src/Components/test/E2ETest/ServerRenderingTests/RedirectionTest.cs[289-298]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| public override async Task InitializeAsync() | ||
| { | ||
| await base.InitializeAsync(); | ||
| Navigate($"{ServerPathBase}/redirect"); | ||
|
|
||
| _originalH1Element = Browser.Exists(By.TagName("h1")); | ||
| Navigate($"{ServerPathBase}/redirect"); | ||
| Browser.Equal("Redirections", () => _originalH1Element.Text); | ||
| } |
There was a problem hiding this comment.
3. Stale h1 element captured 🐞 Bug ⛯ Reliability
• InitializeAsync now stores _originalH1Element before navigating to /redirect. • The project’s Navigate helper intentionally performs a full page reload (about:blank then the target URL), so any previously captured IWebElement becomes stale. • Subsequent uses of _originalH1Element.Text will repeatedly hit StaleElementReferenceException/timeouts, breaking this test class and any test depending on _originalH1Element.
Agent prompt
### Issue description
`_originalH1Element` is captured before a full page navigation, making it stale and causing subsequent assertions to fail/time out.
### Issue Context
`Navigate` performs `about:blank` then the destination URL, so DOM element references must be acquired after navigation.
### Fix Focus Areas
- src/Components/test/E2ETest/ServerRenderingTests/RedirectionTest.cs[28-35]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| Assert.EndsWith("/subdir/nav/scroll-to-hash?foo=%F0%9F%99%82", Browser.Url); | ||
|
|
||
| // See that 'back' takes you to the place from before the redirection | ||
| Browser.Navigate().Back(); | ||
| Browser.Navigate().Forward(); | ||
| Browser.Equal("Redirections", () => _originalH1Element.Text); | ||
| Assert.EndsWith("/subdir/redirect", Browser.Url); |
There was a problem hiding this comment.
4. Uses forward not back 🐞 Bug ✓ Correctness
• RedirectEnhancedGetToInternal changed browser history navigation from Back() to Forward() while the comment and assertions still describe “back”. • After clicking a link, there is typically no forward history entry; Forward() will be a no-op and the test will not return to the expected “Redirections” page. • This makes the test logic inconsistent with other similar tests in the same file that validate history via Back().
Agent prompt
### Issue description
The test intends to validate browser back-button behavior but calls `Forward()`.
### Issue Context
Other tests in the same file validate history via `Back()`.
### Fix Focus Areas
- src/Components/test/E2ETest/ServerRenderingTests/RedirectionTest.cs[108-116]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| public void NavigationException_InAsyncContext_DoesNotBecomeUnobservedTaskException() | ||
| { | ||
| AppContext.SetSwitch("Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException", false); | ||
| AppContext.SetSwitch("Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException", true); | ||
|
|
||
| // Navigate to the page that triggers the circular redirect. | ||
| Navigate($"{ServerPathBase}/redirect/circular"); |
There was a problem hiding this comment.
5. Switch change alters intent 🐞 Bug ✓ Correctness
• The quarantined navigation test now sets DisableThrowNavigationException to true, which disables throwing NavigationException. • If this test’s purpose is to ensure a thrown NavigationException in an async context doesn’t become an unobserved task exception, this change likely stops exercising the relevant code path. • If the intent is to temporarily avoid the exception while quarantined, the test name/assertions should be updated to reflect the new behavior (or the switch change should be reverted).
Agent prompt
### Issue description
The test’s feature-switch setting now disables throwing `NavigationException`, which may no longer match the test’s stated intent.
### Issue Context
`DisableThrowNavigationException=true` causes `_throwNavigationException` to be false.
### Fix Focus Areas
- src/Components/test/E2ETest/ServerRenderingTests/RedirectionTest.cs[289-297]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Benchmark PR from agentic-review-benchmarks#1