Skip to content
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

Namespace conflicts #48

Closed
fargs opened this issue Dec 5, 2020 · 9 comments · Fixed by #55
Closed

Namespace conflicts #48

fargs opened this issue Dec 5, 2020 · 9 comments · Fixed by #55
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@fargs
Copy link

fargs commented Dec 5, 2020

I have a namespace conflict issue when using your library. My namespace for my project has a ".Blazor." in it and yours starts with Blazor.Components.
When this issue is closed it shouldn't be an issue dotnet/razor#7670
I was expecting your library to be Majorsoft.Blazor.Components which would also resolve the issue.
Any suggestions for a workaround?

Thanks, your library is providing some very key components that are missing from even some of the larger commercial component libraries!

@majorimi
Copy link
Owner

majorimi commented Dec 5, 2020

Thanks for contacting me. Yes I want to ship very feature reach high quality Blazor components. More to be come...

It is an interesting issue. I have not encountered it so far. Could you give me some code example? Also not sure how are you adding @using-s to your project?

Meanwhile you can try out these, might work:

  • Try to add namespace using to _Imports.razor or your <component>.razor might one work.
  • Components can have "code behind" file. Just create a C# class with the name of <component>.razor.cs. This file should work as standard C# class. So you can try use using alias. However not 100% sure.
  • Last option is to create a new "Blazor Class Library" without the name ".Blazor." in it. Use my components in that new project and reference it into you Blazor App.

About the naming convention you are right. I have started to work on a this project with the current name. By the time I wanted to upload packages to Nuget.org realized "Blazor" name is taken. So I needed to "prefix" packages. I was thinking to rename all the projects and fix namespaces, etc. but seemed to much time which I wanted to spend on Features and Quality.

@fargs
Copy link
Author

fargs commented Dec 5, 2020

Thanks for responding :)
I think wrapping it in a class library is the best solution at this point.
The _Imports.razor still has the same issue and the issue is with the Component element in the markup so the code behind doesn't help.

I created the following project with a name where the issue occurs. Each of the three pages has examples of things I have tried. You will notice they all produce build errors.

https://github.com/fargs/NamespaceConflictExample.Blazor

Hope that helps. When I get the project wrapped I'll let you know if that works.

Thanks!

@majorimi
Copy link
Owner

majorimi commented Dec 8, 2020

Hi @fargs

Checked your example code. Yes it has build error. It is an unfortunate Blazor bug. I have reported quite a few bugs to Microsoft. Hope they fix it soon. At some point I might also find some time to align Namespaces with Package names.

Meanwhile you can do what I suggested. Create a Razor Class Library for 3rd party components (or just your components). Do not put "Blazor" into this project name. Wrap around my components or just use them in as Blazor suggests it. Create all your pages as components and reference this new 3rd party Library to your app. It works.

Updated code: NamespaceConflictExample.Blazor.zip

@majorimi majorimi self-assigned this Dec 8, 2020
@majorimi majorimi added question Further information is requested enhancement New feature or request labels Dec 8, 2020
@majorimi majorimi linked a pull request Dec 20, 2020 that will close this issue
@majorimi
Copy link
Owner

Hi @fargs,
Just merged the "mega renaming" branch 😄 it will bring the first breaking change to my components. Which is consolidating namespaces with package names. So when next version is released all Components must be used with "@using Majorsoft.Blazor.*".

I will try to publish new version 1.2 with other new components by end of this year.

@fargs
Copy link
Author

fargs commented Jan 2, 2021

Hey @majorimi,

That's awesome, thanks! I ended up forking your repo and included it in my project as a git submodule. I did the same rename refactor to Majorsoft.Blazor for the debounce component which was the main one I was after. I was going to offer to do that work for you but the holidays took over. Very happy to remove my fork and git submodule and use your package directly now! Happy new year!

@fargs fargs closed this as completed Jan 2, 2021
@majorimi
Copy link
Owner

majorimi commented Jan 3, 2021

Hi @fargs,

Yes unfortunately holidays were delaying me as well. So rename is still not published. I'm still trying to finishing up a new component. Will be done soon and released.
Also trying to find the best way to announce breaking change. Hope others won't be suffering and getting angry because of the build errors...

Thanks. Happy new year for you as well!

@majorimi
Copy link
Owner

majorimi commented Jan 5, 2021

Ok v1.2.0 was released today with your request in it...

@fargs
Copy link
Author

fargs commented Jan 15, 2021

I just removed my submodules and included the latest version as a nuget package reference and works like a charm. Thanks!!

@majorimi
Copy link
Owner

majorimi commented Jan 15, 2021

Hi @fargs,
Sounds good. Hope it will unblock other projects also. So thanks for the bug report.
If you happy with the result please endorse the project with with ⭐ and watch. Since I need 100+ star to become an "important" project. (yes Github is also about likes now...)

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants