From 4c5d4495be235c6deccc203f18a53dccf82ae119 Mon Sep 17 00:00:00 2001 From: Timur Kelman Date: Fri, 19 Jul 2024 18:13:59 +0200 Subject: [PATCH 1/8] add a test --- Tests/CSharp/MemberTests/MemberTests.cs | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/Tests/CSharp/MemberTests/MemberTests.cs b/Tests/CSharp/MemberTests/MemberTests.cs index af4fb542..a89c41bf 100644 --- a/Tests/CSharp/MemberTests/MemberTests.cs +++ b/Tests/CSharp/MemberTests/MemberTests.cs @@ -4019,6 +4019,58 @@ public static int StaticTestProperty return _StaticTestProperty_sPrevPosition + 1; } } +}"); + } + + [Fact] + public async Task IndexedPropertyWithTriviaAsync() + { + //issue 1095 + await TestConversionVisualBasicToCSharpAsync( + @"Class IndexedPropertyWithTrivia + 'a + Property P(i As Integer) As Integer + 'b + Get + '1 + Dim x = 1 '2 + '3 + End Get + + 'c + Set(value As Integer) + '4 + Dim x = 1 '5 + '6 + x = value + i '7 + '8 + End Set + 'd + End Property +End Class", @"using System; + +internal partial class IndexedPropertyWithTrivia +{ + // a + public int get_P(int i) + // b + { + // 1 + int x = 1; // 2 + return default; + // 3 + } + + // c + public void set_P(int i, int value) + { + // 4 + int x = 1; // 5 + // 6 + x = value + i; // 7 + // 8 + } + // d }"); } } \ No newline at end of file From 9e5e6c9d68e7cd54dfea173bd57ec331393733f9 Mon Sep 17 00:00:00 2001 From: Timur Kelman Date: Fri, 19 Jul 2024 18:17:10 +0200 Subject: [PATCH 2/8] place trivia in all accessors when converting parameterized properties --- CodeConverter/CSharp/DeclarationNodeVisitor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CodeConverter/CSharp/DeclarationNodeVisitor.cs b/CodeConverter/CSharp/DeclarationNodeVisitor.cs index 0030f880..0e1dcafc 100644 --- a/CodeConverter/CSharp/DeclarationNodeVisitor.cs +++ b/CodeConverter/CSharp/DeclarationNodeVisitor.cs @@ -674,7 +674,7 @@ public override async Task VisitPropertyStatement(VBSyntax.Pro throw new NotImplementedException("MyClass indexing not implemented"); } var methodDeclarationSyntaxs = await propertyBlock.Accessors.SelectAsync(async a => - await a.AcceptAsync(TriviaConvertingDeclarationVisitor, a == propertyBlock.Accessors.First() ? SourceTriviaMapKind.All : SourceTriviaMapKind.None)); + await a.AcceptAsync(TriviaConvertingDeclarationVisitor, SourceTriviaMapKind.All)); var accessorMethods = methodDeclarationSyntaxs.Select(WithMergedModifiers).ToArray(); if (hasExplicitInterfaceImplementation) { From f776453b75a7657502500939024899cde1433903 Mon Sep 17 00:00:00 2001 From: Timur Kelman Date: Thu, 25 Jul 2024 16:11:22 +0200 Subject: [PATCH 3/8] adjust the test --- Tests/CSharp/MemberTests/MemberTests.cs | 43 ++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/Tests/CSharp/MemberTests/MemberTests.cs b/Tests/CSharp/MemberTests/MemberTests.cs index 8ea031d4..c08c57bd 100644 --- a/Tests/CSharp/MemberTests/MemberTests.cs +++ b/Tests/CSharp/MemberTests/MemberTests.cs @@ -4075,30 +4075,29 @@ End Get End Set 'd End Property -End Class", @"using System; - +End Class", @" internal partial class IndexedPropertyWithTrivia { - // a - public int get_P(int i) - // b - { - // 1 - int x = 1; // 2 - return default; - // 3 - } - - // c - public void set_P(int i, int value) - { - // 4 - int x = 1; // 5 - // 6 - x = value + i; // 7 - // 8 - } - // d + // a + // b + public int get_P(int i) + { + // 1 + int x = 1; // 2 + return default; + // 3 + } + + // c + public void set_P(int i, int value) + { + // 4 + int x = 1; // 5 + // 6 + x = value + i; // 7 + // 8 + // d + } }"); } From 266e7e3f03c311a7ffa403120245e843aef845b2 Mon Sep 17 00:00:00 2001 From: Timur Kelman Date: Thu, 25 Jul 2024 16:12:01 +0200 Subject: [PATCH 4/8] implement special handling for indexed properties' trivia --- .../CSharp/DeclarationNodeVisitor.cs | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/CodeConverter/CSharp/DeclarationNodeVisitor.cs b/CodeConverter/CSharp/DeclarationNodeVisitor.cs index 65607cb0..bde95b4c 100644 --- a/CodeConverter/CSharp/DeclarationNodeVisitor.cs +++ b/CodeConverter/CSharp/DeclarationNodeVisitor.cs @@ -305,7 +305,10 @@ private MemberDeclarationSyntax[] GetAdditionalDeclarations(VBSyntax.StatementSy private async Task ConvertMemberAsync(VBSyntax.StatementSyntax member) { try { - return await member.AcceptAsync(TriviaConvertingDeclarationVisitor); + var sourceTriviaMapKind = member is VBSyntax.PropertyBlockSyntax propBlock && ShouldConvertAsParameterizedProperty(propBlock.PropertyStatement) + ? SourceTriviaMapKind.SubNodesOnly + : SourceTriviaMapKind.All; + return await member.AcceptAsync(TriviaConvertingDeclarationVisitor, sourceTriviaMapKind); } catch (Exception e) { return CreateErrorMember(member, e); } @@ -938,7 +941,30 @@ private static AccessorListSyntax ConvertSimpleAccessors(bool isWriteOnly, bool public override async Task VisitPropertyBlock(VBSyntax.PropertyBlockSyntax node) { - return await node.PropertyStatement.AcceptAsync(TriviaConvertingDeclarationVisitor, SourceTriviaMapKind.SubNodesOnly); + var converted = await node.PropertyStatement.AcceptAsync(TriviaConvertingDeclarationVisitor, SourceTriviaMapKind.SubNodesOnly); + + if (converted is MethodDeclarationSyntax) { + var first = (MethodDeclarationSyntax)converted; + + var firstCsConvertedToken = first.GetFirstToken(); + var firstVbSourceToken = node.GetFirstToken(); + first = first.ReplaceToken(firstCsConvertedToken, firstCsConvertedToken.WithSourceMappingFrom(firstVbSourceToken)); + + _additionalDeclarations.TryGetValue(node, out var members); + var last = members?.OfType().LastOrDefault() ?? first; + var lastIx = members.ToList().IndexOf(last); + var lastIsFirst = lastIx < 0; + var lastCsConvertedToken = last.GetLastToken(); + var lastVbSourceToken = node.GetLastToken(); + last = last.ReplaceToken(lastCsConvertedToken, lastCsConvertedToken.WithSourceMappingFrom(lastVbSourceToken)); + + converted = lastIsFirst ? last : first; + if (!lastIsFirst) { + members![lastIx] = last; + } + } + + return converted; } public override async Task VisitAccessorBlock(VBSyntax.AccessorBlockSyntax node) From a64e208899f6dbec7d40856ec88a313bb37c8929 Mon Sep 17 00:00:00 2001 From: Timur Kelman Date: Thu, 25 Jul 2024 16:47:50 +0200 Subject: [PATCH 5/8] move the new test to the PropertyMemberTests --- Tests/CSharp/MemberTests/MemberTests.cs | 51 ------------------- .../CSharp/MemberTests/PropertyMemberTests.cs | 51 +++++++++++++++++++ 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Tests/CSharp/MemberTests/MemberTests.cs b/Tests/CSharp/MemberTests/MemberTests.cs index c08c57bd..1aae7ee1 100644 --- a/Tests/CSharp/MemberTests/MemberTests.cs +++ b/Tests/CSharp/MemberTests/MemberTests.cs @@ -4050,57 +4050,6 @@ public static int StaticTestProperty }"); } - [Fact] - public async Task IndexedPropertyWithTriviaAsync() - { - //issue 1095 - await TestConversionVisualBasicToCSharpAsync( - @"Class IndexedPropertyWithTrivia - 'a - Property P(i As Integer) As Integer - 'b - Get - '1 - Dim x = 1 '2 - '3 - End Get - - 'c - Set(value As Integer) - '4 - Dim x = 1 '5 - '6 - x = value + i '7 - '8 - End Set - 'd - End Property -End Class", @" -internal partial class IndexedPropertyWithTrivia -{ - // a - // b - public int get_P(int i) - { - // 1 - int x = 1; // 2 - return default; - // 3 - } - - // c - public void set_P(int i, int value) - { - // 4 - int x = 1; // 5 - // 6 - x = value + i; // 7 - // 8 - // d - } -}"); - } - [Fact] public async Task TestOmittedArgumentsAsync() { diff --git a/Tests/CSharp/MemberTests/PropertyMemberTests.cs b/Tests/CSharp/MemberTests/PropertyMemberTests.cs index 32938a49..23c3204b 100644 --- a/Tests/CSharp/MemberTests/PropertyMemberTests.cs +++ b/Tests/CSharp/MemberTests/PropertyMemberTests.cs @@ -288,6 +288,57 @@ public void ReturnWhatever(MyEnum m) }"); } + [Fact] + public async Task TestParameterizedPropertyWithTriviaAsync() + { + //issue 1095 + await TestConversionVisualBasicToCSharpAsync( + @"Class IndexedPropertyWithTrivia + 'a + Property P(i As Integer) As Integer + 'b + Get + '1 + Dim x = 1 '2 + '3 + End Get + + 'c + Set(value As Integer) + '4 + Dim x = 1 '5 + '6 + x = value + i '7 + '8 + End Set + 'd + End Property +End Class", @" +internal partial class IndexedPropertyWithTrivia +{ + // a + // b + public int get_P(int i) + { + // 1 + int x = 1; // 2 + return default; + // 3 + } + + // c + public void set_P(int i, int value) + { + // 4 + int x = 1; // 5 + // 6 + x = value + i; // 7 + // 8 + // d + } +}"); + } + [Fact] public async Task PropertyWithMissingTypeDeclarationAsync()//TODO Check object is the inferred type { From a8c6d1033fe71bb4acea589a3b0f45d9bfb0f690 Mon Sep 17 00:00:00 2001 From: Timur Kelman Date: Thu, 25 Jul 2024 16:49:01 +0200 Subject: [PATCH 6/8] adjust tests: some old known bugs are fixed --- Tests/CSharp/MemberTests/MemberTests.cs | 2 +- Tests/CSharp/MemberTests/PropertyMemberTests.cs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Tests/CSharp/MemberTests/MemberTests.cs b/Tests/CSharp/MemberTests/MemberTests.cs index 1aae7ee1..b66950ec 100644 --- a/Tests/CSharp/MemberTests/MemberTests.cs +++ b/Tests/CSharp/MemberTests/MemberTests.cs @@ -669,7 +669,7 @@ public void set_Prop(int i, string value) _Prop_bSet = false; } -}", incompatibleWithAutomatedCommentTesting: true);// Known bug: Additional declarations don't get comments correctly converted +}"); } [Fact] diff --git a/Tests/CSharp/MemberTests/PropertyMemberTests.cs b/Tests/CSharp/MemberTests/PropertyMemberTests.cs index 23c3204b..db425709 100644 --- a/Tests/CSharp/MemberTests/PropertyMemberTests.cs +++ b/Tests/CSharp/MemberTests/PropertyMemberTests.cs @@ -84,7 +84,7 @@ Return LastName & "" "" & FirstName Return FirstName & "" "" & LastName End If End Get - ' Bug: Comment moves inside generated method + ' This comment belongs to the set method Friend Set If isFirst Then FirstName = Value End Set @@ -110,9 +110,8 @@ public string get_FullName(bool lastNameFirst, bool isFirst) { return FirstName + "" "" + LastName; } - // Bug: Comment moves inside generated method } - + // This comment belongs to the set method internal void set_FullName(bool lastNameFirst, bool isFirst, string value) { if (isFirst) @@ -176,7 +175,7 @@ Public Property FullName(Optional ByVal isFirst As Boolean = False) As String Get Return FirstName & "" "" & LastName End Get -'Bug: Comment moves inside generated get method +'This comment belongs to the set method Friend Set If isFirst Then FirstName = Value End Set @@ -197,9 +196,8 @@ internal partial class TestClass public string get_FullName(bool isFirst = false) { return FirstName + "" "" + LastName; - // Bug: Comment moves inside generated get method } - + // This comment belongs to the set method internal void set_FullName(bool isFirst = false, string value = default) { if (isFirst) From 363a25d15db28acc985143c86ebc104faccc3fb1 Mon Sep 17 00:00:00 2001 From: Timur Kelman Date: Thu, 25 Jul 2024 16:49:48 +0200 Subject: [PATCH 7/8] adjust tests: no empty line between getter and setter methods anymore --- Tests/CSharp/MemberTests/MemberTests.cs | 17 ----------------- Tests/CSharp/MemberTests/PropertyMemberTests.cs | 4 ---- .../My Project/MyNamespace.Static.3.Designer.cs | 3 --- .../My Project/MyNamespace.Static.2.Designer.cs | 3 --- .../My Project/MyNamespace.Static.2.Designer.cs | 3 --- .../My Project/MyNamespace.Static.2.Designer.cs | 3 --- .../My Project/MyNamespace.Static.3.Designer.cs | 3 --- .../My Project/MyNamespace.Static.3.Designer.cs | 3 --- .../My Project/MyNamespace.Static.2.Designer.cs | 3 --- 9 files changed, 42 deletions(-) diff --git a/Tests/CSharp/MemberTests/MemberTests.cs b/Tests/CSharp/MemberTests/MemberTests.cs index b66950ec..1a44e1b6 100644 --- a/Tests/CSharp/MemberTests/MemberTests.cs +++ b/Tests/CSharp/MemberTests/MemberTests.cs @@ -590,11 +590,9 @@ public virtual int get_RenamedPropertyParam(int i) { return 1; } - public virtual void set_RenamedPropertyParam(int i, int value) { } - int IClass.get_ReadOnlyPropParam(int i) => get_RenamedPropertyParam(i); public virtual int RenamedReadOnlyProperty @@ -614,11 +612,9 @@ public virtual int get_RenamedWriteOnlyPropParam(int i) { return 1; } - public virtual void set_RenamedWriteOnlyPropParam(int i, int value) { } - void IClass.set_WriteOnlyPropParam(int i, int value) => set_RenamedWriteOnlyPropParam(i, value); public virtual int RenamedWriteOnlyProperty @@ -832,21 +828,18 @@ public string get_ReadOnlyPropRenamed(int i) { throw new NotImplementedException(); } - string IClass.get_ReadOnlyPropToRename(int i) => get_ReadOnlyPropRenamed(i); public virtual void set_WriteOnlyPropRenamed(int i, string value) { throw new NotImplementedException(); } - void IClass.set_WriteOnlyPropToRename(int i, string value) => set_WriteOnlyPropRenamed(i, value); public virtual string get_PropRenamed(int i) { throw new NotImplementedException(); } - public virtual void set_PropRenamed(int i, string value) { throw new NotImplementedException(); @@ -859,21 +852,18 @@ private string get_ReadOnlyPropNonPublic(int i) { throw new NotImplementedException(); } - string IClass.get_ReadOnlyPropNonPublic(int i) => get_ReadOnlyPropNonPublic(i); protected internal virtual void set_WriteOnlyPropNonPublic(int i, string value) { throw new NotImplementedException(); } - void IClass.set_WriteOnlyPropNonPublic(int i, string value) => set_WriteOnlyPropNonPublic(i, value); internal virtual string get_PropNonPublic(int i) { throw new NotImplementedException(); } - internal virtual void set_PropNonPublic(int i, string value) { throw new NotImplementedException(); @@ -886,21 +876,18 @@ protected internal virtual string get_ReadOnlyPropRenamedNonPublic(int i) { throw new NotImplementedException(); } - string IClass.get_ReadOnlyPropToRenameNonPublic(int i) => get_ReadOnlyPropRenamedNonPublic(i); private void set_WriteOnlyPropRenamedNonPublic(int i, string value) { throw new NotImplementedException(); } - void IClass.set_WriteOnlyPropToRenameNonPublic(int i, string value) => set_WriteOnlyPropRenamedNonPublic(i, value); internal virtual string get_PropToRenameNonPublic(int i) { throw new NotImplementedException(); } - internal virtual void set_PropToRenameNonPublic(int i, string value) { throw new NotImplementedException(); @@ -2397,7 +2384,6 @@ private int get_ExplicitProp(string str = """") { return 5; } - private void set_ExplicitProp(string str = """", int value = default) { } @@ -3072,7 +3058,6 @@ private int get_ExplicitProp(string str) { return 5; } - private void set_ExplicitProp(string str, int value) { } @@ -3125,7 +3110,6 @@ public virtual int get_PropParams(string str) { return 5; } - public virtual void set_PropParams(string str, int value) { } @@ -3748,7 +3732,6 @@ private int get_ExplicitProp(string str) { return 5; } - private void set_ExplicitProp(string str, int value) { } diff --git a/Tests/CSharp/MemberTests/PropertyMemberTests.cs b/Tests/CSharp/MemberTests/PropertyMemberTests.cs index db425709..e75b9b09 100644 --- a/Tests/CSharp/MemberTests/PropertyMemberTests.cs +++ b/Tests/CSharp/MemberTests/PropertyMemberTests.cs @@ -150,7 +150,6 @@ public float get_SomeProp(int index) { return 1.5f; } - public void set_SomeProp(int index, float value) { } @@ -257,7 +256,6 @@ public string get_MyProp(int blah) { return blah.ToString(); } - public void set_MyProp(int blah, string value) { } @@ -569,7 +567,6 @@ internal int get_Prop2(int x = 1, int y = 2) { return default; } - internal void set_Prop2(int x = 1, int y = 2, int value = default) { } @@ -659,7 +656,6 @@ internal int get_Prop2(int x = 1, int y = 2, int z = 3) { return default; } - internal void set_Prop2(int x = 1, int y = 2, int z = 3, int value = default) { } diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs index 29ee4992..1a4f092f 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertVbLibraryOnly/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs @@ -27,7 +27,6 @@ public static string get_Value(IEnumerable source) return item.Value; return null; } - public static void set_Value(IEnumerable source, string value) { foreach (XElement item in source) @@ -42,7 +41,6 @@ public static string get_AttributeValue(IEnumerable source, XName name return (string)item.Attribute(name); return null; } - public static void set_AttributeValue(IEnumerable source, XName name, string value) { foreach (XElement item in source) @@ -55,7 +53,6 @@ public static string get_AttributeValue(XElement source, XName name) { return (string)source.Attribute(name); } - public static void set_AttributeValue(XElement source, XName name, string value) { source.SetAttributeValue(name, value); diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/ConsoleApp1/My Project/MyNamespace.Static.2.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/ConsoleApp1/My Project/MyNamespace.Static.2.Designer.cs index 9a517d23..05c0af1b 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/ConsoleApp1/My Project/MyNamespace.Static.2.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/ConsoleApp1/My Project/MyNamespace.Static.2.Designer.cs @@ -28,7 +28,6 @@ public static string get_Value(IEnumerable source) return item.Value; return null; } - public static void set_Value(IEnumerable source, string value) { foreach (XElement item in source) @@ -43,7 +42,6 @@ public static string get_AttributeValue(IEnumerable source, XName name return (string)item.Attribute(name); return null; } - public static void set_AttributeValue(IEnumerable source, XName name, string value) { foreach (XElement item in source) @@ -56,7 +54,6 @@ public static string get_AttributeValue(XElement source, XName name) { return (string)source.Attribute(name); } - public static void set_AttributeValue(XElement source, XName name, string value) { source.SetAttributeValue(name, value); diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/ConsoleApp4/My Project/MyNamespace.Static.2.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/ConsoleApp4/My Project/MyNamespace.Static.2.Designer.cs index 7599da92..b4102757 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/ConsoleApp4/My Project/MyNamespace.Static.2.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/ConsoleApp4/My Project/MyNamespace.Static.2.Designer.cs @@ -27,7 +27,6 @@ public static string get_Value(IEnumerable source) return item.Value; return null; } - public static void set_Value(IEnumerable source, string value) { foreach (XElement item in source) @@ -42,7 +41,6 @@ public static string get_AttributeValue(IEnumerable source, XName name return (string)item.Attribute(name); return null; } - public static void set_AttributeValue(IEnumerable source, XName name, string value) { foreach (XElement item in source) @@ -55,7 +53,6 @@ public static string get_AttributeValue(XElement source, XName name) { return (string)source.Attribute(name); } - public static void set_AttributeValue(XElement source, XName name, string value) { source.SetAttributeValue(name, value); diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/Prefix.VbLibrary/My Project/MyNamespace.Static.2.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/Prefix.VbLibrary/My Project/MyNamespace.Static.2.Designer.cs index ad6dbce3..1eafdfc6 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/Prefix.VbLibrary/My Project/MyNamespace.Static.2.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/Prefix.VbLibrary/My Project/MyNamespace.Static.2.Designer.cs @@ -28,7 +28,6 @@ public static string get_Value(IEnumerable source) return item.Value; return null; } - public static void set_Value(IEnumerable source, string value) { foreach (XElement item in source) @@ -43,7 +42,6 @@ public static string get_AttributeValue(IEnumerable source, XName name return (string)item.Attribute(name); return null; } - public static void set_AttributeValue(IEnumerable source, XName name, string value) { foreach (XElement item in source) @@ -56,7 +54,6 @@ public static string get_AttributeValue(XElement source, XName name) { return (string)source.Attribute(name); } - public static void set_AttributeValue(XElement source, XName name, string value) { source.SetAttributeValue(name, value); diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs index 29ee4992..1a4f092f 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbLibrary/My Project/MyNamespace.Static.3.Designer.cs @@ -27,7 +27,6 @@ public static string get_Value(IEnumerable source) return item.Value; return null; } - public static void set_Value(IEnumerable source, string value) { foreach (XElement item in source) @@ -42,7 +41,6 @@ public static string get_AttributeValue(IEnumerable source, XName name return (string)item.Attribute(name); return null; } - public static void set_AttributeValue(IEnumerable source, XName name, string value) { foreach (XElement item in source) @@ -55,7 +53,6 @@ public static string get_AttributeValue(XElement source, XName name) { return (string)source.Attribute(name); } - public static void set_AttributeValue(XElement source, XName name, string value) { source.SetAttributeValue(name, value); diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbNetStandardLib/My Project/MyNamespace.Static.3.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbNetStandardLib/My Project/MyNamespace.Static.3.Designer.cs index feb85f04..f178d034 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbNetStandardLib/My Project/MyNamespace.Static.3.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/VbNetStandardLib/My Project/MyNamespace.Static.3.Designer.cs @@ -27,7 +27,6 @@ public static string get_Value(IEnumerable source) return item.Value; return null; } - public static void set_Value(IEnumerable source, string value) { foreach (XElement item in source) @@ -42,7 +41,6 @@ public static string get_AttributeValue(IEnumerable source, XName name return (string)item.Attribute(name); return null; } - public static void set_AttributeValue(IEnumerable source, XName name, string value) { foreach (XElement item in source) @@ -55,7 +53,6 @@ public static string get_AttributeValue(XElement source, XName name) { return (string)source.Attribute(name); } - public static void set_AttributeValue(XElement source, XName name, string value) { source.SetAttributeValue(name, value); diff --git a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/WindowsAppVb/My Project/MyNamespace.Static.2.Designer.cs b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/WindowsAppVb/My Project/MyNamespace.Static.2.Designer.cs index 281d5294..b5342896 100644 --- a/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/WindowsAppVb/My Project/MyNamespace.Static.2.Designer.cs +++ b/Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/WindowsAppVb/My Project/MyNamespace.Static.2.Designer.cs @@ -28,7 +28,6 @@ public static string get_Value(IEnumerable source) return item.Value; return null; } - public static void set_Value(IEnumerable source, string value) { foreach (XElement item in source) @@ -43,7 +42,6 @@ public static string get_AttributeValue(IEnumerable source, XName name return (string)item.Attribute(name); return null; } - public static void set_AttributeValue(IEnumerable source, XName name, string value) { foreach (XElement item in source) @@ -56,7 +54,6 @@ public static string get_AttributeValue(XElement source, XName name) { return (string)source.Attribute(name); } - public static void set_AttributeValue(XElement source, XName name, string value) { source.SetAttributeValue(name, value); From e9aefd3c4e8ec5ef31731eb59ab88a3e5141d27c Mon Sep 17 00:00:00 2001 From: Timur Kelman Date: Thu, 25 Jul 2024 16:58:27 +0200 Subject: [PATCH 8/8] clarify code a tiny bit --- CodeConverter/CSharp/DeclarationNodeVisitor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CodeConverter/CSharp/DeclarationNodeVisitor.cs b/CodeConverter/CSharp/DeclarationNodeVisitor.cs index bde95b4c..a719080d 100644 --- a/CodeConverter/CSharp/DeclarationNodeVisitor.cs +++ b/CodeConverter/CSharp/DeclarationNodeVisitor.cs @@ -950,8 +950,8 @@ public override async Task VisitPropertyBlock(VBSyntax.Propert var firstVbSourceToken = node.GetFirstToken(); first = first.ReplaceToken(firstCsConvertedToken, firstCsConvertedToken.WithSourceMappingFrom(firstVbSourceToken)); - _additionalDeclarations.TryGetValue(node, out var members); - var last = members?.OfType().LastOrDefault() ?? first; + var members = _additionalDeclarations[node]; + var last = members.OfType().LastOrDefault() ?? first; var lastIx = members.ToList().IndexOf(last); var lastIsFirst = lastIx < 0; var lastCsConvertedToken = last.GetLastToken(); @@ -960,7 +960,7 @@ public override async Task VisitPropertyBlock(VBSyntax.Propert converted = lastIsFirst ? last : first; if (!lastIsFirst) { - members![lastIx] = last; + members[lastIx] = last; } }