This file provides guidance to Claude Code when working with code in this repository.
TagLibSharp2 is a clean-room rewrite of media file metadata handling, licensed under MIT.
This is NOT a fork or derivative of TagLib#. Implementations must be based solely on format specifications, not existing code.
dotnet build # Build solution
dotnet test # Run all tests
dotnet test --filter "Name~Id3" # Run specific testsCRITICAL: This project must avoid any GPL/LGPL contamination.
- DO NOT reference TagLib# source code when implementing features
- DO reference official format specifications:
- ID3: https://id3.org/Developer%20Information
- Vorbis: https://xiph.org/vorbis/doc/
- FLAC: https://xiph.org/flac/format.html
- MPEG-4: ISO 14496-12/14
- OK to use TagLib# test files as test inputs (they're just data)
- OK to design similar public APIs (APIs aren't copyrightable)
TagLibSharp2/
├── Core/
│ ├── BinaryData.cs # Immutable binary data with Span<T> support
│ ├── MediaFile.cs # Factory + base class
│ └── Tag.cs # Abstract tag interface
├── Id3/
│ ├── Id3v1Tag.cs # ID3v1 implementation
│ └── Id3v2/
│ ├── Id3v2Tag.cs # ID3v2 container
│ ├── Frame.cs # Base frame
│ └── Frames/ # Frame implementations
├── Xiph/
│ ├── VorbisComment.cs # Vorbis comment block
│ └── FlacFile.cs # FLAC container
└── Properties/
└── MediaProperties.cs # Duration, bitrate, etc.
- Immutable by default: ByteVector and parsed data should be immutable
- Span first: Use
ReadOnlySpan<byte>for parsing, avoid allocations - Async I/O: All file operations should have async variants
- Nullable annotations: Full nullable reference type support
- No exceptions for validation: Use result types for parsing errors
- File-scoped namespaces
- Primary constructors where appropriate
- Expression-bodied members for simple properties
- Pattern matching for type checks
is null/is not null(not== null)
netstandard2.0- Broadest compatibilitynetstandard2.1- Better Span supportnet8.0- LTSnet10.0- Current
- Fixed 128-byte footer at end of file
- Fields: Title(30), Artist(30), Album(30), Year(4), Comment(30), Genre(1)
- ID3v1.1: Last 2 bytes of comment = track number if byte[28]=0
- Header: "ID3" + version(2) + flags(1) + syncsafe size(4)
- v2.3: 4-byte frame IDs, big-endian sizes
- v2.4: 4-byte frame IDs, syncsafe sizes, UTF-8 support
- Magic: "fLaC" (4 bytes)
- Metadata blocks: type(1) + size(3) + data
- Block types: STREAMINFO(0), PADDING(1), APPLICATION(2), SEEKTABLE(3), VORBIS_COMMENT(4), CUESHEET(5), PICTURE(6)
- Vendor string (length-prefixed UTF-8)
- Comment count (32-bit LE)
- Comments: length(4) + "KEY=value" (UTF-8)