-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Rename classes to allow import of multiple namespaces without ambiguous symbols #110
Comments
On a related note (for v3 ideas) I have some questions about the existing design. Though I see that a lot of the code dates from 2002-2005 which predates .NET 2.0 and C# 2.0 and many things we take for granted now like Generics and Extension methods. If we adopted them into the library then we can make it more .NET-idiomatic and future-proof with new versions of .NET Standard.
|
For the namespace/class naming, it is indeed an unusual way to do it, and you are not the first user to complain about this. I was myself a bit surprised by this approach when I first tried this library. However, if you do not use the
I do agree that using the standard types and generics would be an improvement.
To be fair, I advocate the opposite approach, that we could develop code for a |
(I searched previous Issues in GitHub to see if anyone raised this point, I couldn't see anything)
(I'm aware the docs say the v2.0 API is stable, so this is a proposal for version 3)
I used TagLib-Sharp to write my utility program TeslaTags - thank you for this library!, but while using the library I experienced a number of ergonomic issues with TagLib, such as how class names are reused in child namespaces when they're used to represent subclasses, which shouldn't be done because it means we need to use C# in a non-idiomatic way - such as aliasing types (
using MpegFile = TagLib.Mpeg.File
) or using Go-style package/namespace prefixes (e.g.using mpeg = TagLib.Mpeg; .. mpeg.AudioFile mp3 = mpeg.AudioFile.Create(...
).Another issue is a conflict with
System.IO
that frequently occurrs because TagLib is invariably used to work with files and some of the type-names conflict (namely all of theFile
classes in TagLib, I can't use it "naked" in the same context asSystem.IO.File
) so I end up needing to alias or prefix everything - the result is that my code isn't as readable as it should be.I'd like to propose the following changes:
TagLib.File
toTaggedFile
, to avoid conflicting withSystem.IO.File
.TagLib.Aac
,TagLib.Mpeg
prefix theirFile
subclass with the codec/format name. SoTagLib.Tiff.File
becomesTagLib.Tiff.TiffFile
.TagLib.Tiff.File < TagLib.Tiff.BaseTiffFile < TagLib.Image.File < TagLib.File
- that's 3 types all namedFile
!TiffImageFile
,BaseTiffImageFile
,ImageFile
andTaggedFile
respectively. Using these names makes their relationship much easier to understand.TagLib.Tiff
's types could be put into theTagLib.Image
namespace.TagLib.Formats.*
as a parent because it's unclear by sight if a namespace refers to a specific format or something else, for example I initially thought thatTagLib.Audible.File
was a superclass for all "audible" (audio) formats and not Audible.com's own format.File
, the specialised subclasses ofTagLib.Tag
(e.g.TagLib.Id3v2.Tag
) should also be prefixed named, e.g.Id3v2Tag
instead).I'm happy to do this myself if you're willing to accept a PR for it.
I'm sure there's other convention/idiom issues that FxCop/Code-Analysis would pick up that that I'd throw into my changes too.
The text was updated successfully, but these errors were encountered: