PowerShell-Docs-DSC icon indicating copy to clipboard operation
PowerShell-Docs-DSC copied to clipboard

Clarify name prefix requirements for classes and enums

Open michaeltlombardi opened this issue 2 years ago • 0 comments

Prerequisites

  • [X] Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • [X] Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in Get-Foo cmdlet" instead of "Typo."
  • [X] Verify Version: If there is a mismatch between documentation and the module on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.

Version

v2.0

Links

  • https://github.com/MicrosoftDocs/PowerShell-Docs-DSC/blob/9a81631df4048e98ed5788d6a10eeb9516d864ea/dsc/docs-conceptual/dsc-2.0/concepts/class-based-resources.md?plain=1#L258
  • https://github.com/MicrosoftDocs/PowerShell-Docs-DSC/blob/9a81631df4048e98ed5788d6a10eeb9516d864ea/dsc/docs-conceptual/dsc-2.0/concepts/class-based-resources.md?plain=1#L309
  • https://github.com/MicrosoftDocs/PowerShell-Docs-DSC/blob/9a81631df4048e98ed5788d6a10eeb9516d864ea/dsc/docs-conceptual/dsc-2.0/concepts/class-based-resources.md?plain=1#L365
  • https://github.com/MicrosoftDocs/PowerShell-Docs-DSC/blob/9a81631df4048e98ed5788d6a10eeb9516d864ea/dsc/docs-conceptual/dsc-2.0/concepts/class-based-resources.md?plain=1#L559-L566
  • https://github.com/MicrosoftDocs/PowerShell-Docs-DSC/blob/9a81631df4048e98ed5788d6a10eeb9516d864ea/dsc/docs-conceptual/dsc-2.0/concepts/class-based-resources.md?plain=1#L794

Summary

If a class or enum is defined with the same name in more than one module, compiling configurations that use both of those modules fails due to the name collision.

Details

We already partially cover this problem for defining the Reasons property for machine configuration:

https://github.com/MicrosoftDocs/PowerShell-Docs-DSC/blob/9a81631df4048e98ed5788d6a10eeb9516d864ea/dsc/docs-conceptual/dsc-2.0/concepts/class-based-resources.md?plain=1#L559-L566

We should generalize this note and advice and surface it wherever it makes sense.

Suggested Fix

We should document this behavior, suggest that authors prefix their enums and classes with their module name, and add name prefixing to the best practices section for the Class-based DSC Resources article.

We may want to add an include that we can use throughout the documentation wherever we're talking about naming classes and enums for use as DSC Resource property types.

michaeltlombardi avatar Apr 05 '23 18:04 michaeltlombardi