Skip to content

Fix another RuntimeAsync NRE with hoisted methods#82624

Open
333fred wants to merge 6 commits intodotnet:mainfrom
333fred:nre-2
Open

Fix another RuntimeAsync NRE with hoisted methods#82624
333fred wants to merge 6 commits intodotnet:mainfrom
333fred:nre-2

Conversation

@333fred
Copy link
Member

@333fred 333fred commented Mar 4, 2026

As pointed out by @AlekseyTs, CSharpCompilation.IsRuntimeAsyncEnabledIn was assuming that only SourceMethodSymbols would be passed in. This isn't true for extension blocks after local rewriting, which indeed caused a crash when a couple of tests were augmented with attribute-level runtime async codegen suppression. To fix, we move the attribute check up to MethodSymbol and implement across all of our symbol types. Fixes #82571.

Relates to test plan #75960.

As pointed out by @AlekseyTs, `CSharpCompilation.IsRuntimeAsyncEnabledIn` was assuming that only `SourceMethodSymbol`s would be passed in. This isn't true for extension blocks after local rewriting, which indeed caused a crash when a couple of tests were augmented with attribute-level runtime async codegen suppression. To fix, we move the attribute check up to `MethodSymbol` and implement across all of our symbol types. Fixes dotnet#82571.
@333fred
Copy link
Member Author

333fred commented Mar 4, 2026

@jcouv @AlekseyTs @dotnet/roslyn-compiler for review

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Mar 4, 2026

Done with review pass (commit 2) #Closed

@jcouv jcouv self-assigned this Mar 7, 2026
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Done with review pass (commit 2)

@333fred
Copy link
Member Author

333fred commented Mar 10, 2026

@AlekseyTs @jcouv I've addressed feedback. I've also renamed the property for clarity, since it's not "whether runtime async is enabled", but is actually "whether there's an attribute that's explicitly controlling runtime async".

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 3)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Done with review pass (commit 3). Just waiting to see how EE question turns out

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 4)

@333fred
Copy link
Member Author

333fred commented Mar 12, 2026

@AlekseyTs @jcouv for another look please.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (commit 5)


public override bool IsAsync => _underlyingMethod.IsAsync;

internal sealed override ThreeState RuntimeAsyncMethodGenerationAttributeSetting => _underlyingMethod.RuntimeAsyncMethodGenerationAttributeSetting;
Copy link
Contributor

@AlekseyTs AlekseyTs Mar 13, 2026

Choose a reason for hiding this comment

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

_underlyingMethod.RuntimeAsyncMethodGenerationAttributeSetting;

Is this code path reachable? This is like a PE symbol and I think for PE we have different implementation #Closed

get { return _parameters; }
}

public override bool IsAsync => _underlyingMethod.IsAsync;
Copy link
Contributor

@AlekseyTs AlekseyTs Mar 13, 2026

Choose a reason for hiding this comment

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

_underlyingMethod.IsAsync

Is this ever true? #Closed

public override bool IsAsync => this.UnderlyingMethod.IsAsync;
public override ImmutableArray<CustomModifier> RefCustomModifiers => this.UnderlyingMethod.RefCustomModifiers;
public override TypeWithAnnotations ReturnTypeWithAnnotations => this.UnderlyingMethod.ReturnTypeWithAnnotations;
internal sealed override ThreeState RuntimeAsyncMethodGenerationAttributeSetting => this.UnderlyingMethod.RuntimeAsyncMethodGenerationAttributeSetting;
Copy link
Contributor

@AlekseyTs AlekseyTs Mar 13, 2026

Choose a reason for hiding this comment

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

this.UnderlyingMethod.RuntimeAsyncMethodGenerationAttributeSetting;

Is this code path reachable? #Closed

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 5)

@333fred
Copy link
Member Author

333fred commented Mar 13, 2026

@AlekseyTs please take another look.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 6), assuming CI is passing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move SourceMethodSymbol.IsRuntimeAsyncEnabledInMethod to MethodSymbol

3 participants