Skip to content

Commit

Permalink
Formatter self registration and tabular data improvements (#1346)
Browse files Browse the repository at this point in the history
* use FormatContext for formatter recursion counting

* dispose writer when FormatContext owns it

* add constructor for delegate that returns string, for parity with PlainTextFormatter<T>

* ITypeFormatterSource / TypeFormatterSourceAttribute

* refactor tabular data, add a lazy formatter for it

* allow first field to be null and still correctly infer tabular data column type; misc refactoring
  • Loading branch information
jonsequitur authored May 27, 2021
1 parent fcf8357 commit f1a4b9a
Show file tree
Hide file tree
Showing 71 changed files with 1,006 additions and 791 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ Generated\ Files/
*.VisualState.xml
TestResult.xml

# Assent / ApprovalTests
*.received.json

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
Expand Down
1 change: 0 additions & 1 deletion dotnet-interactive.v3.ncrunchsolution
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<SolutionConfiguration>
<Settings>
<AllowParallelTestExecution>True</AllowParallelTestExecution>
<SolutionConfigured>True</SolutionConfigured>
</Settings>
</SolutionConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using Microsoft.Data.Analysis;
using Microsoft.DotNet.Interactive.Formatting;

using Microsoft.DotNet.Interactive.Formatting.TabularData;
using Xunit;

namespace Microsoft.DotNet.Interactive.ExtensionLab.Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.DotNet.Interactive.CSharp;
using Microsoft.DotNet.Interactive.ExtensionLab;
using Microsoft.DotNet.Interactive.Formatting;
using Microsoft.DotNet.Interactive.Formatting.TabularData;
using Microsoft.ML;

namespace Microsoft.DotNet.Interactive.ExtensionLab
Expand Down Expand Up @@ -217,7 +218,7 @@ public static TabularDataResource ToTabularDataResource(this IDataView source)
public static TabularDataResourceJsonString ToTabularJsonString(this IDataView source)
{
var tabularDataResource = source.ToTabularDataResource();
return tabularDataResource.ToJson();
return tabularDataResource.ToJsonString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text;
using Microsoft.AspNetCore.Html;
using Microsoft.DotNet.Interactive.Formatting;
using Microsoft.DotNet.Interactive.Formatting.TabularData;
using Microsoft.DotNet.Interactive.Http;

namespace Microsoft.DotNet.Interactive.ExtensionLab
Expand Down Expand Up @@ -41,7 +42,7 @@ protected override IHtmlContent ToHtml()
{
var requireUri = new Uri("https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js");
var divId = Id;
var data = Data.ToJson();
var data = Data.ToJsonString();
var code = new StringBuilder();
var functionName = $"renderNteractDataExplorer_{divId}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive.Commands;
using Microsoft.DotNet.Interactive.Formatting;
using Microsoft.DotNet.Interactive.Formatting.TabularData;
using Enumerable = System.Linq.Enumerable;

namespace Microsoft.DotNet.Interactive.ExtensionLab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Text;
using Microsoft.AspNetCore.Html;
using Microsoft.DotNet.Interactive.Formatting;
using Microsoft.DotNet.Interactive.Formatting.TabularData;
using Microsoft.DotNet.Interactive.Http;

namespace Microsoft.DotNet.Interactive.ExtensionLab
Expand Down Expand Up @@ -41,7 +41,7 @@ protected override IHtmlContent ToHtml()
{
var requireUri = new Uri("https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js");
var divId = Id;
var data = Data.ToJson();
var data = Data.ToJsonString();
var code = new StringBuilder();
var functionName = $"renderSandDanceExplorer_{divId}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using Microsoft.DotNet.Interactive.ExtensionLab;
using Microsoft.DotNet.Interactive.Formatting;
using Microsoft.DotNet.Interactive.Formatting.TabularData;

namespace System.Collections.Generic
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


using Microsoft.DotNet.Interactive.ExtensionLab;
using Microsoft.DotNet.Interactive.Formatting.TabularData;

namespace Microsoft.DotNet.Interactive.Formatting
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Interactive.Formatting.Tests
{
public abstract class FormatterTestBase : IDisposable
{
private static readonly object _lock = new object();
private static readonly object _lock = new();

protected FormatterTestBase()
{
Expand Down
Loading

0 comments on commit f1a4b9a

Please sign in to comment.