Extension Methods in Xamarin Workbooks

Viewed 163

I've recently started playing around with Xamarin Workbooks and would like to use it to provide API documentation for some of the things I'm working on.

In one of my first tests however it appears that I can't use extension methods that I've imported via a Nuget package that I created specifically to test this. I can navigate through the namespaces and types provided in the nuget package and call the methods the static way. But not the way I intended; as extension methods.

Is this a bug or missing feature and can I apply a workaround for it in my workbook?

1 Answers

when pasting a static extension class in a workbook and running it, it says error CS1109: Extension methods must be defined in a top level static class; MyExtensions is a nested class

I've noticed that writing (only) the extension methods (so not contained in a static class) directly at the root of a workbook works.

I'm guessing the whole workbook is some sort of a static class itself

enter image description here

Related