Open ghost opened 8 years ago
@ghost - do you know if this issue has been fixed in later releases?
I'm about to start using FileHelpers in a project I am developing using VB. If FileHelpers still has this issue I'll have to try and learn enough C# to create a separate project for the file I/O that is required.
I have the same issue. The IL-Code of the VB compiler is different.
IL of AutoProperty in VB
IL_0002: stfld int32 FileHelperVb.TestRecord::_Id
IL of AutoProperty in C#
IL_0002: stfld int32 FileHelpersC.TestRecord::'<Id>k__BackingField'
In your code you only check for the C# name of the backing field.
if (fi.Name.EndsWith("__BackingField") &&
fi.Name.StartsWith("<") &&
fi.Name.Contains(">"))
res.FieldFriendlyName = fi.Name.Substring(1, fi.Name.IndexOf(">") - 1);
res.IsAutoProperty = true;
var prop = fi.DeclaringType.GetProperty(res.FieldFriendlyName);
if (prop != null)
{
Attributes.WorkWithFirst<FieldOrderAttribute>(prop, x => res.FieldOrder = x.Order);
}
This results in a res.FieldFriendlyName of null.
Can you fix this in a new build?
Thank you for analyzing and fixing this problem and for your patience.
It would speed up the inclusion of the fix if you could add a NUnit test revealing this problem.
Thank you, Matthias
See also #331:
There seems to be a discrepancy in how the library detects auto-implemented properties in VB vs C#
I created two brand-new MVC projects for testing.
C#
VB
Stack Trace