Skip to content

Commit

Permalink
Revert "Throw error on entering non-existing type in Get-FormatData (P…
Browse files Browse the repository at this point in the history
…owerShell#7434)"

This reverts commit b754cd8.
  • Loading branch information
TravisEz13 committed Aug 16, 2018
1 parent 01634e4 commit 075bf72
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Internal;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Management.Automation.Runspaces;
using Microsoft.PowerShell.Commands.Internal.Format;

Expand Down Expand Up @@ -168,40 +167,29 @@ protected override void ProcessRecord()
typedefs.Add(consolidatedTypeName, viewList);
}
viewList.Add(formatdef);
}
}// foreach(ViewDefinition...

if (typedefs.Count == 0)
// write out all the available type definitions
foreach (var pair in typedefs)
{
ErrorRecord errorRecord = new ErrorRecord(
new TypeLoadException(StringUtil.Format(GetFormatDataStrings.SpecifiedTypeNotFound, _typename)),
"SpecifiedTypeNotFound",
ErrorCategory.InvalidOperation,
_typename);
WriteError(errorRecord);
}
else
{
foreach (var pair in typedefs)
{
var typeNames = pair.Key;
var typeNames = pair.Key;

if (writeOldWay)
if (writeOldWay)
{
foreach (var typeName in typeNames)
{
foreach (var typeName in typeNames)
{
var etd = new ExtendedTypeDefinition(typeName, pair.Value);
WriteObject(etd);
}
var etd = new ExtendedTypeDefinition(typeName, pair.Value);
WriteObject(etd);
}
else
}
else
{
var etd = new ExtendedTypeDefinition(typeNames[0], pair.Value);
for (int i = 1; i < typeNames.Count; i++)
{
var etd = new ExtendedTypeDefinition(typeNames[0], pair.Value);
for (int i = 1; i < typeNames.Count; i++)
{
etd.TypeNames.Add(typeNames[i]);
}
WriteObject(etd);
etd.TypeNames.Add(typeNames[i]);
}
WriteObject(etd);
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

Describe "Get-FormatData" -Tags "CI" {

Context "Check return type of Get-FormatData" {
Expand All @@ -10,11 +9,4 @@ Describe "Get-FormatData" -Tags "CI" {
,$result | Should -BeOfType "System.Object[]"
}
}

Context "Check for error on invalid type as argument" {

It "Should throw error on invalid type as argument" {
{ Get-FormatData "NoSuch.Type.Exists.Or.IsLoaded" -ErrorAction Stop } | Should -Throw -ErrorId "SpecifiedTypeNotFound,Microsoft.PowerShell.Commands.GetFormatDataCommand"
}
}
}

0 comments on commit 075bf72

Please sign in to comment.