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

Account for partial properties at existing use sites of partial method symbol APIs #73772

Open
RikkiGibson opened this issue May 29, 2024 · 5 comments

Comments

@RikkiGibson
Copy link
Contributor

RikkiGibson commented May 29, 2024

Test plan: #73090

Issue referenced in source

IDE

var symbol = model.GetSymbolInfo(invocation.Expression, cancellationToken).Symbol;
if (symbol is not IMethodSymbol method || method.PartialImplementationPart is not null)
{
// https://github.com/dotnet/roslyn/issues/73772: should we also bail out on a partial property?
// We don't handle partial methods yet
return null;
}

// https://github.com/dotnet/roslyn/issues/73772: should we also get partial property symbols here?
var symbols = semanticModel.LookupSymbols(position, container: enclosingSymbol)
.OfType<IMethodSymbol>()
.Where(m => IsPartial(m) && m.PartialImplementationPart == null);

// If this is a parameter symbol for a partial method definition, be sure we visited
// the implementation part's body.
// https://github.com/dotnet/roslyn/issues/73772: also do this for properties
if (renamedSymbol is IParameterSymbol renamedParameterSymbol &&
renamedSymbol.ContainingSymbol is IMethodSymbol methodSymbol &&
methodSymbol.PartialImplementationPart != null)
{

// https://github.com/dotnet/roslyn/issues/73772: add other partial property part as conflicting symbol
if (isMethod && conflictingSymbol is IMethodSymbol conflictingMethod && renamedMember is IMethodSymbol renamedMethod)
{
if (!(conflictingMethod.PartialDefinitionPart != null && Equals(conflictingMethod.PartialDefinitionPart, renamedMethod)) &&
!(conflictingMethod.PartialImplementationPart != null && Equals(conflictingMethod.PartialImplementationPart, renamedMethod)))
{
builder.AddRange(conflictingSymbol.Locations);
}
}

// https://github.com/dotnet/roslyn/issues/73772: define/use a similar helper for PropertySymbolReferenceFinder+PropertyAccessorSymbolReferenceFinder?
if (symbol.PartialDefinitionPart != null)
return [symbol.PartialDefinitionPart];
if (symbol.PartialImplementationPart != null)
return [symbol.PartialImplementationPart];

// https://github.com/dotnet/roslyn/issues/73772: also cascade partial indexer parameters
if (parameter.ContainingSymbol is IMethodSymbol method)
{
var ordinal = parameter.Ordinal;
if (ordinal < method.PartialDefinitionPart?.Parameters.Length)
results.Add(method.PartialDefinitionPart.Parameters[ordinal]);
if (ordinal < method.PartialImplementationPart?.Parameters.Length)
results.Add(method.PartialImplementationPart.Parameters[ordinal]);
}

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label May 29, 2024
@dotnet dotnet deleted a comment from dotnet-issue-labeler bot May 29, 2024
@RikkiGibson
Copy link
Contributor Author

I just reviewed this list, I think all the comments listed in the issue are still present in source.

@Cosifne
Copy link
Member

Cosifne commented May 30, 2024

I am working on the IDE part. Most of them need some changes.

@RikkiGibson
Copy link
Contributor Author

Removed entries which were resolved by #73792

@jaredpar jaredpar added this to the 17.11 milestone Jun 5, 2024
@jaredpar jaredpar modified the milestones: 17.11, 17.12 Jul 9, 2024
@tmat
Copy link
Member

tmat commented Jul 22, 2024

Working on EnC support.

@RikkiGibson RikkiGibson removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jul 26, 2024
@RikkiGibson
Copy link
Contributor Author

I tried to work through the remaining IDE layer bits in #74950, but I was struggling to understand what to do in some cases. @Cosifne do you think you could pick those up, or maybe we could chat offline about how to work through them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants