-
Notifications
You must be signed in to change notification settings - Fork 57
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
Class and Namespace Name Collision #30
Comments
Hi @lawrence-laz, thanks for mentioning this! I hadn't considered this problem before. I never add the Problem and Immediate Solution// Causes error CS0118: 'Spectrogram' is a namespace but is used like a type
using Spectrogram;
var spec = new Spectrogram(...); // This works, but is long and looks redundant
var spec = new Spectrogram.Spectrogram(...); // This works, but is nontraditional
using SG = Spectrogram;
var spec = new SG.Spectrogram(...); Potential Fix: Rename the Namespace
I could rename the Potential Fix: Rename the ClassThe
The proposed change would allow user code to look like this: using Spectrogram;
var spec = new SGram(...); |
Rename Spectrogram.Spectrogram to Spectrogram.SGram to avoid namespace collision #30. Old class was preserved but marked obsolete.
I created a PR (#31) where the class is renamed. I'll probably let this sit here for a few days in case anyone wants to say anything about it before I merge it in and release a new package on NuGet. Using the old Spectrogram/src/Spectrogram/Obsolete.cs Lines 7 to 14 in 0f73874
|
Renaming a class seems like a very good alternative. 👍 The name But as long as there are no collisions I am happy! And thanks for a great library 🙂 |
I think I agree with you here! // this is shorter, but cryptic
var sg = new SGram(sampleRate, fftSize: 4096, stepSize: 500, maxFreq: 3000);
sg.Add(myData);
sg.SaveImage("data.png"); // this is more to type, but more expressive
var sg = new SpectrogramGenerator(sampleRate, fftSize: 4096, stepSize: 500, maxFreq: 3000);
sg.Add(myData);
sg.SaveImage("data.png"); Expressiveness and readability should be favored over character count... I'll sleep on this one for a day or two and come back with fresh eyes before I make a final call! Thanks again for pointing it out @lawrence-laz. I'll leave this issue open until I fix it and the new package is in NuGet |
Thanks again for raising this issue @lawrence-laz! I ended-up changing it to |
Main class and namespace in which it is declared share the same name.
This causes some inconvenience when creating an instance.
I know this is a breaking change, but have you considered changing the namespace's name?
The text was updated successfully, but these errors were encountered: