diff --git a/NTFSSecurity/ParameterConversion.cs b/NTFSSecurity/ParameterConversion.cs index e6a4a01..dc45ed5 100644 --- a/NTFSSecurity/ParameterConversion.cs +++ b/NTFSSecurity/ParameterConversion.cs @@ -154,7 +154,7 @@ namespace NTFSSecurity // The value as a message names it: a collection of one element by that element (also when it is a collection // itself), a collection of several elements by its first ten, anything else by its text. The message is built // inside a catch block, so this method must not fail whatever the text or the enumeration of a value does; a - // value that cannot be formatted is named by its type. + // value that cannot be formatted is named by its type, in the short form of Type.ToString. private static string Describe(object value) { try @@ -164,7 +164,7 @@ namespace NTFSSecurity catch (Exception) { var unwrapped = value is PSObject ? ((PSObject)value).BaseObject : value; - return unwrapped == null ? string.Empty : unwrapped.GetType().FullName; + return unwrapped == null ? string.Empty : unwrapped.GetType().ToString(); } } diff --git a/Tests/ParameterSets.Access.Tests.ps1 b/Tests/ParameterSets.Access.Tests.ps1 index 5693ee4..8136b65 100644 --- a/Tests/ParameterSets.Access.Tests.ps1 +++ b/Tests/ParameterSets.Access.Tests.ps1 @@ -1404,12 +1404,15 @@ Describe 'Invalid and valid values of AccessType, InheritanceFlags, PropagationF } # The message names a list by its first ten elements: ten are named in full, eleven end with an ellipsis. The - # elements of a flags parameter are converted one by one, so these numbers fail there too (4 is not a flag). + # elements of a flags parameter are converted one by one, so these numbers fail there too (4 is not a flag). A + # value whose text cannot be built is named by its type, in the short form that Type.ToString gives. $accessInvalidParameterCases += @( @{ Cmdlet = 'Add-NTFSAccess'; Parameter = 'AccessType'; Shape = 'ten numbers'; Value = 1..10; ValueText = '1, 2, 3, 4, 5, 6, 7, 8, 9, 10' } @{ Cmdlet = 'Add-NTFSAccess'; Parameter = 'AccessType'; Shape = 'eleven numbers'; Value = 1..11; ValueText = '1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...' } @{ Cmdlet = 'Add-NTFSAccess'; Parameter = 'InheritanceFlags'; Shape = 'ten numbers'; Value = 1..10; ValueText = '1, 2, 3, 4, 5, 6, 7, 8, 9, 10' } @{ Cmdlet = 'Add-NTFSAccess'; Parameter = 'InheritanceFlags'; Shape = 'eleven numbers'; Value = 1..11; ValueText = '1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...' } + @{ Cmdlet = 'Add-NTFSAccess'; Parameter = 'AccessType'; Shape = 'a generic list of one object whose ToString throws'; Value = [System.Collections.Generic.List[object]]::new([object[]] @($accessThrowingElement)); ValueText = 'System.Collections.Generic.List`1[System.Object]' } + @{ Cmdlet = 'Add-NTFSAccess'; Parameter = 'InheritanceFlags'; Shape = 'a generic list of one object whose ToString throws'; Value = [System.Collections.Generic.List[object]]::new([object[]] @($accessThrowingElement)); ValueText = 'System.Collections.Generic.List`1[System.Object]' } ) $accessSdInvalidParameterCases = foreach ($cmdlet in 'Add-NTFSAccess', 'Remove-NTFSAccess') {