Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column属性がCSVファイルのカラム数より少ないとデシリアライズ結果がおかしい #10

Closed
shiena opened this issue Jun 26, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@shiena
Copy link

shiena commented Jun 26, 2024

たとえば以下のカラム数3つのCSVがある時に

col1, col2, col3
foo1, bar1, baz1
foo2, bar2, baz2

Column属性が3つ未満のCsvObjectで読み込むとデシリアライズ結果の配列数が2倍になり、偶数番目は空のModelが入っています。

[CsvObject]
public partial class Model
{
    [Column(0)] public string col1;
    [Column(1)] public string col2;
}

public class CsvLoader
{
    public Model[] Load(string path)
    {
        using var fs = File.OpenRead(path);
        var result = CsvSerializer.Deserialize<Model>(fs);
        // resultの数が4つになり、偶数番目は空のModelが入っている
        return result;
    }
}

CSVのカラム数とColumn属性の数を合わせるのは必須でしょうか?

@AnnulusGames AnnulusGames added the bug Something isn't working label Jun 29, 2024
@AnnulusGames AnnulusGames self-assigned this Jun 29, 2024
@AnnulusGames
Copy link
Owner

この問題は #11 で修正されました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants