Skip to content
Merged
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 @@ -980,7 +980,7 @@ protected override void ProcessRecord()
FormatAndTypeDataHelper.ThrowExceptionOnError("ErrorsUpdatingFormats",
null,
entries,
RunspaceConfigurationCategory.Formats);
FormatAndTypeDataHelper.Category.Formats);
}
}
catch (RuntimeException e)
Expand Down
59 changes: 0 additions & 59 deletions src/System.Management.Automation/engine/CommandDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,6 @@ internal CommandDiscovery(ExecutionContext context)
discoveryTracer.ShowHeaders = false;
}

private void AddCmdletToCache(CmdletConfigurationEntry entry)
{
if (!IsSpecialCmdlet(entry.ImplementingType))
{
CmdletInfo newCmdletInfo = NewCmdletInfo(entry, SessionStateEntryVisibility.Public);
AddCmdletInfoToCache(newCmdletInfo.Name, newCmdletInfo, isGlobal: true);
}
}

/// <summary>
/// Determines if the cmdlet is a cmdlet that shouldn't be in the discovery list.
/// </summary>
Expand All @@ -163,13 +154,6 @@ private bool IsSpecialCmdlet(Type implementingType)
return implementingType == typeof(OutLineOutputCommand) || implementingType == typeof(FormatDefaultCommand);
}

private CmdletInfo NewCmdletInfo(CmdletConfigurationEntry entry, SessionStateEntryVisibility visibility)
{
CmdletInfo ci = new CmdletInfo(entry.Name, entry.ImplementingType, entry.HelpFileName, entry.PSSnapIn, Context);
ci.Visibility = visibility;
return ci;
}

private CmdletInfo NewCmdletInfo(SessionStateCmdletEntry entry)
{
return NewCmdletInfo(entry, Context);
Expand Down Expand Up @@ -1555,49 +1539,6 @@ internal IEnumerator<CmdletInfo> GetCmdletInfo(string cmdletName, bool searchAll
}
} // GetCmdletInfo

/// <summary>
/// Removes a cmdlet from the cmdlet cache.
/// </summary>
/// <param name="entry">
/// The configuration entry for the cmdlet which is being removed.
/// </param>
private void RemoveCmdletFromCache(CmdletConfigurationEntry entry)
{
IDictionary<string, List<CmdletInfo>> cmdletTable = Context.EngineSessionState.GetCmdletTable();
List<CmdletInfo> cacheEntry;
if (cmdletTable.TryGetValue(entry.Name, out cacheEntry))
{
int removalIndex = GetCmdletRemovalIndex(cacheEntry, entry.PSSnapIn == null ? String.Empty : entry.PSSnapIn.Name);

if (removalIndex >= 0)
{
string name = cacheEntry[removalIndex].Name;
cacheEntry.RemoveAt(removalIndex);
Context.EngineSessionState.RemoveCmdlet(name, removalIndex, true);
}

// Remove the entry from the cache if there are no more cmdlets
if (cacheEntry.Count == 0)
{
Context.EngineSessionState.RemoveCmdletEntry(entry.Name, true);
}
}
}

private int GetCmdletRemovalIndex(List<CmdletInfo> cacheEntry, string PSSnapin)
{
int removalIndex = -1;
for (int index = 0; index < cacheEntry.Count; ++index)
{
if (String.Equals(cacheEntry[index].ModuleName, PSSnapin, StringComparison.OrdinalIgnoreCase))
{
removalIndex = index;
break;
}
}
return removalIndex;
}

internal ExecutionContext Context { get; }

internal static PSModuleAutoLoadingPreference GetCommandDiscoveryPreference(ExecutionContext context, VariablePath variablePath, string environmentVariable)
Expand Down
Loading