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

Do not simplify type name to a type with the EditorBrowsable attribute on it. #75235

Merged
merged 6 commits into from
Sep 25, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #75162

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 25, 2024
switch (expression.Kind())
// Ensure that replacement doesn't change semantics.
var speculationAnalyzer = new SpeculationAnalyzer(expression, replacementNode, semanticModel, cancellationToken);
return !speculationAnalyzer.ReplacementChangesSemantics();
Copy link
Member Author

Choose a reason for hiding this comment

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

removed helper method and pulled this to common location.

}

enclosingSymbol = enclosingSymbol.ContainingSymbol;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this entire while loop did absolutely nothing.

@@ -40,7 +40,7 @@ public override bool TrySimplify(
replacementNode = null;
issueSpan = default;

if (expression is MemberAccessExpressionSyntax { Expression.RawKind: (int)SyntaxKind.ThisExpression } memberAccessExpression)
if (expression is MemberAccessExpressionSyntax(SyntaxKind.ThisExpression) memberAccessExpression)
Copy link
Member Author

Choose a reason for hiding this comment

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

simpler pattern form, without unnecessary casts.


if (TrySimplifyMemberAccessOrQualifiedName(memberAccess.Expression, memberAccess.Name, semanticModel, out var newLeft, out issueSpan))
switch (expression)
Copy link
Member Author

Choose a reason for hiding this comment

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

view with whitespace off.

// replacement node might not be in it's simplest form, so add simplify annotation to it.
replacementNode = memberAccess.Update(newLeft, memberAccess.OperatorToken, memberAccess.Name)
.WithAdditionalAnnotations(Simplifier.Annotation);

// Ensure that replacement doesn't change semantics.
return !ReplacementChangesSemantics(memberAccess, replacementNode, semanticModel);
Copy link
Member Author

Choose a reason for hiding this comment

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

the two calls to ReplacementChangesSemantics were pulled up and then inlined.

// Don't simplify to a base type if it has the EditorBrowsable attribute on it. This is
// occasionally done in some APIs to have a 'pseudo internal' base type that has functionality,
// which a user is supposed to only access through some 'pseudo public' derived type instead.
if (!containingType.IsEditorBrowsable(hideAdvancedMembers: true, semanticModel.Compilation, includingSourceSymbols: true))
Copy link
Member Author

Choose a reason for hiding this comment

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

new logic.

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review September 25, 2024 16:18
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner September 25, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE 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.

IDE0002 suggests simplifying generated classes to their base class
2 participants