In order to avoid the file locking issue or if you do not want to reference your Project2, try what I like to call "Design Time Reflection".
Since you have both projects (The one containing the T4 and the one containing the class you want to reflect) in the same solution, you can use the EnvDTE.CodeModel to transverse all code artifacts in your solution (Namespaces, Classes, ...) without the need to have Project2 built and referenced.
Have a look at the VisualStudio Automation. And if you are using tangible's T4 Editor, there is a free reusable template in their gallery that eases the access to the EnvDTE.CodeModel from within a T4 template.
This might be a good start point: http://t4-editor.tangible-engineering.com/blog/walking-the-visual-studio-code-model-with-t4-template.html