Repository navigation
Clear the Windows build's warnings in the alert notebook endpoint, its tests, and the store upgrade's secret check - #4460
Merged
Conversation
…s tests, and the store upgrade's secret check The Windows build reported 25 warnings across the Darling.Tests and service projects: CS8602 null-dereference warnings in four alert notebook template test files, CA1068 (CancellationToken not last) in five methods across AlertNotebookEndpoint.cs and DarlingWebEndpoints.cs, a CS8604 possible-null-argument warning in DarlingStoreUpgrade.cs, and a handful of xUnit analyzer warnings already present at the branch's starting point. - CS8602 in the four AlertNotebookTemplate*Tests files: the tests called template!.Value.BuildCells(...) directly, and the compiler cannot narrow BuildCells (a nullable delegate field) through that chain. Each site now assigns the delegate to a local, asserts it non-null, then invokes the local. - CA1068 in AlertNotebookEndpoint's BuildCellsAsync, PrefetchAsync (both overloads), PrefetchCustomRuleAsync, and PrefetchAnalysisFindingAsync: moved CancellationToken to the last parameter and updated every call site (the endpoint's own call, the test file, and the other prefetch overload). None of the four is a route handler or a delegate the framework binds directly -- they are internal helpers BuildCellsAsync and its single caller in Map's handler use -- so no endpoint behavior changed. - CA1068 in DarlingWebEndpoints's RecordComposeLatency: moved CancellationToken last and updated its one call site. Same reasoning: a private helper, not a bound delegate. - CS8604 in DarlingStoreUpgrade.cs: NameMayHoldASecret(name) was called after a tuple deconstruction where name could be null. The read of every caller shows null cannot actually reach it in a probeable setting -- name is null only for a comment/blank/include-directive line, which the very next check already carries and continues past before ever calling NameMayHoldASecret. Folded that null check into the same branch's condition instead of asserting non-null with '!', so the type states what was already true. - The four pre-existing xUnit2000/2013/2031 warnings (unrelated to the 25 above, found while re-running the build to reach zero) are fixed the same way the analyzer recommends: Assert.Single's filtering overload instead of .Where(...).Single(), and swapping Assert.Equal's expected/actual order to match the constant. No suppressions, no new CI gate, no behavior changes for any external caller. ## CHANGELOG entry SECTION: None ENTRY: None: internal build-warning cleanup with no user-visible effect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The release checklist calls for a Windows build with 0 Warning(s) / 0 Error(s), test projects included. Building
Darling/Darling.Tests/Darling.Tests.csprojclean (--no-incremental, Release,-p:EnableWindowsTargeting=true) at the branch's starting point ondevreported 29 Warning(s) (a build run further back ondevhad reported 25;devhad moved since then):CancellationTokennot last) — 4 inAlertNotebookEndpoint.cs(introduced with Add authored-notebook context plumbing (#4223) #4425'sPrefetchAsync/BuildCellsAsyncextraction) and 1 inDarlingWebEndpoints.cs'sRecordComposeLatency(introduced by Record web and composed-panel read durations into hourly latency histograms in the store (#4442) #4451/Add get_read_latency: p50/p95/p99 durations per web and MCP read, and name the web and MCP store connections (#4442) #4454's read-latency recording), each counted twice by the two build steps that touch this project.DarlingStoreUpgrade.cs:3413(from Carry an operator's postgresql.conf lines below the include across a major upgrade (#4358) #4405, the operator-conf carry for Carry operator lines below the darling-managed.conf include across a major PostgreSQL upgrade #4358).PerformanceMonitor.Darling.ViewerandLite.Testsboth already build at 0 Warning(s) and are unchanged.What changes
CS8602 (tests): each of the 15 sites called
template!.Value.BuildCells(...)directly.BuildCellsis a nullable delegate field on areadonly record struct, and the compiler can't narrow it through that member-access chain even afterAssert.NotNull(template). Fixed by assigning the delegate to a local (var buildCells = template!.Value.BuildCells;), asserting that non-null, then invoking the local. Behavior-preserving; same delegate, same arguments.CA1068 in
AlertNotebookEndpoint.cs:BuildCellsAsync, bothPrefetchAsyncoverloads,PrefetchCustomRuleAsync, andPrefetchAnalysisFindingAsyncall hadCancellationTokenin the middle of their parameter list. Route-binding check: none of the four is aMapGet/MapPostlambda or anything the framework binds by reflection —BuildCellsAsyncis an internal static methodMap's handler calls directly (extracted for #4425 testability), and the threePrefetch*methods are its own internal helpers. MovedCancellationTokento the last parameter on all four and updated every call site: the endpoint's own call inMap's handler, the shortPrefetchAsyncoverload's delegation to the long one, the internal switch in the longPrefetchAsyncthat calls the twoPrefetchCustomRuleAsync/PrefetchAnalysisFindingAsyncmethods, and the test file's calls (all named-argument, so only the argument order needed to move). No endpoint route or public contract changed.CA1068 in
DarlingWebEndpoints.cs:RecordComposeLatencyhad the same issue. It's a private static helper called from one place inside the compose-run handler, not a bound delegate. MovedCancellationTokenlast and updated its one call site.CS8604 in
DarlingStoreUpgrade.cs:3413:NameMayHoldASecret(name)is called aftervar (_, name, _) = DarlingManagedPostgres.ParseConfText(rawLine).FirstOrDefault();, wherenameisstring?. Reading the surrounding code: the very next check up above already testsname is not null(as part ofisProbeableSetting) andcontinues pastNameMayHoldASecretfor any line wherenameis null (a comment, blank line, or include directive) — those lines never reach line 3413 at all. So null genuinely cannot reachNameMayHoldASecret; the compiler just couldn't see it through the two-variableisProbeableSettingboolean. Fixed by folding the null check directly into the guard's condition (if (name is null || s_confIncludeDirectiveNames.Contains(name, ...))) so the flow the type-checker follows is the same flow the code already had — no!, no behavior change, no new guard, no CHANGELOG-worthy effect.xUnit analyzer warnings. The five
xUnit2031lines were already in the Windowsbuildjob of dev push run 36268957930. The other two files merged after that run, and the same analyzers flag them:ViewerFinOpsIntervalHonestLiveTests.cs(5 sites):xUnit2031forAssert.Single(collection.Where(predicate))→Assert.Single(collection, predicate).PairedClientDeadlinesTests.cs:68:xUnit2000— swappedAssert.Equal(ceiling, McpCommandDeadlines.ComposedQueryFallbackSeconds)toAssert.Equal(McpCommandDeadlines.ComposedQueryFallbackSeconds, ceiling)so the constant is theexpectedargument. No bound or relation changed; this is the exact assertion Web viewer: stop sending exception text to the browser on the remaining paths (#4283) #4293/Web viewer: tool errors still show the exception text in the browser #4283 already pinned, just with its arguments in the order the analyzer wants.GetReadLatencyLiveTests.cs(2 sites):xUnit2013—Assert.Equal(1, collection.Length)→var x = Assert.Single(collection), then asserting onxinstead ofcollection[0].No suppressions (
#pragma warning disable,NoWarn,WarningsAsErrors) anywhere, and no new CI gate.Updated source-text pins
None of the
AlertNotebook*pins that assert call text or shape (the #4425 pins reachingBuildCellsAsync/PrefetchAsyncthroughAlertNotebookAuthoredContextTests) broke — the reorder only moved aCancellationTokenargument's position in named-argument calls, and the compiler enforced every non-test call site. No pin text changed in meaning; only the twoBuildCellsAsync/PrefetchAsynccall sites inAlertNotebookAuthoredContextTests.cshad their trailingct:/positional-CancellationToken.Noneargument moved to match the new parameter order.Test plan
RED (clean build at the branch's start,
dotnet build Darling/Darling.Tests/Darling.Tests.csproj -c Release -p:EnableWindowsTargeting=true --no-incremental):29 Warning(s) / 0 Error(s), unique lines: 15×CS8602 (the four template test files), 10×CA1068 (5 unique sites, each counted twice), 1×CS8604 (DarlingStoreUpgrade.cs:3413), plus the 4 unique xUnit warnings.GREEN (same build, after the fix):
0 Warning(s) / 0 Error(s).PerformanceMonitor.Darling.ViewerandLite.Tests:0 Warning(s) / 0 Error(s)both before and after (unchanged).Mutation (proves the CA1068 pin is live, not tautological): moved
CancellationTokenback to the front ofPrefetchCustomRuleAsync's parameter list (and its one call site) — rebuild reported exactlywarning CA1068at that line,1 Warning(s). Reverted; rebuild returned to0 Warning(s).AlertNotebook* test classes run in-process (
dotnet Darling.Tests.dll -class <name>, after stripping theMicrosoft.WindowsDesktop.Appframework reference from the runtimeconfig, on this Mac):All 0 Errors, 0 Failed.
Also ran
DocCommentHygieneTests(77, 0 Failed — required after touching doc comments/members) andDarlingStoreUpgradeTests(the class coveringCarryOperatorConfLinesAsync, the caller ofNameMayHoldASecret): 146 Total, 6 Failed, 13 Skipped. The 6 failures are pre-existing and unrelated: they assert literal Windows path strings (e.g."C:\\Program Files\\Darling\\pg-runtime-prev") that fail on this Mac's/private/var/...paths — a macOS-vs-Windows path-format mismatch, not a regression from this change. Ran the twoCarryOperatorConfLinesAsync_*tests individually (the ones that actually exercise theNameMayHoldASecretcall site): both pass, 0 Failed.Darling.Tests.dll,PerformanceMonitor.Darling.Viewer, andLite.Testsall BUILD on macOS (targetnet10.0-windows) but the six Windows-path-specificDarlingStoreUpgradeTestsfailures and any WPF-touching test cannot run here; CI decides those.Not run here: the 4 skipped
AlertNotebookAuthoredContextTestsfacts need live PostgreSQL, so CI's PostgreSQL shards run them. The 6DarlingStoreUpgradeTestsfailures on this Mac were not compared against a run ondev. They assert Windows path strings, so CI on Windows decides them.How to check it
This PR's own Windows
buildjob must read0 Warning(s)in the Darling build step (dotnet build Darling/Darling.Tests/Darling.Tests.csproj -c Release --no-restore && dotnet build Darling/PerformanceMonitor.Darling.Viewer/...). That's the merge gate.CHANGELOG entry
None: warning cleanup with no behavior change (the one product condition rewritten, in
DarlingStoreUpgrade.cs, is logically identical).