Open gaelcolas opened 5 years ago
Those wanting to create class-based resource should be able to do so if there are no problems mixing mof-based and class-based. This repo could be made the proof of that.
The main reason that I personally don't go for class-based resource is that when running the unit test locally one have to start a new session for each run. I think this is solved in PS Core, but not Windows PowerShell. I personally don't see that class-based resource give any benefit (other than the code are written a bit different). But when can use DSC in PS Core then I want to be able to all in with class-based resource, or maybe by then there is a third alternative to writing DSC resources. 😄
My preference is also to write MOF-based DSC resources, but I think we should not force our old ways if it's just personal preferences. ;)
Yes you can mix both Class & MOF based, there's a slight formatting issue on the MSFT docs that I need to submit a fix for: here's a better illustration.
Creating the MOF is adding extra complexity that new-comers could avoid, and some would-be-contributors might just be more familiar with the Class paradigm than PowerShell Advanced Functions.
I know a few organisations that have been writing Class based DSC Resources, so we should illustrate how to do it here, although that's probably going on the back burner. We should have a standard they could adhere to so that eventually they can contribute to the Resource Kit, and we can test against.
I'm not sure I remember the testing issue you mention. I can see when you dot source a class, but here you would do InModuleScope
right?
Nope, we should not force it because of personal preference. ;)
Here the problem of testing class-based resource https://github.com/pester/Pester/issues/797. I have not tested for a while, so it can be resolved in latest Windows PowerShell.
Well, if we want to try this out and see what bubbles up, maybe migrating WmiNamespaceSecurity to ComputerManagementDsc is one way to check this out. However, ComputerManagementDsc is Auto-documentation and I'm fairly sure the Auto-documentation code would need to be updated to support Class based resources (do-able I'm sure). But that might be the opportunity to start identifying these challenges.
See, that's a great conversation to have. I innocently thought it wouldn't be too bad, and here's a list of dependencies ;) Not urgent, but it's great to see what problem are needed to solve that issue.
As per PowerShell/DscResources#467 I can imagine that's a common question that could be clarified here.
Opening the discussion...