Open
Description
With the las published packages a lot of big changes in command parsing. This might create issues at runtime.
The interactive extension should update to latest if possible, also adopting the .dib based approach to install extension is advised, the interface based discovery is not ideal and introduces more issues, this extension could be built without dependencies on .NET Interactive by using convention based formatting and .dib to load the extension.
Activity
kMutagene commentedon Nov 13, 2024
Thanks for the heads-up.
It must stop being its own package though if i understand the docs correctly, because there has to be an attribute on the type that gets the custom formatting, the formatting code must be in the source of the core lib?
jonsequitur commentedon Nov 13, 2024
The extension isn't currently broken as far as I can tell.
jonsequitur commentedon Nov 13, 2024
As long as the only notebook behavior you want to customize is formatting (which appears to be the case with Plotly.NET), you don't need a separate assembly or a separate package at all, nor do you need to embed a
.dib
file to register formatters. You can follow the convention-basedTypeFormatterSourceAttribute
approach, remove the dependency on .NET Interactive libraries entirely, and therefore remove future version incompatibility problems.You can see examples of this approach here.
kMutagene commentedon Nov 14, 2024
@jonsequitur That's what i was thinking, thanks. I'll look into it
jonsequitur commentedon Nov 14, 2024
Let me know if you want a hand or if you have feedback on the approach. And if you want to contribute F# sample code to document the convention-based approach, I'm sure others would find it helpful.
#476: First try at no-deps interactive formatting
kMutagene commentedon Jan 13, 2025
@jonsequitur I finally had a first go at this, and I'd love some guidance on how to actually test this. I have implemented the (I think) equivalents of the no-dependency attribute-based formatting shown for C# in your linked docs:
Plotly.NET/src/Plotly.NET/InternalUtils.fs
Lines 134 to 142 in ffe000b
Plotly.NET/src/Plotly.NET/ChartAPI/GenericChart.fs
Lines 592 to 608 in ffe000b
but no formatting is applied in the notebook i test this in, and now i am not sure how to proceed/troubleshoot.
jonsequitur commentedon Jan 13, 2025
As far as I can see the code looks correct. Have you confirmed that the formatter source is being called at all?
Here's an example test. There's no F# equivalent but adding one in this project might surface a bug.
kMutagene commentedon Jan 22, 2025
@jonsequitur I tried to isolate the issue more and ported that test, however it just tests if the formatted string is correct, which we already know that it is not. How can i dig deeper and test whether the custom attribute is detected correctly?
For reference, here is the (failing) test
jonsequitur commentedon Jan 22, 2025
If you can hit a breakpoint in the custom formatter source when it returns your formatter, then it's being detected correctly. If you can set a breakpoint in the custom formatter, then it's being recognized as valid for the type and MIME type you're requesting in your example code.
The easiest way to debug your code is to load a locally-built package and before you run any code in the notebook that would trigger loading of the formatter (which will happen lazily when it first sees a given type), run this:
System.Diagnostics.Debugger.Launch() ```