jspuij / RESTier

A turn-key library for building RESTful services
http://odata.github.io/RESTier
Other
2 stars 0 forks source link

Remove all System namespaces #37

Open jspuij opened 3 years ago

jspuij commented 3 years ago

Don't pollute the system namespaces from another library.

robertmclaws commented 3 years ago

Can you elaborate on this a little bit?

jspuij commented 3 years ago

There are classes in Restier that live in the System.<xxx> namespaces, probably to prevent usings or because netstandard 2.0 did not have them. They now either conflict or could conflict with other libraries that have classes in the same namespace. It's good practice to just keep everything in Microsoft.Restier.<xxx> and subnamespaces.

robertmclaws commented 3 years ago

If they were Extensions, I do that because importing weird namespaces in order to get extensions tends to be weird. I put extension methods in the original namespace, so that they just show up when you need them.

jspuij commented 3 years ago

I understand it's a bit of an inconvenience to right-click to generate the using statement or have your users look into the documentation. However, it's more annoying if two libraries import the same class or extension method into the same namespace and people have to start working with assembly aliases to resolve them. It happened to me multiple times and it is not fun. In this case, it was even worse as two classes are implemented in .net 4.7.2 and netstandard 2.1, but not in netstandard 2.0. (the metadata stuff). Using these classes (and the right ones, the Restier ones) required assembly aliasing from both runtimes. I've worked around it for now by retargeting Restier for both net472 and netstandard2.1 and NOT netstandard2.0 anymore. Now I can just use the framework classes that are present in the classic, core and mono runtimes, and not worry about netstandard2.0 anymore. There are still some other classes that seem to be Restier specific (even internal) that live in system namespaces that could probably better be moved outside the System.<xxx> namespaces.