Skip to content

2.9.1 has potential to collide with IEnumerable.CastΒ #820

@kevinms99

Description

@kevinms99

I ran into an issue with CommandLine version 2.9.1. You can see the issue in the code available here:

https://github.com/kevinms99/CommandLineIssue2.9.1

The project above has a compilation issue with version 2.9.1 but has no compilation issue with the previous version 2.8.0.

2.9.1 introduced a new, public extension on the object type via T CommandLine.CastExtensions.Cast<T>(this object obj). I was originally using IEnumerable.Cast<T>(this IEnumerable seq) to cast each element in a sequence to a particular type. However, my particular using setup ended up switching to the CastExtensions class's Cast method, resulting in an unexpected compilation failure.

I can't really classify this as a bug, and I can fix this by simply changing the ordering of my using statements. However, it's generally a little dangerous to publicly expose extension methods on the object type due to the potential for name collisions. I'm unsure whether these extension methods are an expected part of an expanded API set as it wasn't obvious to me what feature the changes are associated with. Perhaps CastExtensions wasn't even meant to be public?

Something to consider as 2.9.1 rolls out to more people.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions