Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, November 23, 2010 1:51 PM
Hi,all,
I'm just learning a huge project. How can I get the list of namespace in a solution?
Thanks,
Andrew Huang
All replies (9)
Tuesday, November 23, 2010 4:20 PM ✅Answered
Derek, great! That's I wanted.
But this command doesn't work with:
'Select-String' is not recognized as an internal or external command, operable program or batch file.
Thanks,
Andrew Huang
Hi Andrew,
You'll need Powershell installed and/or run it through the Powershell command (powershell.exe). Sounds like you ran the command with cmd.exe
The cmd.exe is a bit limited but this cmd might be a way forward
findstr /s/r "^using" *.cs
…we each have more potential than we might ever presume to guess. (Blog: http://dsmyth.blogspot.com/)
Tuesday, November 23, 2010 2:02 PM | 1 vote
Open the Object explorer in VS.
Tuesday, November 23, 2010 2:14 PM
Open the Object explorer in VS.
Thanks, Louis. I mean how to get the name list which I can write into a document.Thanks,
Andrew Huang
Tuesday, November 23, 2010 2:43 PM | 1 vote
Hi,
Use Grep or even Powershell.....
dir -r -filter *.cs | Select-String -pattern "^using" | Select-Object -expand Line -unique | Format-List -property Line
Run the above in a solutions root directory and ... well here is one I just ran. Just pipe it into a file.
using System;
using MbUnit.Framework;
using AcceptanceTests.DLL;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Runtime.CompilerServices;
using NUnit.Framework;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
Man I love the command line.
…we each have more potential than we might ever presume to guess. (Blog: http://dsmyth.blogspot.com/)
Tuesday, November 23, 2010 2:48 PM
Type[] types = Assembly.GetExecutingAssembly().GetTypes(); //This will give you the fully qualified types, you can extract the namespaces from that, waiting for the clever Francis way
http://msdn.microsoft.com/en-us/library/xbe1wdx9.aspx //Read about the class
Also you can printscreen the object explorer and run it by an ocr (joking)
Regards
Tuesday, November 23, 2010 2:54 PM
Derek, great! That's I wanted.
But this command doesn't work with:
'Select-String' is not recognized as an internal or external command, operable program or batch file.
Thanks,
Andrew Huang
Tuesday, November 23, 2010 3:04 PM
Once you have all the types, you can select all distinct namespaces:
types.Select(t=>t.Namespace).Distinct()
Tuesday, November 23, 2010 3:07 PM
Hello,
How about using the Find and Replace feature of Visual Studio ? :p
In the find options, select Use "Regular Expressions" and find "using .*;"
Eyal, Regards.
commandbrowser.eyal7.net CodeVolume.Presenters
Tuesday, November 23, 2010 3:15 PM
Thanks, Serguey & Louis. I can't get the namespace because the assemblies didn't register.Thanks,
Andrew Huang