Skip to content

Generate_Conceptual_Help: Fails if module script file contain advanced types #121

@johlju

Description

@johlju

Details of the scenario you tried and the problem that is occurring

If for example a class-based resource contain a advanced type the task fails to process the conceptual help (this will probably true for Wiki generation as well).

Steps to reproduce the problem

Add the following to the built module script file (.psm1):

class SqlDatabasePermission
{
    hidden [Microsoft.SqlServer.Management.Smo.Server] $sqlServerObject = $null

    # Other code removed for readability
}

Expected behavior

Should be able to handle advanced types that is not loaded.

Current behavior

Throws the error:

ERROR: At C:\source\SqlServerDsc\output\SqlServerDsc\16.0.0\SqlServerDsc.psm1:745 char:13
+     hidden [Microsoft.SqlServer.Management.Smo.Server] $sqlServerObje …
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unable to find type [Microsoft.SqlServer.Management.Smo.Server].
At C:\source\SqlServerDsc\output\RequiredModules\DscResource.DocGenerator\0.11.0\DscResource.DocGenerator.psm1:3085 char:17
+                 throw $parseErrors
+                 ~~~~~~~~~~~~~~~~~~

Suggested solution to the issue

  • Option 1: Replace any advanced types from module script file before parsing. Could be a list of regex in the build configuration that is run on the code before parsing.
  • Option 2: Provide means in the build configuration to load additional stub types or modules necessary to get the correct advanced types into the session.

Personally I prefer option 2.

The operating system the target node is running

n/a

Version and build of PowerShell the target node is running

7.2

Version of the module that was used

0.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions