Skip to content

Format-* cmdlets: Centralize ExcludeProperty filter application in ViewGenerator #26568

@yotsuda

Description

@yotsuda

Summary of the new feature / enhancement

#26514 introduced the -ExcludeProperty parameter to Format-Table/List/Wide/Custom. The implementation requires calling ApplyExcludePropertyFilter() at different locations depending on the ViewGenerator class:

ViewGenerator Call Location
Table End of Initialize()
List End of SetUpActiveProperties() (called from Initialize())
Wide End of SetUpActiveProperty() (called lazily from GeneratePayload())
Complex Filters locally within DisplayObject() (doesn't use base class method)

This works correctly, but has maintainability concerns:

  1. Future implementations: New ViewGenerator subclasses must remember to call the filter method at the right place
  2. Discoverability: It's not obvious from the base class that this step is required
  3. Scattered call sites: The filter is applied in different methods depending on the subclass

A centralized approach would make the code more maintainable and less error-prone.

Proposed technical implementation details (optional)

The main challenge is that activeAssociationList is built at different times:

  • Table/List: During Initialize()
  • Wide: Lazily during GeneratePayload()
  • Complex: Uses a local variable instead of the base class member

This timing difference makes simple centralization non-trivial. Further investigation is needed to determine the best approach.

Related: #26514

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Engine-Format

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions