Reference3::Aliases Property
Visual Studio 2015
Gets or sets the aliased names for the specified reference. This property applies to Visual C# only.
Assembly: VSLangProj80 (in VSLangProj80.dll)
In Visual C#, you can use one or more alternate names, or aliases, for reference names in projects. This property allows you to view or set the aliases.
This example tests to see if a project is a Visual C# project, and it then lists all the aliases for the project references. Open a Visual C# project before running this example. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.
Imports VSLangProj Imports VSLangProj2 Imports VSLangProj80 Public Sub OnConnection(ByVal application As Object,_ ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _ ByRef custom As Array) Implements IDTExtensibility2.OnConnection applicationObject = CType(application, DTE2) addInInstance = CType(addInInst, AddIn) DisplayAliases(applicationObject) End Sub Public Sub DisplayAliases(ByVal dte As DTE2) ' The first project is a Visual Basic or C# project. Dim vsProject As VSProject2 = _ CType(applicationObject.Solution.Projects.Item(1).Object, _ VSProject2) Dim aRef As Reference3 Dim refStr As String refStr = "" If vsProject.Project.Kind = PrjKind.prjKindCSharpProject Then For Each aRef In vsProject.References refStr += (aRef.Name & " " & aRef.Aliases & vbCr) Next MsgBox(refStr) Else MsgBox("The project is not a C# project") End If End Sub
Show: