Monday, February 15, 2021

VB.NET Property is of Unsupported Type

 Backward compatibility is hard and there is a saying "The only constant is change". The error message this time makes me scratch my head for an hour or so.

Problem

I updated the CsvHelper package in one of my applications to 23.0.0 and immediately notice errors. Looking at the change log (https://joshclose.github.io/CsvHelper/change-log) and indeed there is a breaking change. I'm aware of the parameter change to a struct as specified in the change log and made the required change. 

For somewhat reason, Visual Studio didn't like the configuration part, for example the PrepareHeaderForMatch delegate, in which it can't access the property of the struct argument. The error message says: Property 'CsvHelper.PrepareHeaderForMatchArgs.Header' is of unsupported type.

Solution

This happens on Visual Studio 2017. So, I visited the GitHub repository:

https://github.com/JoshClose/CsvHelper/blob/master/src/CsvHelper/Delegates/PrepareHeaderForMatch.cs

and noticed the following code:

public string Header { get; init; }

After searching online, seems like the 'init' setter is the issue. It is supported in VB 16.9 which is immediately available in Visual Studio 2019.


When I opened the code in Visual Studio 2019, the error went away. So due to time constraint, I switch to VS 2019 for that particular application.

No comments:

Post a Comment