none
Automatically Rename Dependent Files RRS feed

  • Question

  • So,

    I've got the extensibility to now Create the items from a template as I desire, and I even have an editor for when i double click on the item.

    The primary item is a dmxml file that contains meta-data used to generate the Designer.cs file.  I also include a one-time generated .cs file filled with the partial classes for user modified code elements.  Overrides from base classes, implementing other interfaces, you name it.

    I discovered however that when I rename the .dmxml file, the .cs and .Designer.cs files do not rename as well.  This normally wouldn't be a problem but as dependent files i cannot manually rename them in solution explorer, so I'd have to rename them in explorer and edit the csproj file, or remove/add the renamed files.

    How can i fix this?

    csproj xml:

        <Compile Include="Classes\ExcelSubscriber.cs">
          <DependentUpon>ExcelSubscriber.dmxml</DependentUpon>
        </Compile>
        <Compile Include="Classes\ExcelSubscriber.Designer.cs">
          <DependentUpon>ExcelSubscriber.dmxml</DependentUpon>
        </Compile>
        <None Include="Classes\ExcelSubscriber.dmxml">
          <SubType>Designer</SubType>
        </None>

    Solution View:

    Thanks

    Jaeden "Sifo Dyas" al'Raec Ruiner


    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.



    Wednesday, May 15, 2019 10:00 PM

All replies

  • Hi friend,

    Welcome to MSDN forum.

    I understand your meaning. But after my research, maybe you need to write some more code for listening to Rename event and do the actions you need.

    I create structure like below:

    When renaming Test.xaml, the Test.xaml.CS will be renamed after that. But for ExcelSubscriber.dmxml, this custom one, no such function. So I check the .csproj file and find the difference between them.

    For ExcelSubscriber.dmxml: <None Include="ExcelSubscriber.dmxml" />

    For xxx.xaml: 

    <EmbeddedResource Include="Test.xaml">
          <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    </EmbeddedResource>

    I've searched what MSBuild:UpdateDesignTimeXaml mean and find this, the XAMarin adds the MSBuild Task to support the update of .xaml. But for the custom .dmxml, I think we need to write code to achieve this goal.

    If I misunderstand anything, please feel free to correct me!

    And maybe you can get some help from links below:

    How to notify the editor about document changes

    Visual Studio SDK - Handling File Add, Remove, and Rename Events

    Best Regards

    Lance


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.




    Friday, May 17, 2019 10:06 AM
  • That is generally helpful, telling me which interfaces to use.

    However it doesn't tell me where to put them.

    Currently my generator is not registered as a User CustomToo (generator)l.  (I will get to that eventually) once i finish mapping my editor to a WindowPan, IVsPersistDocData, and IVsEditorFactory. 

    So, would i listen to the IVsHierarchyEvents or IVsSolutionEvents3 in the Generator?  In the Editory? 

    where do i put this code to handle the renaming of dependent files.

    Thanks

    Jaeden "Sifo Dyas"al'Raec Ruiner


    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.

    Sunday, May 19, 2019 6:24 AM
  • Hi friend,

    Do you have more than one projects for your extension? One for Item Template and another for Extension editor?

    If so, maybe you can put the code in your editor extension project. Let the extension to listen to the rename event and do some actions. I think there must be much better way but sorry for that I have't figure it out.

    Best Regards

    Lance


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 21, 2019 9:23 AM