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

Partial events and constructors: IDE #77337

Open
wants to merge 6 commits into
base: features/PartialEventsCtors
Choose a base branch
from

Conversation

jjonescz
Copy link
Member

Test plan: #76859

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 25, 2025
@jjonescz jjonescz marked this pull request as ready for review February 25, 2025 13:13
@jjonescz jjonescz requested a review from a team as a code owner February 25, 2025 13:13
@jjonescz
Copy link
Member Author

@cston @RikkiGibson FYI

@jjonescz
Copy link
Member Author

@dotnet/roslyn-ide for a review, thanks

symbol = (symbol as IPropertySymbol)?.PartialImplementationPart ?? symbol;
symbol = symbol switch
{
IMethodSymbol method => method.PartialImplementationPart ?? method,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it feels like the pattern itself could also just test that the PartialImplementationPart is non-null, and the _ => symbol case can be used instead of ?? method, etc. in these arms.

return CreateResolution(result, $"({nameof(EventSymbolKey)} '{metadataName}' not found)", out failureReason);
using var events = GetMembersOfNamedType<IEventSymbol>(containingTypeResolution, metadataName);

if (events.Count == 1 && isPartialImplementationPart)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is making use of an assumption that events are not overloaded. Is this really what we want to do when, say, erroneous duplicated partial events are present in source?

@@ -238,6 +238,12 @@ private static bool IsPartialMethodDefinitionPart(IPropertySymbol symbol)
private static bool IsPartialMethodImplementationPart(IPropertySymbol symbol)
=> symbol.PartialDefinitionPart != null;

private static bool IsPartialMethodDefinitionPart(IEventSymbol symbol)
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be good to name these according to the symbol kinds they actually deal with, i.e. IsPartialEventDefinitionPart. Not critical, though.

Assert.NotSame(implementation, definition);

// Assert that both the definition and implementation resolve back to themselves
Assert.Equal(definition, ResolveSymbol(definition, comp, SymbolKeyComparison.None));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Assert.Same?

@CyrusNajmabadi
Copy link
Member

i can look at these tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature - Partial Events and Constructors untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants