Skip to content

Merging of CodeFiles does not take into account different path separators #773

@cyungmann

Description

@cyungmann

Describe the bug
Perhaps I am missing something, but I believe the Equals(object) implementation in CodeFile.cs does not account for different path separators on different operating systems:

        public override bool Equals(object obj)
        {
            if (obj == null || !obj.GetType().Equals(typeof(CodeFile)))
            {
                return false;
            }
            else
            {
                var codeFile = (CodeFile)obj;
                string fileNameToCompare = codeFile.Path.Substring(codeFile.Path.LastIndexOf('\\') + 1);

                string fileName = this.Path.Substring(this.Path.LastIndexOf('\\') + 1);
                return fileName.Equals(fileNameToCompare, StringComparison.OrdinalIgnoreCase);
            }
        }

I think this is causing different behavior in a build pipeline I am using when run on a Windows build agent vs Linux build agent and merging coverage reports generated on different operating systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions