tareqimbasher / NetPad

A cross-platform C# editor and playground.
MIT License
1.09k stars 56 forks source link

Rendering exception with HttpQSCollection #217

Closed AlexKeene closed 1 week ago

AlexKeene commented 3 weeks ago

The following code:

System.Collections.Specialized.NameValueCollection qs = System.Web.HttpUtility.ParseQueryString("foo");
qs.Dump();

Raises the following serialization exception when attempting to render the collection:

Could not serialize object to HTML. System.NullReferenceException: Object reference not set to an instance of an object.
   at O2Html.Converters.DotNetTypeWithStringRepresentationHtmlConverter.WriteHtml[T](T obj, Type type, SerializationScope serializationScope, HtmlSerializer htmlSerializer)
   at O2Html.Converters.DotNetTypeWithStringRepresentationHtmlConverter.WriteHtmlWithinTableRow[T](Element tr, T obj, Type type, SerializationScope serializationScope, HtmlSerializer htmlSerializer)
   at O2Html.HtmlSerializer.SerializeWithinTableRow[T](Element tr, T obj, Type type, SerializationScope serializationScope)
   at O2Html.Converters.CollectionHtmlConverter.<>c__DisplayClass3_0`1.<Convert>b__0(Object item, Int32 _)
   at O2Html.Common.Enumerate.Max[T](IEnumerable collection, Nullable`1 max, ProcessEnumeratedItem`1 action)
   at O2Html.Common.Enumerate.Max(IEnumerable collection, Nullable`1 max, ProcessEnumeratedItem`1 action)
   at O2Html.Converters.CollectionHtmlConverter.Convert[T](T obj, Type type, SerializationScope serializationScope, HtmlSerializer htmlSerializer)
   at O2Html.Converters.CollectionHtmlConverter.WriteHtml[T](T obj, Type type, SerializationScope serializationScope, HtmlSerializer htmlSerializer)
   at O2Html.HtmlSerializer.Serialize[T](T obj, Type type, SerializationScope serializationScope)
   at O2Html.HtmlSerializer.Serialize[T](T obj, HtmlSerializerOptions htmlSerializerSettings)
   at NetPad.Presentation.Html.HtmlPresenter.SerializeToElement(Object output, DumpOptions options, Boolean isError)

(v0.7.1)

tareqimbasher commented 3 weeks ago

Cool, thanks for reporting! Will fix in next release.

tareqimbasher commented 1 week ago

222 merged to fix this issue. Will be in next release