Skip to content

Custom file type registration example in README does not match the public API #57

Description

@Vladipz

The “Custom File Type Registration” example in the README does not compile against the current File.TypeChecker package (4.4.0).

The example uses:

public override string Name => "...";
public override string Extension => "...";
public override string MimeType => "...";
public override bool IsMatch(byte[] signature, Stream stream) => ...;

FileTypeValidator.RegisterType<MyCustomType>();
However, in the current API:
- FileType.Name, Extension, and MimeType are not virtual.
- FileType requires values through its protected constructor.
- IsMatch(...) does not exist.
- FileTypeValidator.RegisterType<T>() does not exist.
The documented approach that compiles is:
using FileTypeChecker;
using FileTypeChecker.Abstracts;

public sealed class MyCustomType : FileType
{
    public MyCustomType()
        : base(
            "My Custom Format",
            "application/x-mycustom",
            "mycustom",
            [0x4D, 0x59, 0x43, 0x54])
    {
    }
}

FileTypeValidator.RegisterCustomTypes(typeof(MyCustomType).Assembly);
Could the README be updated to match the public API, or could the documented API be restored?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions