Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No easy way to determine if a method is partial. #6956

Closed
gafter opened this issue Nov 22, 2015 · 2 comments
Closed

No easy way to determine if a method is partial. #6956

gafter opened this issue Nov 22, 2015 · 2 comments
Labels
0 - Backlog Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request
Milestone

Comments

@gafter
Copy link
Member

gafter commented Nov 22, 2015

From my inbox...


How to query if a method is a partial definition or partial implementation?

partial class Example 
{
partial void Test();
}

I’ve tried PartialDefinitionPart and PartialImplementationPart, but it seems PartialDefinitionPart always return null, even for Test() above.

method.PartialDefinitionPart returns null if the method itself is the definition.
Likewise PartialImplementationPart returns null if the method itself is the implementation.

/// 
/// If this is a partial method implementation part, returns the corresponding
/// definition part. Otherwise null.
/// 
IMethodSymbol PartialDefinitionPart { get; }

/// 
/// If this is a partial method declaration without a body, and the method is
/// implemented with a body, returns that implementing definition. Otherwise
/// null.
/// 
IMethodSymbol PartialImplementationPart { get; }

There seems to be something missing. There doesn’t seem to be any way to know if a method is partial unless the other part happens to exist. i.e. if I have a partial definition, with no partial implementation,
How would I find out that I’m actually partial?

Well, it is a bit hacky, but you may be able to find this out by method.CallsAreOmitted(tree) && !method.CallsAreConditionallyOmitted(tree). However, it probably makes sense to expose IsPartialDefinition.

Or, perhaps the simplest change would be to have PartialDefinitionPart return itself for the definition part, and PartialImplementationPart return itself for the implementation part.

@gafter gafter added Concept-API This issue involves adding, removing, clarification, or modification of an API. Area-Compilers labels Nov 22, 2015
@jaredpar jaredpar added this to the 2.0 milestone Dec 2, 2015
@gafter gafter modified the milestones: 2.0 (Preview 1), 2.0 (RC) Jun 20, 2016
@jaredpar jaredpar modified the milestones: 2.0 (RC), 2.1, 2.0 (RTM) Jul 19, 2016
@gafter gafter self-assigned this Aug 8, 2016
@jaredpar jaredpar modified the milestones: 2.1, 2.0 (RC) Aug 23, 2016
@jaredpar jaredpar modified the milestones: 2.1, Unknown Feb 8, 2017
@jaredpar jaredpar modified the milestones: Unknown, 2.1 Feb 8, 2017
@gafter gafter removed their assignment Jul 2, 2020
@aetos382
Copy link

Is this issue resolved by #51255 ?

@CyrusNajmabadi
Copy link
Member

Yes. t his can be closed out. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - Backlog Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request
Projects
None yet
Development

No branches or pull requests

4 participants