Skip to content

New-AzureRmVm/VMSS: verbose parameter output. #5933

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

Merged
merged 12 commits into from
Apr 24, 2018
Merged

New-AzureRmVm/VMSS: verbose parameter output. #5933

merged 12 commits into from
Apr 24, 2018

Conversation

sergey-shandar
Copy link
Contributor

@sergey-shandar sergey-shandar commented Apr 11, 2018

Description

#5650

Known issues:

Checklist

@sergey-shandar sergey-shandar changed the title New-AzureRmVm/VMSS: verbose parameter output. [Don't merge yet] New-AzureRmVm/VMSS: verbose parameter output. Apr 11, 2018
@sergey-shandar sergey-shandar changed the title [Don't merge yet] New-AzureRmVm/VMSS: verbose parameter output. New-AzureRmVm/VMSS: verbose parameter output. Apr 11, 2018
This was referenced Apr 18, 2018
return typeof(T)
.GetProperties()
.Where(p => p
.GetCustomAttributes(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

we should check for null here, what if there is a random class property that does not have any custom attributes... will the code here throw a null ptr exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.Where(p => p
.GetCustomAttributes(false)
.OfType<ParameterAttribute>()
.Any(a => a.ParameterSetName == psName))
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've a fix. I'm going to push it soon.

{
return string.Join(",", e.Cast<object>().Select(ToPowerShellString));
}
return value.ToString();
Copy link
Contributor

Choose a reason for hiding this comment

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

so for this, if the type of the parameter (specifically for custom defined classes) does not implement a ToString() this would just print out the object type instead of a string representation of the data in the object? Do we want to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if we don't know the type we use object.ToString() function. This's also default PowerShell behavior.

@praries880
Copy link
Contributor

Want about adding unit tests for this scenario?

@sergey-shandar
Copy link
Contributor Author

@praries880 I'm going to introduce unit tests in #5972 where the code is used in a generic Strategy library.

praries880
praries880 previously approved these changes Apr 20, 2018
{
_Cmdlet = cmdlet;
}

public bool WhatIf
Copy link
Member

Choose a reason for hiding this comment

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

@sergey-shandar As we have discussed, this is an anti-pattern, we should not print additional information based on our own setting of WhatIf - WhatIf should be handled automaticsally by the PowerShell runtime. Additional information printed in WhatIf should use only ShouldProcess prompts.

Verbose output should simply be written to the verbose stream - we cna log such output to the Verbose or Debug streams, depending on the level of information (verbose versus debug/very verbose)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@markcowl Good catch! I forgot to remove the property. Note: the property was not used anyway, so the behavior is still the same: the cmdlet doesn't relay on the WhatIf parameter.

@markcowl
Copy link
Member

@markcowl markcowl removed their assignment Apr 24, 2018
@cormacpayne cormacpayne merged commit 2ef14aa into Azure:preview Apr 24, 2018
@sergey-shandar sergey-shandar deleted the sergey-whatif branch April 24, 2018 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants