-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Do not simplify type name to a type with the EditorBrowsable attribute on it. #75235
Conversation
switch (expression.Kind()) | ||
// Ensure that replacement doesn't change semantics. | ||
var speculationAnalyzer = new SpeculationAnalyzer(expression, replacementNode, semanticModel, cancellationToken); | ||
return !speculationAnalyzer.ReplacementChangesSemantics(); |
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new logic.
Fixes #75162