Skip to content

Commit f2bf7b7

Browse files
committed
Remove redundant WithCancellation
1 parent e05dc99 commit f2bf7b7

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/MiniExcel/MiniExcel.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,31 @@ public static async Task<int[]> SaveAsAsync(this Stream stream, object value, bo
105105
public static async IAsyncEnumerable<T> QueryAsync<T>(string path, string sheetName = null, ExcelType excelType = ExcelType.UNKNOWN, string startCell = "A1", IConfiguration configuration = null, bool hasHeader = true, [EnumeratorCancellation] CancellationToken cancellationToken = default) where T : class, new()
106106
{
107107
using (var stream = FileHelper.OpenSharedRead(path))
108-
await foreach (var item in QueryAsync<T>(stream, sheetName, ExcelTypeHelper.GetExcelType(path, excelType), startCell, configuration, hasHeader, cancellationToken).WithCancellation(cancellationToken).ConfigureAwait(false))
108+
await foreach (var item in QueryAsync<T>(stream, sheetName, ExcelTypeHelper.GetExcelType(path, excelType), startCell, configuration, hasHeader, cancellationToken).ConfigureAwait(false))
109109
yield return item; //Foreach yield return twice reason : https://stackoverflow.com/questions/66791982/ienumerable-extract-code-lazy-loading-show-stream-was-not-readable
110110
}
111111

112112
[Zomp.SyncMethodGenerator.CreateSyncVersion]
113113
public static async IAsyncEnumerable<T> QueryAsync<T>(this Stream stream, string sheetName = null, ExcelType excelType = ExcelType.UNKNOWN, string startCell = "A1", IConfiguration configuration = null, bool hasHeader = true, [EnumeratorCancellation] CancellationToken cancellationToken = default) where T : class, new()
114114
{
115115
using (var excelReader = await ExcelReaderFactory.GetProviderAsync(stream, ExcelTypeHelper.GetExcelType(stream, excelType), configuration, cancellationToken).ConfigureAwait(false))
116-
await foreach (var item in excelReader.QueryAsync<T>(sheetName, startCell, hasHeader, cancellationToken).WithCancellation(cancellationToken).ConfigureAwait(false))
116+
await foreach (var item in excelReader.QueryAsync<T>(sheetName, startCell, hasHeader, cancellationToken).ConfigureAwait(false))
117117
yield return item;
118118
}
119119

120120
[Zomp.SyncMethodGenerator.CreateSyncVersion]
121121
public static async IAsyncEnumerable<dynamic> QueryAsync(string path, bool useHeaderRow = false, string sheetName = null, ExcelType excelType = ExcelType.UNKNOWN, string startCell = "A1", IConfiguration configuration = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
122122
{
123123
using (var stream = FileHelper.OpenSharedRead(path))
124-
await foreach (var item in QueryAsync(stream, useHeaderRow, sheetName, ExcelTypeHelper.GetExcelType(path, excelType), startCell, configuration, cancellationToken).WithCancellation(cancellationToken).ConfigureAwait(false))
124+
await foreach (var item in QueryAsync(stream, useHeaderRow, sheetName, ExcelTypeHelper.GetExcelType(path, excelType), startCell, configuration, cancellationToken).ConfigureAwait(false))
125125
yield return item;
126126
}
127127

128128
[Zomp.SyncMethodGenerator.CreateSyncVersion]
129129
public static async IAsyncEnumerable<dynamic> QueryAsync(this Stream stream, bool useHeaderRow = false, string sheetName = null, ExcelType excelType = ExcelType.UNKNOWN, string startCell = "A1", IConfiguration configuration = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
130130
{
131131
using (var excelReader = await ExcelReaderFactory.GetProviderAsync(stream, ExcelTypeHelper.GetExcelType(stream, excelType), configuration, cancellationToken).ConfigureAwait(false))
132-
await foreach (var item in excelReader.QueryAsync(useHeaderRow, sheetName, startCell, cancellationToken).WithCancellation(cancellationToken).ConfigureAwait(false))
132+
await foreach (var item in excelReader.QueryAsync(useHeaderRow, sheetName, startCell, cancellationToken).ConfigureAwait(false))
133133
yield return item.Aggregate(new ExpandoObject() as IDictionary<string, object>,
134134
(dict, p) => { dict.Add(p); return dict; });
135135
}
@@ -155,15 +155,15 @@ public static async IAsyncEnumerable<dynamic> QueryAsync(this Stream stream, boo
155155
public static async IAsyncEnumerable<dynamic> QueryRangeAsync(string path, bool useHeaderRow = false, string sheetName = null, ExcelType excelType = ExcelType.UNKNOWN, string startCell = "A1", string endCell = "", IConfiguration configuration = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
156156
{
157157
using (var stream = FileHelper.OpenSharedRead(path))
158-
await foreach (var item in QueryRangeAsync(stream, useHeaderRow, sheetName, ExcelTypeHelper.GetExcelType(path, excelType), startCell, endCell, configuration, cancellationToken).WithCancellation(cancellationToken).ConfigureAwait(false))
158+
await foreach (var item in QueryRangeAsync(stream, useHeaderRow, sheetName, ExcelTypeHelper.GetExcelType(path, excelType), startCell, endCell, configuration, cancellationToken).ConfigureAwait(false))
159159
yield return item;
160160
}
161161

162162
[Zomp.SyncMethodGenerator.CreateSyncVersion]
163163
public static async IAsyncEnumerable<dynamic> QueryRangeAsync(this Stream stream, bool useHeaderRow = false, string sheetName = null, ExcelType excelType = ExcelType.UNKNOWN, string startCell = "A1", string endCell = "", IConfiguration configuration = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
164164
{
165165
using (var excelReader = await ExcelReaderFactory.GetProviderAsync(stream, ExcelTypeHelper.GetExcelType(stream, excelType), configuration, cancellationToken).ConfigureAwait(false))
166-
await foreach (var item in excelReader.QueryRangeAsync(useHeaderRow, sheetName, startCell, endCell, cancellationToken).WithCancellation(cancellationToken).ConfigureAwait(false))
166+
await foreach (var item in excelReader.QueryRangeAsync(useHeaderRow, sheetName, startCell, endCell, cancellationToken).ConfigureAwait(false))
167167
yield return item.Aggregate(new ExpandoObject() as IDictionary<string, object>,
168168
(dict, p) => { dict.Add(p); return dict; });
169169
}
@@ -172,15 +172,15 @@ public static async IAsyncEnumerable<dynamic> QueryRangeAsync(this Stream stream
172172
public static async IAsyncEnumerable<dynamic> QueryRangeAsync(string path, bool useHeaderRow = false, string sheetName = null, ExcelType excelType = ExcelType.UNKNOWN, int startRowIndex = 1, int startColumnIndex = 1, int? endRowIndex = null, int? endColumnIndex = null, IConfiguration configuration = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
173173
{
174174
using (var stream = FileHelper.OpenSharedRead(path))
175-
await foreach (var item in QueryRangeAsync(stream, useHeaderRow, sheetName, ExcelTypeHelper.GetExcelType(path, excelType), startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, configuration, cancellationToken).WithCancellation(cancellationToken).ConfigureAwait(false))
175+
await foreach (var item in QueryRangeAsync(stream, useHeaderRow, sheetName, ExcelTypeHelper.GetExcelType(path, excelType), startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, configuration, cancellationToken).ConfigureAwait(false))
176176
yield return item;
177177
}
178178

179179
[Zomp.SyncMethodGenerator.CreateSyncVersion]
180180
public static async IAsyncEnumerable<dynamic> QueryRangeAsync(this Stream stream, bool useHeaderRow = false, string sheetName = null, ExcelType excelType = ExcelType.UNKNOWN, int startRowIndex = 1, int startColumnIndex = 1, int? endRowIndex = null, int? endColumnIndex = null, IConfiguration configuration = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
181181
{
182182
using (var excelReader = await ExcelReaderFactory.GetProviderAsync(stream, ExcelTypeHelper.GetExcelType(stream, excelType), configuration, cancellationToken).ConfigureAwait(false))
183-
await foreach (var item in excelReader.QueryRangeAsync(useHeaderRow, sheetName, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, cancellationToken).WithCancellation(cancellationToken).ConfigureAwait(false))
183+
await foreach (var item in excelReader.QueryRangeAsync(useHeaderRow, sheetName, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, cancellationToken).ConfigureAwait(false))
184184
yield return item.Aggregate(new ExpandoObject() as IDictionary<string, object>,
185185
(dict, p) => { dict.Add(p); return dict; });
186186
}

src/MiniExcel/OpenXml/ExcelOpenXmlSheetReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ internal async Task<List<SheetRecord>> GetWorkbookRelsAsync(ReadOnlyCollection<Z
593593
);
594594

595595
var sheetRecords = new List<SheetRecord>();
596-
await foreach (var sheetRecord in ReadWorkbookAsync(entries, cancellationToken).WithCancellation(cancellationToken).ConfigureAwait(false))
596+
await foreach (var sheetRecord in ReadWorkbookAsync(entries, cancellationToken).ConfigureAwait(false))
597597
{
598598
sheetRecords.Add(sheetRecord);
599599
}

0 commit comments

Comments
 (0)