From 5bd7ef897381b7a284b1f45a55e1e97a03844ff9 Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Tue, 13 Aug 2024 19:19:06 +0100 Subject: [PATCH] `Get-ClassResourceProperty` - Check for prefixed and non-prefixed class names (#152) --- CHANGELOG.md | 5 +++++ azure-pipelines.yml | 2 +- source/Private/Get-ClassResourceProperty.ps1 | 22 +++++++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6042fa5..2ac12ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- `Get-ClassResourceProperty` + - Check for a prefixed and non-prefixed class names [issue #132](https://github.com/dsccommunity/DscResource.DocGenerator/issues/132). +- `azure-pipelines` + - Pin gitversion to V5. + ## [0.12.4] - 2024-06-03 ### Fixed diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 595e4a7..977ccd8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,7 @@ stages: vmImage: 'ubuntu-latest' steps: - pwsh: | - dotnet tool install --global GitVersion.Tool + dotnet tool install --global GitVersion.Tool --version 5.* $gitVersionObject = dotnet-gitversion | ConvertFrom-Json $gitVersionObject.PSObject.Properties.ForEach{ Write-Host -Object "Setting Task Variable '$($_.Name)' with value '$($_.Value)'." diff --git a/source/Private/Get-ClassResourceProperty.ps1 b/source/Private/Get-ClassResourceProperty.ps1 index 7e35f81..589fb7e 100644 --- a/source/Private/Get-ClassResourceProperty.ps1 +++ b/source/Private/Get-ClassResourceProperty.ps1 @@ -44,13 +44,29 @@ function Get-ClassResourceProperty { $dscResourceAst = Get-ClassAst -ClassName $currentClassName -ScriptFile $BuiltModuleScriptFilePath - $sourceFilePath = Join-Path -Path $SourcePath -ChildPath ('Classes/???.{0}.ps1' -f $currentClassName) + $classExists = $false + $sourceFilePath = '' + $childPaths = @( + ('Classes/???.{0}.ps1' -f $currentClassName) + ('Classes/{0}.ps1' -f $currentClassName) + ) + + foreach ($childPath in $childPaths) + { + $sourceFilePath = Join-Path -Path $SourcePath -ChildPath $childPath + + if ((Test-Path -Path $sourceFilePath)) + { + $classExists = $true + break + } + } <# - Skip if the class's source file does not exist. Thi can happen if the + Skip if the class's source file does not exist. This can happen if the class uses a parent class from a different module. #> - if (-not (Test-Path -Path $sourceFilePath)) + if (-not $classExists) { continue }