Skip to content

Conversation

@VSadov
Copy link
Member

@VSadov VSadov commented Oct 20, 2025

Async methods in structs can compile and work correctly now.

This is a test-only change that removes workarounds.

@VSadov VSadov added test-enhancement Improvements of test source code area-VM-coreclr runtime-async labels Oct 20, 2025
@VSadov VSadov changed the title Nyis[RuntimeAsync] Remove no longer needed workarounds for Roslyn NYIs [RuntimeAsync] Remove no longer needed workarounds for Roslyn NYIs Oct 20, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@VSadov VSadov marked this pull request as ready for review October 31, 2025 20:31
Copilot AI review requested due to automatic review settings October 31, 2025 20:31
@VSadov
Copy link
Member Author

VSadov commented Oct 31, 2025

/ba-g this is a test-only change in a disabled test area. (verified that it passes when enabled)

@VSadov VSadov merged commit 0ad494b into dotnet:main Oct 31, 2025
16 of 60 checks passed
@VSadov VSadov deleted the nyis branch October 31, 2025 20:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes the async struct test by removing obsolete workarounds. The changes eliminate manual @this variable copies that were previously needed to work around C# compiler limitations in a prototype phase, simplifying the code to use this directly.

Key Changes

  • Removed TODO comments and manual @this variable workarounds from async methods
  • Direct usage of this in struct async methods Test() and InstanceCall()

Comment on lines +50 to +56
AssertEqual(100, this.Value);
this.Value++;
await this.InstanceCall();
AssertEqual(101, this.Value);

AssertEqual(100, @this.Value);
@this.Value++;
await @this.InstanceCall();
AssertEqual(101, @this.Value);

await @this.TaskButNotAsync();
AssertEqual(102, @this.Value);
await this.TaskButNotAsync();
AssertEqual(102, this.Value);
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

The test expects this.Value to remain 101 after the async operation (line 53), but since structs are value types and this is passed by value to async methods, mutations in InstanceCall() won't affect the caller's copy. After removing the @this workaround, this test logic may be incorrect unless the C# compiler now generates code to properly handle struct mutation across await points with by-ref semantics.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants