PowerShell / DscResource.Tests

Common meta tests for PowerShell DSC resources repositories.
MIT License
51 stars 49 forks source link

Generation of Wikipages throws an error #357

Closed ykuijs closed 4 years ago

ykuijs commented 4 years ago

Details of the problem, bug, or enhancement

When reviewing the AppVeyor log of a PR, I noticed that the WikiPages.ps1 is throwing errors with objects of type Microsoft.Management.Infrastructure.CimType. The code is adding '[]' to the type, but this results in the below error.

Verbose logs showing the problem (if applicable)

Cannot convert value "[]" to type "Microsoft.Management.Infrastructure.CimType". Error: "Unable to match the identifier name [] to a valid enumerator name. Specify one of the following enumerator names and try again:
Unknown, Boolean, UInt8, SInt8, UInt16, SInt16, UInt32, SInt32, UInt64, SInt64, Real32, Real64, Char16, DateTime, String, Reference, Instance, BooleanArray, UInt8Array, SInt8Array, UInt16Array, SInt16Array, UInt32Array, 
SInt32Array, UInt64Array, SInt64Array, Real32Array, Real64Array, Char16Array, DateTimeArray, StringArray, ReferenceArray, InstanceArray"
At C:\projects\sharepointdsc\DscResource.Tests\DscResource.DocumentationHelper\WikiPages.psm1:99 char:21
+                     $dataType += '[]'
+                     ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : SubstringDisambiguationEnumParseThrewAnException

Suggested solution to the issue

??

PlagueHO commented 4 years ago

Hi @ykuijs - I think I can see the problem: The DataType property that is returned by Get-MofSchemaObject is type [Microsoft.Management.Infrastructure.CimType], but we're trying to append a string to it. There is no implict cast to string for this type.

E.g.

$a = [Microsoft.Management.Infrastructure.CimType]::Real64
$a + '[]'

So the code needs to be changed to:

$dataType = $dataType.ToString() + '[]'

I'll submit a PR to correct this.

PlagueHO commented 4 years ago

Should be fixed now @ykuijs - could you check?

ykuijs commented 4 years ago

With the move or SPDsc to the DSC Community org, our AppVeyor tests are broken. So right now I have no possibility to test. We are working on fixing it asap.