Skip to content

Python Tools adding Licenseheader to file in folder throws InvalidOperationException #40

@FlorianDecker

Description

@FlorianDecker

When trying to add an Licenseheader to a .py file in a Folder in a Python Tools Project, an InvalidOperationException gets thrown with Error message "Operation is not valid due to the current state of the object":
capture

This is due to us trying to access projectItem.Collection. Collection is not implemented by Python Tools in OAFileItem. While the Base class provides an implementation for the root directory, it throws an InvalidOperationException in other cases (see Base Class Implementation, Line 157: https://github.com/Microsoft/PTVS/blob/master/Common/Product/SharedProject/Automation/OAProjectItem.cs ).

This can be fixed by accessing the Parent "Microsoft.VisualStudioTools.Project.Automation.OAFileItem" via the supplied object with reflection - the same fashion as #36 .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions