Repository navigation
[BUG] - IAsyncEnumerable not correctly detected in net472 #974
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Continuation of #953 CC @michelebastione
When implementing using a channel in net472, MiniExcel does not detect the IAsyncEnumerable correctly and throws a notImplementException when it goes to GetWriteAdapter instead of GetWriteAsyncAdapter.
If you retarget the below code to net10.0, it works.
Program.cs
using MiniExcelLibs;
static async IAsyncEnumerable<Row> GetRowsAsync()
{
for (var i = 1; i <= 10; i++)
{
await Task.Delay(25);
yield return new Row(i, $"Item {i}");
}
}
var outputPath = Path.Combine(Environment.CurrentDirectory, "output.xlsx");
await MiniExcel.SaveAsAsync(outputPath, GetRowsAsync());
public record Row(int Id, string Name);CSProj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MiniExcel" Version="1.44.1" />
<PackageReference Include="PolySharp" Version="1.16.0" />
<PackageReference Include="Microsoft.BCL.AsyncInterfaces" Version="10.0.9" />
<PackageReference Include="System.Threading.Channels" Version="10.0.9" />
</ItemGroup>
</Project>Run Result
Unhandled Exception: System.NotImplementedException: The method or operation is not implemented.
at MiniExcelLibs.WriteAdapter.MiniExcelWriteAdapterFactory.GetWriteAdapter(Object values, Configuration configuration)
at MiniExcelLibs.OpenXml.ExcelOpenXmlSheetWriter.<WriteValuesAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MiniExcelLibs.OpenXml.ExcelOpenXmlSheetWriter.<CreateSheetXmlAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at MiniExcelLibs.OpenXml.ExcelOpenXmlSheetWriter.<SaveAsAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MiniExcelLibs.MiniExcel.<SaveAsAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MiniExcelLibs.MiniExcel.<SaveAsAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Program.<<Main>$>d__0.MoveNext() in C:\Users\justi\Projects\Sandbox\MiniExcelTest\Program.cs:line 5
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Program.<Main>(String[] args)
Likely Problem
MiniExcel/src/MiniExcel.Core/WriteAdapters/MiniExcelWriteAdapterFactory.cs
Lines 10 to 12 in 3359104
| var writeAdapterType = typeof(AsyncEnumerableWriteAdapter<>).MakeGenericType(genericArgument!); | |
| writeAdapter = Activator.CreateInstance(writeAdapterType, values, configuration) as IMiniExcelWriteAdapterAsync; | |
| return true; |
This code returns false for the IAsyncEnumerable, and is not detecting it correctly.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
JustinGrote commentedon Jun 16, 2026
I tested 2.0.0-preview.4 and it seems to work there, but I'll leave this open for a decision to either backport the fix to 1.x or just close the issue and tell people to use 2.0
michelebastione commentedon Jun 17, 2026
Thank you for reporting the issue, we'll try to address it in the next release. This is actually a dependency resolution issue specifically affecting .NET Framework that wasn't apparent before. In the meantime you should be able to circumvent the issue by removing the current reference to the MiniExcel package in your project and adding the following snippet:
JustinGrote commentedon Jun 26, 2026
Thank you!