Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private PSMemberInfo GetPropertySet()
EnsureValue1IsNotNull();
Collection<string> value1Collection =
(Collection<string>)GetParameterType(_value1, typeof(Collection<string>));
return new PSPropertySet(_memberName, value1Collection);
return new PSPropertySet(_memberName, (IEnumerable<string>)value1Collection);
}

private PSMemberInfo GetScriptMethod()
Expand Down
18 changes: 18 additions & 0 deletions src/System.Management.Automation/engine/MshMemberInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3455,6 +3455,24 @@ public PSPropertySet(string name, IEnumerable<string> referencedPropertyNames)
}
}

// We mean that 'referencedPropertyNames' does not contain null and empty values,
// otherwise we should use public constructor with the check.
internal PSPropertySet(string name, IList<string> referencedPropertyNames)
{
if (string.IsNullOrEmpty(name))
{
throw PSTraceSource.NewArgumentException(nameof(name));
}

this.name = name;
if (referencedPropertyNames == null)
{
throw PSTraceSource.NewArgumentNullException(nameof(referencedPropertyNames));
}

ReferencedPropertyNames = new Collection<string>(referencedPropertyNames);
}

/// <summary>
/// Gets the property names in this property set.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/System.Management.Automation/engine/TypeTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3135,7 +3135,8 @@ internal static void ProcessPropertySetData(ConcurrentBag<string> errors, string
}

// the node cardinality is OneToMany
Collection<string> referencedProperties = new Collection<string>();
var propList = new List<string>(propertySetData.ReferencedProperties.Count);
Collection<string> referencedProperties = new Collection<string>(propList);
foreach (string name in propertySetData.ReferencedProperties)
{
if (string.IsNullOrEmpty(name))
Expand Down