diff --git a/CodeConverter/CSharp/ExpressionNodeVisitor.cs b/CodeConverter/CSharp/ExpressionNodeVisitor.cs index 1084ed19..9af8d45f 100644 --- a/CodeConverter/CSharp/ExpressionNodeVisitor.cs +++ b/CodeConverter/CSharp/ExpressionNodeVisitor.cs @@ -1836,6 +1836,9 @@ RefConversion GetRefConversion(VBSyntax.ExpressionSyntax expression) if (symbolInfo is IPropertySymbol propertySymbol) { return propertySymbol.IsReadOnly ? RefConversion.PreAssigment : RefConversion.PreAndPostAssignment; } + else if (symbolInfo is IFieldSymbol { IsConst: true } or ILocalSymbol { IsConst: true }) { + return RefConversion.PreAssigment; + } if (DeclaredInUsing(symbolInfo)) return RefConversion.PreAssigment; diff --git a/Tests/CSharp/MemberTests/MemberTests.cs b/Tests/CSharp/MemberTests/MemberTests.cs index 148aa6a5..bbb4389c 100644 --- a/Tests/CSharp/MemberTests/MemberTests.cs +++ b/Tests/CSharp/MemberTests/MemberTests.cs @@ -4047,6 +4047,40 @@ public static int StaticTestProperty return _StaticTestProperty_sPrevPosition + 1; } } +}"); + } + + [Fact] + public async Task TestRefConstArgumentAsync() + { + await TestConversionVisualBasicToCSharpAsync( + @"Class RefConstArgument + Const a As String = ""a"" + Sub S() + Const b As String = ""b"" + MO(a) + MS(b) + End Sub + Sub MO(ByRef s As Object) : End Sub + Sub MS(ByRef s As String) : End Sub +End Class", @" +internal partial class RefConstArgument +{ + private const string a = ""a""; + public void S() + { + const string b = ""b""; + object args = a; + MO(ref args); + string args1 = b; + MS(ref args1); + } + public void MO(ref object s) + { + } + public void MS(ref string s) + { + } }"); } } \ No newline at end of file