Better code completion for namespaces, and option to use Alias?

Hi all,

So my OCD mind is waging battle between using static classes vs namespaces.  

The two options are as follows:

Option 1 - Using static classes to enforce namespacing.

namespace Game.Core.Events {
public static ModuleEvents {
public struct LoadModuleEvent { ... }
}
}

// Usage
using Game.Core.Events;
...
var event = new ModuleEvents.LoadModuleEvent();

 

Option 2 - using namespaces:

namespace Game.Core.Events.ModuleEvents {
public struct LoadModuleEvent { ... }
}

// Usage
using ModuleEvents=Game.Core.Events.ModuleEvents;
...
var event = new ModuleEvents::LoadModuleEvent();

 

Pros and Cons:

I will point out, in either case, it's not necessary to have the ModuleEvents in front.  But what is super important is being able to find the specific event that I want quickly.  There will be hundreds of events to manage so being able to select the right one quickly when provided the group that it belongs to is a must.

Using static classes: 

  1. [BIG PRO] Can use code complete in the editor to quickly find the event that I want by starting to type ModuleEvents and importing easily. 
  2. [CON] Frowned upon to use static classes in this manner for namespaces

Using namespaces:

  1. [PRO] More aligned with the intent of namespaces.
  2. [PRO] The ModuleEvents:: stands out in the code more (which can be easily color adjusted as well).
  3. [BIG CON] Rider doesn't allow code complete with namespaces - for example, after typing "ModuleEvents", Rider won't see it unless I go from the beginning, typing: Game.Core.Events...
  4. [BIG CON] Rider doesn't allow me to quickly add Alias, I have to do it by hand.

 

My thoughts: I prefer the namespace option, I like the ModuleEvents:: look.  However, it's painstakingly slow to get it setup.  What would really help would be the following features:

  1. Include nested namespaces as part of the Code Complete somehow.
  2. Be able to annotate a namespace at its declaration as preferring to use an alias and have it integrated with the Inspection (suggestion/hint/warning/error..etc)

For example:

// ReSharper alias="ModuleEvents"
using ModuleEvents=Game.Core.Events.ModuleEvents;
...
var event = new ModuleEvents::LoadModuleEvent();

 

Any suggestions or thoughts?

Thanks,

James

Please sign in to leave a comment.