Bug Report T753143
Visible to All Users

Code Cleanup – The “Add Copyright header” cleanup applied on save changes the existing copyright header

created 6 years ago

Hey guys,

In our project we want to include copyright headers. Currently only about half of the files have such a header with the company information, the user information and the date of creation of the file. Is it possible for CodeRush to check if there already exists a header and if yes, not overwrite it? Currently my template just creates a new Header and deletes the old header no matter what, which is not what i want.

Cheers

Andri

Comments (3)
DevExpress Support Team 6 years ago

    Hello Andri,

    Thank you for contacting us.

    I couldn't reproduce this issue on my side. Here is a screencast that illustrates my attempts: https://monosnap.com/file/7fsc3ykrtBjF6gxQPK6XfyI9v8rzzc.

    There, you can see that the first expansion of the 'h' template at the top of the file adds the header, while the second expansion does not do anything.

    Please clarify how you create the headers:
    - using the 'h' template;
    - using the "Add Copyright Header" code action (via the Light Bulb menu);
    - using the "Add copyright header" code cleanup rule and running Code CleanUp (via code action or via saving file).

    It would be also helpful if you provide the following information:
    - CodeRush settings (from "%AppData%\CodeRush\Settings");
    - CodeRush log files (from "%LocalAppData%\CodeRush\Logs").

    I look forward to your response.

      Hey Pavel,

      I could reproduce the behaviour you described in your test/video on my machine, this works properly for me. However, i'm using the "Add copyright header" from the code cleanup via saving and not manually. I retested it with older headers and with new headers and it always updates the header.

      Additionally, i implemented a rule, which should convert all var-types to the explicit type (e.g. string). This works somewhat fine, but it adds the fully qualified name for Lists, but not for normal variables.

      Example:

      C#
      var test = new List<string>() { "asdf", "asdf2", "asdf3" }; // gets converted to global::System.Collections.Generic.List<string> test = new List<string> { "asdf", "asdf2", "asdf3" };

      but

      C#
      var test = "asdf";

      is convertet to

      C#
      string test = "asdf";

      when i save. Is there a option in CodeRush i set wrong?

      Thanks for the help

      Andri

      DevExpress Support Team 6 years ago

        Hello Andri,

        Thank you for the clarification and providing the requested information.
        I have reproduced this behavior with the "Add copyright header" cleanup rule.
        We will research this issue and notify you when we make any progress.

        Regarding the issue with the explicit types for local declarations, I've created a separate ticket on your behalf: CodeCleanUp incorrectly generates an explicit type name for the List type.
        It has been placed in our processing queue and will be answered shortly.

        Answers approved by DevExpress Support

        created 6 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Comments (2)

            Hi everybody

            I got the same prob like Andri in the very first post.

            When I save my class, the author of the class is overwritten . If a header already exists, the author should not be overwritten.

            Are there some settings i forgot?

            Visual Studio 2019
            CodeRush V21.2.4

            regards,
            Mario

            DevExpress Support Team 3 years ago

              Hello,

              I created a separate ticket on your behalf: T1050899: Code Cleanup – The “Add Copyright header” cleanup changes the existing copyright header . We placed it in our processing queue and will process it shortly.

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.