Closed VBAndCs closed 4 years ago
Similar issue here: C#:
foreach (var item in ViewLocationExpanderValues)
{
hashCodeCombiner.Add(item.Key, StringComparer.Ordinal);
hashCodeCombiner.Add(item.Value, StringComparer.Ordinal);
}
VB:
For Each item As IEnumerable(Of KeyValuePair(Of String, String)) In ViewLocationExpanderValues
_hashCodeCombiner.Add(item.Key, StringComparer.Ordinal)
_hashCodeCombiner.Add(item.Value, StringComparer.Ordinal)
Next
The item is of type KeyValuePair(Of String, String)
not IEnumerable(Of KeyValuePair(Of String, String))
, and you can avoid this but maintain inference:
For Each item In ViewLocationExpanderValues
_hashCodeCombiner.Add(item.Key, StringComparer.Ordinal)
_hashCodeCombiner.Add(item.Value, StringComparer.Ordinal)
Next
I am getting your desired results when I just convert the snippet. I need a more complete example to debug the issue. I try to avoid type inference when I know the type. The defaults for all my projects are Infer Off, Strict On, Explicit On.
You should stick with the original c# code. Inference makes the code shorter and cleaner so more readable. Besides, you write the full qualified names srating with system. Save your self the truple and keep inferencxe. C# and vb are idintical in this aspect.
I now support user setting of Option Infer, I may look at using this for source generation in the future. But it is not high priority.
I now allow the user to specify the options included in the converted code so you can set whatever you want and the converter will include your selections. @VBAndCs if you still have an issue open a new report with enough source to reproduce.
C#:
VB:
No need to explicit declaration here. This is OK:
Dim activateInfo = propertiesToActivate(i)
But if you have to mention the type, you should evaluate the type param, instead using
TContext
which is the raw generic declaration not a real type. In this context, TContext is evaluated to beViewContext()
. You need to use a valid sample to reproduce this case.