From f4bcd57feb663976710acc0b3ae198ac23f755dd Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 28 Apr 2021 21:36:11 +1000 Subject: [PATCH 1/9] EnC support for record structs --- .../EditAndContinue/TopLevelEditingTests.cs | 55 +++++++++++++++++++ .../EditAndContinue/SyntaxComparer.cs | 4 +- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs index c99c831ff6c7a..9f505b8763749 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs @@ -1693,6 +1693,17 @@ public void Record_Name_Update() Diagnostic(RudeEditKind.Renamed, "record D", CSharpFeaturesResources.record_)); } + [Fact] + public void RecordStruct_NoModifiers_Insert() + { + var src1 = ""; + var src2 = "record struct C { }"; + + var edits = GetTopEdits(src1, src2); + + edits.VerifyRudeDiagnostics(); + } + [Fact] public void Record_NoModifiers_Insert() { @@ -1838,6 +1849,27 @@ protected virtual bool PrintMembers(System.Text.StringBuilder builder) edits.VerifyRudeDiagnostics(); } + [Fact] + public void RecordStruct_ImplementSynthesized_PrintMembers() + { + var src1 = "record struct C { }"; + var src2 = @" +record struct C +{ + protected virtual bool PrintMembers(System.Text.StringBuilder builder) + { + return true; + } +}"; + + var edits = GetTopEdits(src1, src2); + + edits.VerifySemantics( + SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.PrintMembers"))); + + edits.VerifyRudeDiagnostics(); + } + [Fact] public void Record_ImplementSynthesized_WrongParameterName() { @@ -1947,6 +1979,29 @@ record C(int X) edits.VerifyRudeDiagnostics(); } + [Fact] + public void RecordStruct_AddProperty_NotPrimary() + { + var src1 = "record struct C(int X);"; + var src2 = @" +record struct C(int X) +{ + public int Y { get; set; } +}"; + + var edits = GetTopEdits(src1, src2); + + edits.VerifySemantics( + SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.PrintMembers")), + SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C").GetMembers("Equals").OfType().First(m => SymbolEqualityComparer.Default.Equals(m.Parameters[0].Type, m.ContainingType))), + SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.GetHashCode")), + SemanticEdit(SemanticEditKind.Insert, c => c.GetMember("C.Y")), + SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C").Constructors.Single(c => c.Parameters[0].Type.ToDisplayString() == "int"), preserveLocalVariables: true), + SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C").Constructors.Single(c => c.Parameters[0].Type.ToDisplayString() == "C"))); + + edits.VerifyRudeDiagnostics(); + } + [Fact] public void Record_AddProperty_NotPrimary_WithConstructor() { diff --git a/src/Features/CSharp/Portable/EditAndContinue/SyntaxComparer.cs b/src/Features/CSharp/Portable/EditAndContinue/SyntaxComparer.cs index de9ae560a58f4..11a4bfd82d71f 100644 --- a/src/Features/CSharp/Portable/EditAndContinue/SyntaxComparer.cs +++ b/src/Features/CSharp/Portable/EditAndContinue/SyntaxComparer.cs @@ -563,11 +563,11 @@ private static Label ClassifyTopSyntax(SyntaxKind kind, out bool isLeaf) case SyntaxKind.NamespaceDeclaration: return Label.NamespaceDeclaration; - // Need to add support for record structs (tracked by https://github.com/dotnet/roslyn/issues/44877) case SyntaxKind.ClassDeclaration: case SyntaxKind.StructDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: + case SyntaxKind.RecordStructDeclaration: return Label.TypeDeclaration; case SyntaxKind.MethodDeclaration: @@ -1343,11 +1343,11 @@ private static double CombineOptional( case SyntaxKind.NamespaceDeclaration: return ((NamespaceDeclarationSyntax)node).Name; - // Need to add support for record structs (tracked by https://github.com/dotnet/roslyn/issues/44877) case SyntaxKind.ClassDeclaration: case SyntaxKind.StructDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: + case SyntaxKind.RecordStructDeclaration: return ((TypeDeclarationSyntax)node).Identifier; case SyntaxKind.EnumDeclaration: From 072a0afb3664062b1c21f1cdc8c3470acf144ccf Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 28 Apr 2021 21:37:46 +1000 Subject: [PATCH 2/9] Update src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs --- .../CSharpTest/EditAndContinue/TopLevelEditingTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs index 9f505b8763749..004de1866ca35 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs @@ -1693,7 +1693,7 @@ public void Record_Name_Update() Diagnostic(RudeEditKind.Renamed, "record D", CSharpFeaturesResources.record_)); } - [Fact] + [Fact] public void RecordStruct_NoModifiers_Insert() { var src1 = ""; From 84f4207e745262a4dd29145a1a5f4f0b71c541db Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 29 Apr 2021 07:32:07 +1000 Subject: [PATCH 3/9] Add resource --- src/Features/CSharp/Portable/CSharpFeaturesResources.resx | 3 +++ .../CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf | 5 +++++ 14 files changed, 68 insertions(+) diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx index 019ca0f85ca72..f5e9fc923787f 100644 --- a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx +++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx @@ -621,4 +621,7 @@ record + + record struct + \ No newline at end of file diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf index c2a819d8bc8f8..7197ca5bffe23 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement příkaz switch diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf index 4b95649bede12..5ab0d9218f1dc 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement switch-Anweisung diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf index f775b17afcf35..1991839837c48 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement instrucción switch diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf index 4c5916b74e553..515b6b424fc02 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement instruction switch diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf index 94688d112ab3a..23f2f2e9749b3 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement istruzione switch diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf index 70ac45620b7f1..1a5b465bd9da1 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement switch ステートメント diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf index f8f5c44cd8f87..f25e9d58b329a 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement switch 문 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf index f98de496503d0..20650c85db12d 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement instrukcja switch diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf index 8a1031efa4b6a..c66603e40ed98 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement instrução switch diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf index c6846379a30d8..eab4cbb292085 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement оператор switch diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf index a8901cab24888..9cb5415adc9cd 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement switch deyimi diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf index d0dcc2b43c5da..63a33d644620e 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement switch 语句 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf index 43be8381fa6dd..7e0889c89afcd 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf @@ -417,6 +417,11 @@ record + + record struct + record struct + + switch statement switch 陳述式 From 27c081824011d23032f8912b58258dbdd1901375 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 29 Apr 2021 07:32:17 +1000 Subject: [PATCH 4/9] Classify record structs --- .../EditAndContinue/CSharpEditAndContinueAnalyzer.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs b/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs index b6d6970728c20..d56d39aacb58b 100644 --- a/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs +++ b/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs @@ -1100,7 +1100,7 @@ internal override bool IsInterfaceDeclaration(SyntaxNode node) => node.IsKind(SyntaxKind.InterfaceDeclaration); internal override bool IsRecordDeclaration(SyntaxNode node) - => node.IsKind(SyntaxKind.RecordDeclaration); + => node.IsKind(SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration); internal override SyntaxNode? TryGetContainingTypeDeclaration(SyntaxNode node) => node.Parent!.FirstAncestorOrSelf(); @@ -1426,6 +1426,7 @@ private static bool GroupBySignatureComparer(ImmutableArray ol case SyntaxKind.StructDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: + case SyntaxKind.RecordStructDeclaration: var typeDeclaration = (TypeDeclarationSyntax)node; return GetDiagnosticSpan(typeDeclaration.Modifiers, typeDeclaration.Keyword, typeDeclaration.TypeParameterList ?? (SyntaxNodeOrToken)typeDeclaration.Identifier); @@ -1777,6 +1778,9 @@ internal override TextSpan GetLambdaParameterDiagnosticSpan(SyntaxNode lambda, i case SyntaxKind.RecordDeclaration: return CSharpFeaturesResources.record_; + case SyntaxKind.RecordStructDeclaration: + return CSharpFeaturesResources.recordstruct; + case SyntaxKind.EnumDeclaration: return FeaturesResources.enum_; @@ -2136,6 +2140,7 @@ private void ClassifyReorder(SyntaxNode newNode) case SyntaxKind.StructDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: + case SyntaxKind.RecordStructDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.DelegateDeclaration: case SyntaxKind.VariableDeclaration: @@ -2209,6 +2214,7 @@ private void ClassifyInsert(SyntaxNode node) case SyntaxKind.ClassDeclaration: case SyntaxKind.StructDeclaration: case SyntaxKind.RecordDeclaration: + case SyntaxKind.RecordStructDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.DelegateDeclaration: @@ -2299,6 +2305,7 @@ private void ClassifyDelete(SyntaxNode oldNode) case SyntaxKind.StructDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: + case SyntaxKind.RecordStructDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.PropertyDeclaration: case SyntaxKind.IndexerDeclaration: @@ -2387,6 +2394,7 @@ private void ClassifyUpdate(SyntaxNode oldNode, SyntaxNode newNode) case SyntaxKind.StructDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: + case SyntaxKind.RecordStructDeclaration: ClassifyUpdate((TypeDeclarationSyntax)oldNode, (TypeDeclarationSyntax)newNode); return; @@ -3188,6 +3196,7 @@ protected override List GetExceptionHandlingAncestors(SyntaxNode nod case SyntaxKind.ClassDeclaration: case SyntaxKind.StructDeclaration: case SyntaxKind.RecordDeclaration: + case SyntaxKind.RecordStructDeclaration: return result; } From 2d308d3a86c1fe65cd68ca6dc1858b2fd10389cc Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 29 Apr 2021 07:32:24 +1000 Subject: [PATCH 5/9] Update tests --- .../EditAndContinue/CSharpEditAndContinueAnalyzerTests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/CSharpEditAndContinueAnalyzerTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/CSharpEditAndContinueAnalyzerTests.cs index c9170321bc2cf..4bcaf73ea5dd3 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/CSharpEditAndContinueAnalyzerTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/CSharpEditAndContinueAnalyzerTests.cs @@ -126,6 +126,9 @@ public void ErrorSpans_TopLevel() [A, B] /**/public abstract partial record R/**/ { } +[A, B] +/**/public abstract partial record struct R/**/ { } + /**/interface I/**/ : J, K, L { } [A] From 5eeeb8b4c60f5883a78754b24aa3b99b2d15ac4c Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 29 Apr 2021 10:59:50 +1000 Subject: [PATCH 6/9] Fix visibility --- .../EditAndContinue/TopLevelEditingTests.cs | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs index 004de1866ca35..eb9ec6147413b 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs @@ -1835,7 +1835,7 @@ public void Record_ImplementSynthesized_PrintMembers() var src2 = @" record C { - protected virtual bool PrintMembers(System.Text.StringBuilder builder) + protected bool PrintMembers(System.Text.StringBuilder builder) { return true; } @@ -1856,7 +1856,7 @@ public void RecordStruct_ImplementSynthesized_PrintMembers() var src2 = @" record struct C { - protected virtual bool PrintMembers(System.Text.StringBuilder builder) + private bool PrintMembers(System.Text.StringBuilder builder) { return true; } @@ -1979,29 +1979,6 @@ record C(int X) edits.VerifyRudeDiagnostics(); } - [Fact] - public void RecordStruct_AddProperty_NotPrimary() - { - var src1 = "record struct C(int X);"; - var src2 = @" -record struct C(int X) -{ - public int Y { get; set; } -}"; - - var edits = GetTopEdits(src1, src2); - - edits.VerifySemantics( - SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.PrintMembers")), - SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C").GetMembers("Equals").OfType().First(m => SymbolEqualityComparer.Default.Equals(m.Parameters[0].Type, m.ContainingType))), - SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.GetHashCode")), - SemanticEdit(SemanticEditKind.Insert, c => c.GetMember("C.Y")), - SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C").Constructors.Single(c => c.Parameters[0].Type.ToDisplayString() == "int"), preserveLocalVariables: true), - SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C").Constructors.Single(c => c.Parameters[0].Type.ToDisplayString() == "C"))); - - edits.VerifyRudeDiagnostics(); - } - [Fact] public void Record_AddProperty_NotPrimary_WithConstructor() { From 08b4616e4e18b9ffa23e5d09d8c5135e33e901db Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 3 May 2021 15:26:13 +1000 Subject: [PATCH 7/9] Rename --- src/Features/CSharp/Portable/CSharpFeaturesResources.resx | 2 +- .../Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf | 2 +- .../CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf | 2 +- src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf | 2 +- .../CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf | 2 +- .../CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx index f5e9fc923787f..209f102173c6c 100644 --- a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx +++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx @@ -621,7 +621,7 @@ record - + record struct \ No newline at end of file diff --git a/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs b/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs index d56d39aacb58b..d03a348856a18 100644 --- a/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs +++ b/src/Features/CSharp/Portable/EditAndContinue/CSharpEditAndContinueAnalyzer.cs @@ -1779,7 +1779,7 @@ internal override TextSpan GetLambdaParameterDiagnosticSpan(SyntaxNode lambda, i return CSharpFeaturesResources.record_; case SyntaxKind.RecordStructDeclaration: - return CSharpFeaturesResources.recordstruct; + return CSharpFeaturesResources.record_struct; case SyntaxKind.EnumDeclaration: return FeaturesResources.enum_; diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf index 7197ca5bffe23..cb3924c998502 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf index 5ab0d9218f1dc..362e6013d5ec6 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf index 1991839837c48..8ba4b0bbcd0fe 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf index 515b6b424fc02..7b0fd88ccbc97 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf index 23f2f2e9749b3..db03039583bab 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf index 1a5b465bd9da1..2055d9cd7312b 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf index f25e9d58b329a..c01f7065707ef 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf index 20650c85db12d..ce0387fd1d2b9 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf index c66603e40ed98..e315e6cfbe6c7 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf index eab4cbb292085..1266be34a1002 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf index 9cb5415adc9cd..8ed1229424eb5 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf index 63a33d644620e..feda06d416e22 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf @@ -417,7 +417,7 @@ record - + record struct record struct diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf index 7e0889c89afcd..8107ba89eefa3 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf @@ -417,7 +417,7 @@ record - + record struct record struct From e44477e0bb7c937ac285225d774cd1991718b0be Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 10 May 2021 12:18:02 +1000 Subject: [PATCH 8/9] Add tests for fields and properties --- .../EditAndContinue/TopLevelEditingTests.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs index eb9ec6147413b..fe06586671e65 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs @@ -1704,6 +1704,44 @@ public void RecordStruct_NoModifiers_Insert() edits.VerifyRudeDiagnostics(); } + [Fact] + public void RecordStruct_AddField() + { + var src1 = @" +record struct C(int X) +{ +}"; + var src2 = @" +record struct C(int X) +{ + private int _y = 0; +}"; + + var edits = GetTopEdits(src1, src2); + + edits.VerifySemanticDiagnostics( + Diagnostic(RudeEditKind.InsertIntoStruct, "_y = 0", FeaturesResources.field, CSharpFeaturesResources.record_struct)); + } + + [Fact] + public void RecordStruct_AddProperty() + { + var src1 = @" +record struct C(int X) +{ +}"; + var src2 = @" +record struct C(int X) +{ + public int Y { get; set; } = 0; +}"; + + var edits = GetTopEdits(src1, src2); + + edits.VerifySemanticDiagnostics( + Diagnostic(RudeEditKind.InsertIntoStruct, "public int Y { get; set; } = 0;", FeaturesResources.auto_property, CSharpFeaturesResources.record_struct)); + } + [Fact] public void Record_NoModifiers_Insert() { From 721e587ff2431c7e830db8d88b775ea968b35795 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 14 May 2021 08:50:07 +1000 Subject: [PATCH 9/9] Add test --- .../EditAndContinue/TopLevelEditingTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs index fe06586671e65..82a95f98de1d3 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs @@ -587,6 +587,21 @@ public void TypeKindUpdate2() Diagnostic(RudeEditKind.TypeKindUpdate, "record C", CSharpFeaturesResources.record_)); } + [Fact] + public void TypeKindUpdate3() + { + var src1 = "record C { }"; + var src2 = "record struct C { }"; + + var edits = GetTopEdits(src1, src2); + + edits.VerifyEdits( + "Update [record C { }]@0 -> [record struct C { }]@0"); + + edits.VerifyRudeDiagnostics( + Diagnostic(RudeEditKind.TypeKindUpdate, "record struct C", CSharpFeaturesResources.record_struct)); + } + [Fact] public void Class_Modifiers_Update() {