Skip to content

Virtual static interface methods analyzis API #77260

Closed Answered by CyrusNajmabadi
syrompetka asked this question in Q&A
Discussion options

You must be logged in to vote

How can I identify which implementation of virtual static method will be invoked from Main?

From inside Main you can use the semantic model to ask about DoWrapper<StaticVirtualImplementation>(); It will tell you that you are invoking the DoWrapper<T> method where T is StaticVirtualImplementation. See .ConstructedFrom on the DoWrapper<StaticVirtualImplementation> method symbol you get to get bacck to the DoWrapper<T> method.

Now that you have this information, you can analyze DoWrapper<>. Inside of that you will see that .Do is a call to IStaticVirtual.Do through T. Knowing that T is the ITypeSymbol StaticVirtualImplementation you can use FindImplementationForInterfaceMember on it with t…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by CyrusNajmabadi
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Area-Analyzers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request
2 participants
Converted from issue

This discussion was converted from issue #77257 on February 18, 2025 06:55.