We're currently using a custom type map like this:
internal class RemoveSpacesFromColumnNames : SqlMapper.ITypeMap
{
private readonly Type _type;
public RemoveSpacesFromColumnNames(Type type)
{
_type = type;
}
public ConstructorInfo FindConstructor(string[] names, Type[] types) =>
_type.GetConstructors().Single();
public ConstructorInfo? FindExplicitConstructor() => null;
public SqlMapper.IMemberMap? GetConstructorParameter(ConstructorInfo constructor, string columnName)
{
var nameWithoutSpaces = columnName.Replace(" ", "");
var parameter = constructor.GetParameters().FirstOrDefault(x => x.Name == nameWithoutSpaces);
return parameter == null ? null : new CustomParameterMap(columnName, parameter);
}
public SqlMapper.IMemberMap? GetMember(string columnName) => null;
}
where we'd added the nullable reference annotations ourselves. (Hopefully this code doesn't look too crazy :)
However when updating to dapper 2.1.4 this code now fails to compile since GetConstructorParameter is expected to return SqlMapper.IMemberMap instead of SqlMapper.IMemberMap?.
In SqlMapper.GenerateDeserializerFromMap it seems like the output of this method is checked for null in the same way that GetMember is, so I guess returning null is probably valid here?
We're currently using a custom type map like this:
where we'd added the nullable reference annotations ourselves. (Hopefully this code doesn't look too crazy :)
However when updating to dapper 2.1.4 this code now fails to compile since
GetConstructorParameteris expected to returnSqlMapper.IMemberMapinstead ofSqlMapper.IMemberMap?.In
SqlMapper.GenerateDeserializerFromMapit seems like the output of this method is checked for null in the same way thatGetMemberis, so I guess returning null is probably valid here?