From 68dcd32c36154a9f5b3e6f6c54ca4e6df24862d3 Mon Sep 17 00:00:00 2001
From: fuguikz <2514883828@qq.com>
Date: Fri, 19 Dec 2025 00:34:45 +0800
Subject: [PATCH] Document ObjectDisposedException for GetRecords overloads
---
src/CsvHelper/CsvReader.cs | 22 +++++++++++----------
tests/CsvHelper.Tests/Reading/YieldTests.cs | 19 ++++++++++++++++++
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/src/CsvHelper/CsvReader.cs b/src/CsvHelper/CsvReader.cs
index 3fa74c2a0..d9a1402f6 100644
--- a/src/CsvHelper/CsvReader.cs
+++ b/src/CsvHelper/CsvReader.cs
@@ -891,11 +891,12 @@ record = read();
}
}
- ///
- public virtual IEnumerable GetRecords(T anonymousTypeDefinition)
- {
- if (anonymousTypeDefinition == null)
- {
+ ///
+ /// Thrown when the reader has been disposed.
+ public virtual IEnumerable GetRecords(T anonymousTypeDefinition)
+ {
+ if (anonymousTypeDefinition == null)
+ {
throw new ArgumentNullException(nameof(anonymousTypeDefinition));
}
@@ -907,11 +908,12 @@ public virtual IEnumerable GetRecords(T anonymousTypeDefinition)
return GetRecords();
}
- ///
- public virtual IEnumerable