mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Filter out compiler generated types for Add-Type -PassThru (#18095)
This commit is contained in:
1 parent
d702b52168
commit
d0a91470c9
1 file changed
+9
-1
@@ -13,6 +13,7 @@ using System.Management.Automation;
|
||||
using System.Management.Automation.Internal;
|
||||
using System.Management.Automation.Security;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Loader;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
@@ -891,7 +892,14 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
private void WriteTypes(Assembly assembly)
|
||||
{
|
||||
WriteObject(assembly.GetTypes(), true);
|
||||
foreach (Type type in assembly.GetTypes())
|
||||
{
|
||||
// We only write out types that are not auto-generated by compiler.
|
||||
if (type.GetCustomAttribute<CompilerGeneratedAttribute>() is null)
|
||||
{
|
||||
WriteObject(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion LoadAssembly
|
||||
|
||||
Reference in new issue
Block a user