Skip to content

Incorrect Placement of BOM When Adding Copyright Headers #165

@kinkelpk

Description

@kinkelpk

Issue: Incorrect Placement of BOM When Adding Copyright Headers

Description:

When using Hawkeye to add copyright headers to files encoded in UTF-8 with BOM, the header is added at the very first character of the file.
This results in the BOM being moved behind the header, which can cause issues with file encoding recognition.

Steps to Reproduce:

  1. Create a file encoded in UTF-8 with BOM.
  2. Use Hawkeye to add a copyright header to the file.
  3. Observe the placement of the BOM in the file.

Expected Behavior:
The BOM should remain at the very beginning of the file, with the copyright header added after it.

Actual Behavior:
The BOM is moved behind the copyright header, which can cause encoding issues.

Example:

Original file content:

using System;

namespace Some.Fake.Namespace;

public class SomeFakeClass
{
    public void SomeFakeMethod()
    {
        Console.WriteLine("Hello, World!");
    }
}

Resulting file:

// Copyright (c) 2023
using System;

namespace Some.Fake.Namespace;

public class SomeFakeClass
{
    public void SomeFakeMethod()
    {
        Console.WriteLine("Hello, World!");
    }
}

PR with a demo test in preparation. Will add a link once its there....

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