Skip to content

Commit

Permalink
Remove dead code (PowerShell#5066)
Browse files Browse the repository at this point in the history
Code guarded by the following defines is ancient and has never been
used, so removing.
* RELATIONSHIP_SUPPORTED
* SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER
* SUPPORTS_CMDLETPROVIDER_FILE
Also removed some unused platform dependent unsafe code.
  • Loading branch information
lzybkr authored and daxian-dbw committed Oct 10, 2017
1 parent 590848c commit 22662c8
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 2,255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,6 @@ public class GetChildItemCommand : CoreCommandBase
private const string childrenSet = "Items";
private const string literalChildrenSet = "LiteralItems";

#if RELATIONSHIP_SUPPORTED
// 2004/11/24-JeffJon - Relationships have been removed from the Exchange release

/// <summary>
/// The string declaration for the -relationship parameter set.
/// </summary>
///
/// <remarks>
/// The "relationship" parameter set includes the following parameters:
/// -relationship
/// -property
/// </remarks>
///
private const string relationshipSet = "Relationship";
#endif
#region Command parameters

/// <summary>
Expand Down Expand Up @@ -214,51 +199,6 @@ public SwitchParameter Name
}
}

#if RELATIONSHIP_SUPPORTED
// 2004/11/24-JeffJon - Relationships have been removed from the Exchange release

/// <summary>
/// Gets and sets the value of the Relationship parameter which determines
/// which relationship the targets should be retrieved for.
/// </summary>
///
[Parameter(
Mandatory = true,
ParameterSetName = relationshipSet,
ValueFromPipelineByPropertyName = true)]
public string[] Relationship
{
get
{
return relationships;
}
set
{
relationships = value;
}
}
private string[] relationships = new string[0];

/// <summary>
/// Gets or sets the property parameter which may provide guidance to the relationship
/// provider on which targets to return.
/// </summary>
///
[Parameter(ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)]
public string Property
{
get
{
return property;
}

set
{
property = value;
}
}
private string property = String.Empty;
#endif
/// <summary>
/// A virtual method for retrieving the dynamic parameters for a cmdlet. Derived cmdlets
/// that require dynamic parameters should override this method and return the
Expand Down Expand Up @@ -302,13 +242,6 @@ internal override object GetDynamicParameters(CmdletProviderContext context)
}
break;

#if RELATIONSHIP_SUPPORTED
// 2004/11/24-JeffJon - Relationships have been removed from the Exchange release

case relationshipSet:
// No possible dynamic parameters for the relationship set.
break;
#endif
default:
result = InvokeProvider.ChildItem.GetChildItemsDynamicParameters(path, Recurse, context);
break;
Expand Down Expand Up @@ -421,63 +354,6 @@ protected override void ProcessRecord()

break;

#if RELATIONSHIP_SUPPORTED
// 2004/11/24-JeffJon - Relationships have been removed from the Exchange release

case relationshipSet:
foreach (string relationship in relationships)
{
Collection<string> results = null;

try
{
results =
InvokeProvider.Relationship.GetTargets(
relationship,
path,
property);
}
catch (PSArgumentException argException)
{
WriteError(
new ErrorRecord(
argException.ErrorRecord,
argException));
continue;
}
catch (ProviderNotFoundException providerNotFound)
{
WriteError(
new ErrorRecord(
providerNotFound.ErrorRecord,
providerNotFound));
continue;
}

foreach (string target in results)
{
// Create an PSObject with the result.
// Attach the relationship name as a note,
// and set "System.Management.Automation.RelationshipTarget"
// as the TreatAs.

PSObject result = PSObject.AsPSObject (target);
result.Properties.Add (
new PSNoteProperty (
"Relationship",
relationship));

Collection<string> treatAs = new Collection<string> ();
treatAs.Add (targetTreatAsType);

result.TypeNames = treatAs;

// Now write out the result
WriteObject (result);
}
}
break;
#endif
default:
Dbg.Diagnostics.Assert(
false,
Expand All @@ -487,11 +363,6 @@ protected override void ProcessRecord()
}
} // ProcessRecord

#if RELATIONSHIP_SUPPORTED
// 2004/11/24-JeffJon - Relationships have been removed from the Exchange release

private const string targetTreatAsType = "System.Management.Automation.RelationshipTarget";
#endif
#endregion command code
} // class GetChildrenCommand
} // namespace Microsoft.PowerShell.Commands
Expand Down
Loading

0 comments on commit 22662c8

Please sign in to comment.