10000 Filter out compiler generated types for `Add-Type -PassThru` by daxian-dbw · Pull Request #18095 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Filter out compiler generated types for Add-Type -PassThru #18095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2022
Merged
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 @@ -13,6 +13,7 @@
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;
Expand Down Expand Up @@ -891,7 +892,14 @@ private IEnumerable<PortableExecutableReference> GetPortableExecutableReferences

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
Expand Down
0