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

Exception when displaying ArraySegment with null value #3773

Open
2 of 17 tasks
jianyunliu opened this issue Nov 20, 2024 · 0 comments
Open
2 of 17 tasks

Exception when displaying ArraySegment with null value #3773

jianyunliu opened this issue Nov 20, 2024 · 0 comments
Labels
Area-Formatting Data and object formatting as HTML and plaintext bug Something isn't working

Comments

@jianyunliu
Copy link

Describe the bug

There is exception when displaying ArraySegment with null value. The other enumerable values are just fine with null - like List, byte[] and etc.
This is one code example to repro the issue:

ArraySegment<byte> arraySeg = null;
arraySeg

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.InvalidOperationException: The underlying array is null.
at Microsoft.DotNet.Interactive.Formatting.EnumerableExtensions.TakeAndCountRemaining[T](IEnumerable1 source, Int32 count, Boolean forceCountRemainder) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\EnumerableExtensions.cs:line 17 at Microsoft.DotNet.Interactive.Formatting.PlainTextFormatter.JoinGeneric[T](IEnumerable1 seq, TextWriter writer, FormatContext context) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\PlainTextFormatter.cs:line 350
at InvokeStub_Action3.Invoke(Object, Span1)
at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
--- End of inner exception stack trace ---
at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Microsoft.DotNet.Interactive.Formatting.PlainTextFormatter1.<>c__DisplayClass8_0.<CreateForAnyEnumerable>b__5(T value, FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\PlainTextFormatter{T}.cs:line 103 at Microsoft.DotNet.Interactive.Formatting.PlainTextSummaryFormatter.<>c.<.cctor>b__7_2(IEnumerable obj, FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\PlainTextSummaryFormatter.cs:line 42 at Microsoft.DotNet.Interactive.Formatting.Formatter1.FormatTo(T obj, FormatContext context, String mimeType) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\Formatter{T}.cs:line 68
at lambda_method530(Closure, FormatContext, Object, String)
at Microsoft.DotNet.Interactive.Formatting.Formatter.ToDisplayString(Object obj, String mimeType) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\Formatter.cs:line 277
at Microsoft.DotNet.Interactive.Formatting.HtmlFormatter1.<>c__DisplayClass8_5.<CreateTreeViewFormatterForAnyObject>b__8(FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\HtmlFormatter{T}.cs:line 280 at Microsoft.DotNet.Interactive.Formatting.HtmlTag.WriteTo(FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\HtmlTag.cs:line 103 at Microsoft.DotNet.Interactive.Formatting.PocketView.Write(IReadOnlyList1 args, FormatContext context) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\PocketView.cs:line 220
at Microsoft.DotNet.Interactive.Formatting.PocketView.Write(IReadOnlyList1 args, FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\PocketView.cs:line 216 at Microsoft.DotNet.Interactive.Formatting.PocketView.Write(IReadOnlyList1 args, FormatContext context) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\PocketView.cs:line 216
at Microsoft.DotNet.Interactive.Formatting.PocketView.WriteTo(FormatContext context) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\PocketView.cs:line 283
at Microsoft.DotNet.Interactive.Formatting.HtmlFormatter1.<CreateTreeViewFormatterForAnyObject>g__BuildTreeView|8_3(T source, FormatContext context, ValueTuple2[] rows) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\HtmlFormatter{T}.cs:line 294
at Microsoft.DotNet.Interactive.Formatting.HtmlFormatter1.<>c__DisplayClass8_0.<CreateTreeViewFormatterForAnyObject>b__2(T instance, FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\HtmlFormatter{T}.cs:line 266 at Microsoft.DotNet.Interactive.Formatting.HtmlFormatter1.Format(T value, FormatContext context) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\HtmlFormatter{T}.cs:line 54
at Microsoft.DotNet.Interactive.Formatting.TypeFormatter1.Microsoft.DotNet.Interactive.Formatting.ITypeFormatter.Format(Object instance, FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\TypeFormatter{T}.cs:line 23 at Microsoft.DotNet.Interactive.Formatting.HtmlFormatter1.Format(T value, FormatContext context) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\HtmlFormatter{T}.cs:line 54
at Microsoft.DotNet.Interactive.Formatting.Formatter1.FormatTo(T obj, FormatContext context, String mimeType) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\Formatter{T}.cs:line 68 at lambda_method530(Closure, FormatContext, Object, String) at Microsoft.DotNet.Interactive.Formatting.Formatter.ToDisplayString(Object obj, String mimeType) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\Formatter.cs:line 277 at Microsoft.DotNet.Interactive.FormattedValue.<>c__DisplayClass12_0.<CreateManyFromObject>b__0(String mimeType) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\FormattedValue.cs:line 49 at System.Linq.Enumerable.SelectArrayIterator2.Fill(ReadOnlySpan1 source, Span1 destination, Func2 func) at System.Linq.Enumerable.SelectArrayIterator2.ToArray()
at Microsoft.DotNet.Interactive.FormattedValue.CreateManyFromObject(Object value, String[] mimeTypes) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive\FormattedValue.cs:line 47
at Microsoft.DotNet.Interactive.CSharp.CSharpKernel.Microsoft.DotNet.Interactive.IKernelCommandHandler<Microsoft.DotNet.Interactive.Commands.SubmitCode>.HandleAsync(SubmitCode submitCode, KernelInvocationContext context) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive.CSharp\CSharpKernel.cs:line 339
at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive\Kernel.cs:line 365
at Microsoft.DotNet.Interactive.KernelCommandPipeline.b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 60
at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\a_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 41

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

  • OS
    • Windows 11
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Firefox
    • Safari
  • Frontend
    • Jupyter Notebook
    • Jupyter Lab
    • nteract
    • Visual Studio Code
    • Visual Studio Code Insiders
    • Visual Studio
    • Other (please specify)

Screenshots

Image

@jonsequitur jonsequitur added bug Something isn't working Area-Formatting Data and object formatting as HTML and plaintext labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Formatting Data and object formatting as HTML and plaintext bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants