Skip to content

Commit ac261dd

Browse files
authored
Merge pull request #55765 from dotnet/merges/main-to-main-vs-deps
Merge main to main-vs-deps
2 parents 1cb7217 + 2f6768e commit ac261dd

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,8 +2625,6 @@ private readonly bool PrintMembers(System.Text.StringBuilder builder)
26252625
[Fact]
26262626
public void Record_ImplementSynthesized_WrongParameterName()
26272627
{
2628-
// TODO: Remove this requirement with https://github.com/dotnet/roslyn/issues/52563
2629-
26302628
var src1 = "record C { }";
26312629
var src2 = @"
26322630
record C
@@ -2652,6 +2650,17 @@ protected C(C other)
26522650
Diagnostic(RudeEditKind.ExplicitRecordMethodParameterNamesMustMatch, "protected virtual bool PrintMembers(System.Text.StringBuilder sb)", "PrintMembers(System.Text.StringBuilder builder)"),
26532651
Diagnostic(RudeEditKind.ExplicitRecordMethodParameterNamesMustMatch, "public virtual bool Equals(C rhs)", "Equals(C other)"),
26542652
Diagnostic(RudeEditKind.ExplicitRecordMethodParameterNamesMustMatch, "protected C(C other)", "C(C original)"));
2653+
2654+
edits.VerifySemantics(
2655+
ActiveStatementsDescription.Empty,
2656+
new[]
2657+
{
2658+
SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.PrintMembers")),
2659+
SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").GetMembers("Equals").OfType<IMethodSymbol>().First(m => SymbolEqualityComparer.Default.Equals(m.Parameters[0].Type, m.ContainingType))),
2660+
SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").Constructors.Single(c => c.Parameters.FirstOrDefault()?.Type.ToDisplayString() == "C"), preserveLocalVariables: true),
2661+
SemanticEdit(SemanticEditKind.Update, c => c.GetMember<INamedTypeSymbol>("C").Constructors.Single(c => c.Parameters.Length == 0), preserveLocalVariables: true),
2662+
},
2663+
EditAndContinueTestHelpers.Net6RuntimeCapabilities);
26552664
}
26562665

26572666
[Fact]

src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ private static IEnumerable<SyntaxNode> GetChildNodes(SyntaxNode root, SyntaxNode
655655
}
656656
}
657657

658-
internal override void ReportDeclarationInsertDeleteRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode oldNode, SyntaxNode newNode, ISymbol oldSymbol, ISymbol newSymbol, CancellationToken cancellationToken)
658+
internal override void ReportDeclarationInsertDeleteRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode oldNode, SyntaxNode newNode, ISymbol oldSymbol, ISymbol newSymbol, EditAndContinueCapabilities capabilities, CancellationToken cancellationToken)
659659
{
660660
// Global statements have a declaring syntax reference to the compilation unit itself, which we can just ignore
661661
// for the purposes of declaration rude edits
@@ -675,7 +675,7 @@ internal override void ReportDeclarationInsertDeleteRudeEdits(ArrayBuilder<RudeE
675675
// declaration kind has changed. If it hasn't changed, then our standard code will handle it.
676676
if (oldNode.RawKind == newNode.RawKind)
677677
{
678-
base.ReportDeclarationInsertDeleteRudeEdits(diagnostics, oldNode, newNode, oldSymbol, newSymbol, cancellationToken);
678+
base.ReportDeclarationInsertDeleteRudeEdits(diagnostics, oldNode, newNode, oldSymbol, newSymbol, capabilities, cancellationToken);
679679
return;
680680
}
681681

@@ -709,11 +709,12 @@ internal override void ReportDeclarationInsertDeleteRudeEdits(ArrayBuilder<RudeE
709709
}
710710
else if (oldNode is RecordDeclarationSyntax &&
711711
newNode is MethodDeclarationSyntax &&
712+
!capabilities.HasFlag(EditAndContinueCapabilities.UpdateParameters) &&
712713
!oldSymbol.GetParameters().Select(p => p.Name).SequenceEqual(newSymbol.GetParameters().Select(p => p.Name)))
713714
{
714-
// TODO: Remove this requirement with https://github.com/dotnet/roslyn/issues/52563
715715
// Explicitly implemented methods must have parameter names that match the compiler generated versions
716-
// exactly otherwise symbol matching won't work for them.
716+
// exactly if the runtime doesn't support updating parameters, otherwise the debugger would show incorrect
717+
// parameter names.
717718
// We don't need to worry about parameter types, because if they were different then we wouldn't get here
718719
// as this wouldn't be the explicit implementation of a known method.
719720
// We don't need to worry about access modifiers because the symbol matching still works, and most of the

src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ private void ReportTopLevelSyntacticRudeEdits(ArrayBuilder<RudeEditDiagnostic> d
700700
/// <see cref="EditKind.Move"/> or <see cref="EditKind.Reorder"/>.
701701
/// The scenarios include moving a type declaration from one file to another and moving a member of a partial type from one partial declaration to another.
702702
/// </summary>
703-
internal virtual void ReportDeclarationInsertDeleteRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode oldNode, SyntaxNode newNode, ISymbol oldSymbol, ISymbol newSymbol, CancellationToken cancellationToken)
703+
internal virtual void ReportDeclarationInsertDeleteRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode oldNode, SyntaxNode newNode, ISymbol oldSymbol, ISymbol newSymbol, EditAndContinueCapabilities capabilities, CancellationToken cancellationToken)
704704
{
705705
// When a method is moved to a different declaration and its parameters are changed at the same time
706706
// the new method symbol key will not resolve to the old one since the parameters are different.
@@ -2787,7 +2787,7 @@ private async Task<ImmutableArray<SemanticEditInfo>> AnalyzeSemanticsAsync(
27872787
if (oldSymbol.DeclaringSyntaxReferences.Length == 1)
27882788
{
27892789
Contract.ThrowIfNull(oldDeclaration);
2790-
ReportDeclarationInsertDeleteRudeEdits(diagnostics, oldDeclaration, newDeclaration, oldSymbol, newSymbol, cancellationToken);
2790+
ReportDeclarationInsertDeleteRudeEdits(diagnostics, oldDeclaration, newDeclaration, oldSymbol, newSymbol, capabilities, cancellationToken);
27912791

27922792
if (IsPropertyAccessorDeclarationMatchingPrimaryConstructorParameter(newDeclaration, newContainingType, out var isFirst))
27932793
{
@@ -2822,7 +2822,7 @@ private async Task<ImmutableArray<SemanticEditInfo>> AnalyzeSemanticsAsync(
28222822

28232823
// Compare the old declaration syntax of the symbol with its new declaration and report rude edits
28242824
// if it changed in any way that's not allowed.
2825-
ReportDeclarationInsertDeleteRudeEdits(diagnostics, oldDeclaration, newDeclaration, oldSymbol, newSymbol, cancellationToken);
2825+
ReportDeclarationInsertDeleteRudeEdits(diagnostics, oldDeclaration, newDeclaration, oldSymbol, newSymbol, capabilities, cancellationToken);
28262826

28272827
var oldBody = TryGetDeclarationBody(oldDeclaration);
28282828
if (oldBody != null)
@@ -4395,9 +4395,10 @@ private void AddConstructorEdits(
43954395
ReportMemberBodyUpdateRudeEdits(diagnostics, newDeclaration, firstSpan);
43964396
}
43974397

4398-
// When explicitly implementing the copy constructor of a record the parameter name must match for symbol matching to work
4399-
// TODO: Remove this requirement with https://github.com/dotnet/roslyn/issues/52563
4400-
if (oldCtor != null &&
4398+
// When explicitly implementing the copy constructor of a record the parameter name if the runtime doesn't support
4399+
// updating parameters, otherwise the debugger would show the incorrect name in the autos/locals/watch window
4400+
if (!capabilities.HasFlag(EditAndContinueCapabilities.UpdateParameters) &&
4401+
oldCtor != null &&
44014402
!isPrimaryRecordConstructor &&
44024403
oldCtor.DeclaringSyntaxReferences.Length == 0 &&
44034404
newCtor.Parameters.Length == 1 &&

0 commit comments

Comments
 (0)