I noticed PowerShell lets you write types like [Collections.Generic.List[string]] without the [System] prefix. Do you usually omit it, or keep the full namespace for clarity and consistency?
Do you leave off System in PowerShell type names?
Answers
For ordinary scripts, Iโd omit it when the shorter name is clear. It is supported syntax and makes common types less tedious to write. I wouldnโt treat it as a performance trick, though. The claimed lookup speed advantage doesnโt hold up.
Reply to this answer
I lean toward fully qualified names in shared code, especially when there are several types or namespaces in play. The extra text can make it easier to tell exactly what a type refers to, and it lines up with tools and generated output that often include System.
Reply to this answer
Tab completion is a big part of this for me. If the editor fills in the full name, deleting the prefix feels like extra work, and the expanded name can be handy when searching documentation or looking at unfamiliar code.
Reply to this answer
Thereโs also an explicit middle ground: put a namespace in a using namespace statement, then use shorter type names. That can be convenient in a focused script, but broad imports may make name conflicts harder to spot, particularly when code is split across files.
Reply to this answer
Add your answer
Answers are reviewed before publication.
c6__Dremble:
That makes sense for consistency, though Iโd still shorten a type in a small script if the full name adds clutter without helping the reader.