Is it possible to have class based DSC resource in separate file

Currently for my modules I store actual code in separate file from psm file, then dot source it and use Export-ModuleMember to export Functions, this way it allows me easily debug/test individual functions.
I assume it’s not possible since Export-ModuleMember does not give an option to export DSCResource but is it possible to have similar setup for class based DSC Resources?

Mmmmyyeessss. Sort of.

Your class itself has to be one file. But the class can simply call regular functions, from a module, to perform whatever tasks it needs to perform. That keeps the code in the class itself very minimal, and is actually considered by some (including me) to be a good design pattern.

That said, I’m not necessarily a huge fan of your module approach. I just don’t like dot-sourcing - it’s a very informal inclusion. I’m usually fine keeping related functions together in a .psm1; if I need to test or debug one, it’s easy enough to just copy and paste it out, do what I need, and then update my module.

So personally, my Resource approach would be to have a normal .psm1 module, with its own manifest (I rely on manifests more than Export-ModuleMember, because manifests create several advantages elsewhere in the shell), and that would do all the heavy lifting for my resource. I could then write a traditional function-based resource or a class-based resource, which simply called on the heavy-lifting functions to do all the work. I regard the resource itself (class or function-based) as an “interface” and I like to keep as little code in there as possible.

Given the current lack of versioning support in classes, I’ve been sticking with function-based resources. Once that issue is addressed, it’ll be easy to switch my resources, since there’s essentially no code in them.