8000 Filter out compiler generated types for `Add-Type -PassThru` (#18095) · PowerShell/PowerShell@d0a9147 · GitHub
[go: up one dir, main page]

Skip to content

Commit d0a9147

Browse files
authored
Filter out compiler generated types for Add-Type -PassThru (#18095)
1 parent d702b52 commit d0a9147

File tree

1 file changed

+9
-1
lines changed
  • src/Microsoft.PowerShell.Commands.Utility/commands/utility

1 file changed

+9
-1
lines changed

src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Management.Automation.Internal;
1414
using System.Management.Automation.Security;
1515
using System.Reflection;
16+
using System.Runtime.CompilerServices;
1617
using System.Runtime.Loader;
1718
using System.Security;
1819
using System.Text;
@@ -891,7 +892,14 @@ private IEnumerable<PortableExecutableReference> GetPortableExecutableReferences
891892

892893
private void WriteTypes(Assembly assembly)
893894
{
894-
WriteObject(assembly.GetTypes(), true);
895+
foreach (Type type in assembly.GetTypes())
896+
{
897+
// We only write out types that are not auto-generated by compiler.
898+
if (type.GetCustomAttribute<CompilerGeneratedAttribute>() is null)
899+
{
900+
5A8D WriteObject(type);
901+
}
902+
}
895903
}
896904

897905
#endregion LoadAssembly

0 commit comments

Comments
 (0)
0