Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ArgumentNullException when Generating without docs -NoDocs switch #711

Merged
merged 2 commits into from
Nov 20, 2020
Merged

Fix ArgumentNullException when Generating without docs -NoDocs switch #711

merged 2 commits into from
Nov 20, 2020

Conversation

georgend
Copy link
Contributor

Currently the code path below, throws ArgumentNullException when Export-ProxyCmdlet is invoked in the -NoDocs code path.

if($NoDocs) {
Write-Host -ForegroundColor Green 'Creating exports...'
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs
} else {
Write-Host -ForegroundColor Green 'Creating exports and docs...'
$moduleDescription = '${$project.metadata.description}'
$docsFolder = Join-Path $PSScriptRoot '${$lib.path.relative($project.baseFolder, $project.docsFolder)}'
if(Test-Path $docsFolder) {
$null = Get-ChildItem -Path $docsFolder -Recurse -Exclude 'readme.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue
}
$null = New-Item -ItemType Directory -Force -Path $docsFolder
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ModuleDescription $moduleDescription -DocsFolder $docsFolder -ExamplesFolder $examplesFolder -ModuleGuid $guid

Exception is thrown here at Path.Combine, since ExamplesFolder will be null.
var examplesFolder = isValidProfile ? Path.Combine(ExamplesFolder, variantGroup.ProfileName) : ExamplesFolder;

Solution
Allow ExamplesFolder to be passed along for all param sets, since examples are already always generated. (Example Stubs).

[Parameter(Mandatory = true, ParameterSetName = "Docs")]
[ValidateNotNullOrEmpty]
public string ExamplesFolder { get; set; }

Pass along -ExamplesFolder since its required in all code paths.

George Ndungu added 2 commits November 18, 2020 16:10
…ures.

Pass along `-ExamplesFolder` since its required in all code paths.
@georgend georgend marked this pull request as ready for review November 18, 2020 13:17
@dolauli
Copy link
Contributor

dolauli commented Nov 19, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

@dolauli dolauli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@dolauli dolauli merged commit 808c16f into Azure:master Nov 20, 2020
dolauli pushed a commit to dolauli/autorest.powershell that referenced this pull request Nov 23, 2020
…ch (Azure#711)

* Fix ArgumentNullException when Generating without docs `-NoDocs` features.
Pass along `-ExamplesFolder` since its required in all code paths.

* Make examples mandatory, for all paramsets

Co-authored-by: George Ndungu <[email protected]>
dolauli added a commit that referenced this pull request Nov 23, 2020
…ch (#711) (#712)

* Fix ArgumentNullException when Generating without docs `-NoDocs` features.
Pass along `-ExamplesFolder` since its required in all code paths.

* Make examples mandatory, for all paramsets

Co-authored-by: George Ndungu <[email protected]>

Co-authored-by: George <[email protected]>
Co-authored-by: George Ndungu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants