Skip to content

Add coverage for StrictIn local home handling - #85758

Merged
AlekseyTs merged 4 commits into
mainfrom
copilot/add-test-coverage-codegenerator-hashome
Sep 25, 2026
Merged

AlekseyTs merged 4 commits into
mainfrom
copilot/add-test-coverage-codegenerator-hashome

Conversation

Copilot AI commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

CodeGenerator.HasHome lacked coverage for checking whether a lowered StrictIn local has a writable home.

Changes

  • Add a focused compiler unit test that constructs a StrictIn local and verifies it has no writable home.
  • Remove the temporary assertion that intentionally failed when this path was reached.

@azure-pipelines

azure-pipelines Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: AlekseyTs <10522107+AlekseyTs@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit test for untested code path in CodeGenerator.HasHome Add coverage for StrictIn local home handling Sep 23, 2026
Copilot AI requested a review from AlekseyTs September 23, 2026 17:16
public class CodeGenInParametersTests : CompilingTestBase
{
[Fact, WorkItem(85757, "https://github.com/dotnet/roslyn/issues/85757")]
public void HasHome_StrictInLocal()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot While a test like this is useful to preserve the behavior, please try to come up with another unit-test that exercises the code path while compiling some valid C# code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I instrumented the exact branch and tried valid-source scenarios across the extension-indexer/extension-member, reordered explicit in, inline-array, async-spill, and dynamic code-generation paths, including running the full relevant test classes. None reached it: the current lowering producers of StrictIn locals only flow those locals to readonly consumers (ReadOnly/ReadOnlyStrict), so a writable/constrained HasHome check is not presently source-reachable. I restored the instrumentation and kept the direct unit test as the focused coverage for this defensive branch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Please add similar direct unit-test for this code path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the direct BoundDup coverage in af678b1. The test verifies a StrictIn duplicate has a readonly home, and the now-covered fail-fast assertion was removed.

Co-authored-by: AlekseyTs <10522107+AlekseyTs@users.noreply.github.com>
Co-authored-by: AlekseyTs <AlekseyTs@users.noreply.github.com>
@AlekseyTs
AlekseyTs marked this pull request as ready for review September 24, 2026 03:22
Copilot AI lite review requested due to automatic review settings September 24, 2026 03:22
@AlekseyTs
AlekseyTs requested a review from a team as a code owner September 24, 2026 03:22
@AlekseyTs

Copy link
Copy Markdown
Contributor

@dotnet/roslyn-compiler Please review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review issues remain.

Review effort: Lite
Findings: None

What changed in this PR

Adds compiler test coverage for CodeGenerator.HasHome handling of lowered StrictIn locals and duplicates.

Changes:

  • Adds writable and read-only home behavior tests.
  • Removes temporary debug assertions.
File Description
src/​Compilers/​CSharp/​Test/​Emit/​CodeGen/​CodeGenInParametersTests.cs Adds focused StrictIn local and duplicate coverage.
src/​Compilers/​CSharp/​Portable/​CodeGen/​CodeGenerator_HasHome.cs Removes temporary assertions.

}
else if (localRefKind == RefKindExtensions.StrictIn)
{
Debug.Assert(localRefKind != RefKindExtensions.StrictIn, "Add a test if this assert fails for the scenario.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added unit tests call this method directly, not via some full compilation scenario; is that because it's not observable like that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added unit tests call this method directly, not via some full compilation scenario; is that because it's not observable like that?

See Copilot's response at #85758 (comment)

@AlekseyTs
AlekseyTs merged commit 5b9ef75 into main Sep 25, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No test coverage for a code path in CodeGenerator.HasHome

4 participants