dotnet / dotnet/command-line-api
Exception stack-traces when using System.CommandLine.DragonFruit are not friendly...
- Lingua principale
- C#
- Stelle
- 3.7k
- Fork
- 428
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Here's a sample assertion from a program I have using System.CommandLine.DragonFruit:
Note:
1. I tried to catch the exception and Just print nothing instead of this wall of text (below):
```csharp
public static unsafe void Main(...)
{
try {
WrappedMain(...);
}
catch {
Console.WriteLine("XXX");
}
}
```
This does not work, I didn't bother to investigate why that is the case
2. Instead, the default behaviour here generated 90 lines of exception stack trace,
**84** (!) of which are internal stuff inside System.CommandLine.DragonFruit which I would claim that no normal user should care about? Wouldn't it make sense to never have this printed under any circumstances to the user, except for maybe debug builds of your own package?
```bash
Process terminated. Assertion failed.
depth=0 boundary=30, idx = 0 *t(24) <= pivot=12
at QuickSortAvaganza.AVX2.Happy.AVX2DoublePumpedAlignedOverlapUnrolledWithPCSort`1.QuickSortInt32.VerifyBoundaryIsCorrect(Int32* left, Int32* right, Int32 pivot, Int32* boundary) in /home/dmg/projects/public/QuicksortAvaganza/QuickSortAvaganza/AVX2/Happy/07_AVX2DoublePumpedUnrolledWithPCSort.cs:line 809
at QuickSortAvaganza.AVX2.Happy.AVX2DoublePumpedAlignedOverlapUnrolledWithPCSort`1.QuickSortInt32.VectorizedPartitionInPlace(Int32* left, Int32* right, Int64 hint) in /home/dmg/projects/public/QuicksortAvaganza/QuickSortAvaganza/AVX2/Happy/07_AVX2DoublePumpedUnrolledWithPCSort.cs:line 491
at QuickSortAvaganza.AVX2.Happy.AVX2DoublePumpedAlignedOverlapUnrolledWithPCSort`1.QuickSortInt32.QuickSort(Int32* left, Int32* right, Int64 hint) in /home/dmg/projects/public/QuicksortAvaganza/QuickSortAvaganza/AVX2/Happy/07_AVX2DoublePumpedUnrolledWithPCSort.cs:line 208
at QuickSortAvaganza.AVX2.Happy.AVX2DoublePumpedAlignedOverlapUnrolledWithPCSort`1.QuickSort(T[] array) in /home/dmg/projects/public/QuicksortAvaganza/QuickSortAvaganza/AVX2/Happy/07_AVX2DoublePumpedUnrolledWithPCSort.cs:line 27
at Example.Program.WrappedMain(String typeList, String sizeList, Int32 maxLoops, Int32 modulo, Int32 forceValue, Double forceRate, Boolean noCheck, String statsFile) in /home/dmg/projects/public/QuicksortAvaganza/Example/Program.cs:line 93
at Example.Program.Main(String typeList, String sizeList, Int32 maxLoops, Int32 modulo, Int32 forceValue, Double forceRate, Boolean noCheck, String statsFile) in /home/dmg/projects/public/QuicksortAvaganza/Example/Program.cs:line 49
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.b__0(InvocationContext invocationContext, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass1_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass1_0.b__0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__22_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__22_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass8_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass8_0.b__0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__7_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__7_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__6_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__6_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__20_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__20_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass3_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass3_0.b__0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__23_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__23_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass5_0.<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass5_0.b__0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__4_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__4_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_2.b__3(InvocationContext c)
at System.CommandLine.Invocation.InvocationExtensions.<>c.<b__0_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.<>c.b__0_0(InvocationContext context, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_1.b__2(InvocationContext ctx, Func`2 next)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(IConsole console)
at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, ParseResult parseResult, IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, ParseResult parseResult, IConsole console)
at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, String[] args, IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, String[] args, IConsole console)
at System.CommandLine.DragonFruit.CommandLine.InvokeMethodAsync(String[] args, MethodInfo method, String xmlDocsFilePath, Object target, IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.DragonFruit.CommandLine.InvokeMethodAsync(String[] args, MethodInfo method, String xmlDocsFilePath, Object target, IConsole console)
at System.CommandLine.DragonFruit.CommandLine.ExecuteAssemblyAsync(Assembly entryAssembly, String[] args, String entryPointFullTypeName, String xmlDocsFilePath, IConsole console)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.CommandLine.DragonFruit.CommandLine.ExecuteAssemblyAsync(Assembly entryAssembly, String[] args, String entryPointFullTypeName, String xmlDocsFilePath, IConsole console)
at AutoGeneratedProgram.Main(String[] args) in /home/dmg/projects/public/QuicksortAvaganza/Example/obj/Debug/netcoreapp3.0/Example.Program.g.cs:line 10
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at AutoGeneratedProgram.Main(String[] args)
at AutoGeneratedProgram.(String[] args)
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia riproducendo l'errore di asserzione tramite System.CommandLine.DragonFruit e segui il percorso attraverso CommandLine.InvokeMethodAsync ed ExecuteAssemblyAsync. Esamina come la pipeline di invocazione gestisce le eccezioni e determina quale sia l'output previsto per l'utente; il lavoro è completato quando gli utenti normali non ricevono più il lungo stack trace interno, mentre l'errore rimane diagnosticabile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100