Roslyn: "nameof" expression in lambda expression causes capture

Created on 2 May 2020  路  3Comments  路  Source: dotnet/roslyn

image
image

Area-IDE Bug IDE-IntelliSense help wanted

Most helpful comment

This is only a bug in the Quick Info. When you look at the generated code, you'll see that it doesn't actually cause a capture.

This makes it a compiler bug and should be on Roslyn instead.

All 3 comments

This is only a bug in the Quick Info. When you look at the generated code, you'll see that it doesn't actually cause a capture.

This makes it a compiler bug and should be on Roslyn instead.

I don't think DataFlowAnalysis.Captured API should report locals inside nameof? if so the fix would be straightforward.

I don't think DataFlowAnalysis.Captured API should report locals inside nameof? if so the fix would be straightforward.

AFIK, "captured" means implicit closure class and instance has been created.
Actually, it seems that nameof expression never causes capture , so it is inconsistent,it should not be reported.

Was this page helpful?
0 / 5 - 0 ratings