Add 'add extension completion' support for modern extensions.#81239
Add 'add extension completion' support for modern extensions.#81239CyrusNajmabadi merged 44 commits intodotnet:mainfrom
Conversation
| // This is the implementation at Editor layer to provide a CancellationToken | ||
| // for the workqueue used for background cache refresh. | ||
| [ExportWorkspaceServiceFactory(typeof(IImportCompletionCacheService<ExtensionMethodImportCompletionCacheEntry, object>), ServiceLayer.Editor), Shared] | ||
| [ExportWorkspaceServiceFactory(typeof(IImportCompletionCacheService<ExtensionMemberImportCompletionCacheEntry, object>), ServiceLayer.Editor), Shared] |
There was a problem hiding this comment.
a lot of the PR is just renaming 'method' to 'member' (and loosening IMethodSymbol to ISymbol). I will call out the interesting changes beyond that.
There was a problem hiding this comment.
i also recommend viewing with whitespace off.
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Metadata.cs
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| // has to be `public static "<Extension>$"(parameter)` (with exactly one parameter). note: | ||
| // method.GetParameters() doesn't seem to work here for static methods (perhaps because the name |
There was a problem hiding this comment.
it def fails for me. Feel free to debug. Do you use MetadataReader? or some other system?
There was a problem hiding this comment.
Looking at PEMethodSymbol we don't use MethodDefinition.GetParameters() we use DecodeMethodSignature as you do below.
That said, when I add var x = method.GetParameters(); here, none of the tests fail.
When I step through one test (TestPredefinedType_ModernExtensionProperty_GenericType) and inspect x it looks correct for the marker method.
Can you share some details of how things fail for you?
There was a problem hiding this comment.
Thanks. I can repro. GetParameters() returns a collection of 0 items.
Copilot gave some a plausible explanation:
In ECMA-335 metadata the Param table entries (what method.GetParameters() enumerates) are optional. A parameter only gets a row if it needs metadata: a name, attributes, marshaling info, default value, custom modifiers, etc. Synthetic methods (like your $ marker) can have parameters in the signature blob but no Param rows. The signature decoder (SignatureDecoder.DecodeMethodSignature) reads the raw signature (method.Signature) and will still show the parameter type, so
signature.ParameterTypes.Length == 1is correct whilemethod.GetParameters().Count == 0.
I checked out sections "II.22.33 Param" and "II.15.4 Defining methods" but I couldn't spot where this falls out of... It does make sense that there would be no Param row if there's no information to store.
There was a problem hiding this comment.
I think it's because you have no name. So there's no interesting parameter info to read out from the param table.
| { | ||
| receiverTypeSymbol = container; | ||
| return true; | ||
| return (container, isStatic: false); |
There was a problem hiding this comment.
Do we have a test showing the effect of isStatic: false here? #Closed
There was a problem hiding this comment.
i'm fine not caring about hitting all scenarios. we can drive narrower cases based on reports if people are hitting this.
| { | ||
| try | ||
| { | ||
| // Enable if, during debugging, you want to be able to easily debug into the PE reference processing |
There was a problem hiding this comment.
nit: FWIW, in the compiler, instead of ifdef we just avoid the parallelism when debugging.
See MethodCompiler checking ConcurrentBuild; our unittests set ConcurrentBuild to false when debugger is attached.
See CSharpTestBase.CreateCompilationCore (line 1836)
There was a problem hiding this comment.
i'll look into that.
jcouv
left a comment
There was a problem hiding this comment.
Done with review pass (commit 39)
| // } | ||
| // | ||
| // Note: to keep things simple, we don't check actual attributes. We just check enough to give us | ||
| // confidence that we found the right thing. (So same modifiers, has or does not have a special name, |
There was a problem hiding this comment.
has or does not have a special name,
Is this comment accurate? It looks like the if below makes a special name required.
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Metadata.cs
Outdated
Show resolved
Hide resolved
jcouv
left a comment
There was a problem hiding this comment.
LGTM Thanks (commit 44). I'm assuming the feedback on using well-known member name and conditioning parallelism on presence of debugger are for later
|
Yup. both of those are non-blocking. thnx. |
Fixes #80561
Relates to test plan #76130