Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,22 @@
public ValueTask<string> MapObjectToCsvAsync<T>(
List<T> @object,
bool hasHeaderRecord,
Dictionary<string, int>? fieldMappings = null,

Check warning on line 48 in NHSISL.CsvHelperClient/Services/Foundations/CsvHelpers/CsvHelperService.cs

View workflow job for this annotation

GitHub Actions / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 48 in NHSISL.CsvHelperClient/Services/Foundations/CsvHelpers/CsvHelperService.cs

View workflow job for this annotation

GitHub Actions / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 48 in NHSISL.CsvHelperClient/Services/Foundations/CsvHelpers/CsvHelperService.cs

View workflow job for this annotation

GitHub Actions / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 48 in NHSISL.CsvHelperClient/Services/Foundations/CsvHelpers/CsvHelperService.cs

View workflow job for this annotation

GitHub Actions / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
bool? shouldAddTrailingComma = false) =>
TryCatch(async () =>
{
ValidateMapObjectToCsvArguments(@object, hasHeaderRecord);
string csv = await GetCsvFromListOfObjectsAsync(@object, hasHeaderRecord, fieldMappings, shouldAddTrailingComma);

return await ValueTask.FromResult(csv);
});

virtual internal async ValueTask<string> GetCsvFromListOfObjectsAsync<T>(
List<T> @object,
bool hasHeaderRecord,
Dictionary<string, int> fieldMappings = null,
bool? shouldAddTrailingComma = false)
{
var type = typeof(T);
bool isPlainObject = type == typeof(object);
ValidateMapObjectToCsvArgumentCombination(isPlainObject, shouldAddTrailingComma);
Expand Down Expand Up @@ -93,6 +104,6 @@

return await ValueTask.FromResult(csv);
}
});
}
}
}
Loading