VB -> C# Parameterized property
See original GitHub issueInput code
Public ReadOnly Property FullName(ByVal lastNameFirst As Boolean) As String
Get
If lastNameFirst Then
Return LastName & " " & FirstName
Else
Return FirstName & " " & LastName
End If
End Get
End Property
Erroneous output
public string FullName
{
get
{
if (lastNameFirst)
return LastName + " " + FirstName;
else
return FirstName + " " + LastName;
}
}
Expected output
public string FullName(bool lastNameFirst)
{
if (lastNameFirst)
return LastName + " " + FirstName;
else
return FirstName + " " + LastName;
}
Details
Product in use: VS extension
Version in use: 6.1.0.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
What is the difference between a parameterized property ...
Based on this principle, the most common use case for parameterized properties in VB.NET is in classes that represent a sequence of items, ......
Read more >Property Statement - Visual Basic
This parameter holds the value to be assigned to the property. You typically store this value in a private local variable and return...
Read more >Properties with Parameters (and Making Them the Default)
You can create properties that accept parameters (just like methods!). But they work best when they're also the default property of your ...
Read more >VB.NET Property Examples (Get, Set)
In VB.NET, a Property is similar to a Function. With a getter and a setter, it controls access to a value. This value...
Read more >Re: A Class Public Property with one input parameter
I have a VB.NET code, but I don't know how to write in C#. Code: Public WriteOnly Property Borders(Edge As EdgeEnum) As LineStyleEnum...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sadly all i can help with is identify and workarounds.
Speaking of which, in case anyone else wants to change it before converting it to C# here is a regex to identify the parameterized properties.
Property?\s+(\w+)\s*(\([^()]+\))
Nice investigation. Yep I usually look at the decompiled IL version of a VB assembly using the feature to see if I can at least take some inspiration. Obviously it doesn’t always map across nicely though. Since the setter sounds like a complicated (and not super-common) case, I’d happily take a PR that only works in C# 7.3+ if you can get it working. ref sounds like a plausible way to get it working.