Skip to content

Match DynamicDependency members by name#1262

Merged
sbomer merged 1 commit into
dotnet:masterfrom
sbomer:dynamicDependencyName
Jun 10, 2020
Merged

Match DynamicDependency members by name#1262
sbomer merged 1 commit into
dotnet:masterfrom
sbomer:dynamicDependencyName

Conversation

@sbomer
Copy link
Copy Markdown
Member

@sbomer sbomer commented Jun 10, 2020

The signature parser allows a name to match different member types (method/field, etc.) with the same string, and it also allows specifying a parameterless method by name alone. This change also allows it to match methods/properties with any number of parameters by name alone.

I thought this was already the case, but didn't notice that the parser still checks parameters when it doesn't see parentheses, and didn't hit it when testing.

I noticed this while turning it on for dotnet/runtime. There we use it to pull in GetSourceLineInfo by name: https://github.com/dotnet/runtime/blob/144e5145453ac3885ac20bc1f1f2641523c6fcea/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs#L91.

GetSourceLineInfo has a lot of parameters, so we probably wouldn't want to put the full signature in the attribute: https://github.com/dotnet/runtime/blob/144e5145453ac3885ac20bc1f1f2641523c6fcea/src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/StackTraceSymbols.cs#L53.

@sbomer sbomer requested a review from marek-safar as a code owner June 10, 2020 01:46
@sbomer sbomer requested a review from vitek-karas June 10, 2020 01:47
IEnumerable<IMemberDefinition> members;
if (dynamicDependency.MemberSignature is string memberSignature) {
members = DocumentationSignatureParser.GetMembersByDocumentationSignature (type, memberSignature);
members = DocumentationSignatureParser.GetMembersByDocumentationSignature (type, memberSignature, acceptName: true);
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.

So this is a light version of wildcard support, right? It will mark any members if ( is not part of the signature.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yup. I will note this in the docs.

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.

Great!

Copy link
Copy Markdown
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

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

Maybe we should add a short doc about the signatures (and mention the two attributes where we use it). If nothing else to have a link to the Roslyn docs about it and also to note whichever differences we know about and some of the notable capabilities.

@sbomer
Copy link
Copy Markdown
Member Author

sbomer commented Jun 10, 2020

I'm working on a doc - I will open a follow-up for it so that I can get this in now.

@sbomer sbomer merged commit 012faca into dotnet:master Jun 10, 2020
tkapin pushed a commit to tkapin/runtime that referenced this pull request Jan 31, 2023
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.

3 participants